
function close_photo(id){

document.getElementById('photo_div'+id).style.display = 'none';

}

function open_photo(id, user_id, index,stamp,type){

	document.getElementById('photo_div'+id).style.display = 'block';
	if(index!=1){
	
		var pre_index = index-1;
		var next_index = index+1;	
	
	
	
	}
	
	else{
	
	}
	
	
	document.getElementById('photo_cnt'+id).innerHTML = '<img alt="alt" src="/sh_users_images/original_'+user_id+'_'+index+'_'+stamp+'.'+type+' " />';
} 



/*
var s_divs = new Array('s_price','s_units','s_firms','s_second');

function show_search(name){

	for(var i=0; i<=3;i++){
		if (s_divs[i] == name) {
			document.getElementById(name).style.display = 'block';
			
		}
		else {
		
			document.getElementById(s_divs[i]).style.display = 'none';
		}
	}

}
*/



var code = new Array();
	
		function showCode(id){
		alert(id);
			if(!code[id] || code[id]==0){
				code[id] = 1;
				document.getElementById('codeCont'+id).style.display = 'block';
			}
			else {
				
				code[id] = 0;
				document.getElementById('codeCont'+id).style.display = 'none';
			
			}
			
			//alert(code[id]);
			
		}


function deleteField(a) {
    
    var contDiv = a.parentNode;
    
    contDiv.parentNode.removeChild(contDiv);
    
    countOfFields--;
    
    return false;
}



function addField() {
  
    if (countOfFields >= maxFieldLimit) {
        alert("Ìàêñèìóì = " + maxFieldLimit);
        return false;
    }
    
    countOfFields++;
    
    curFieldNameId++;
    
    var div = document.createElement("div");
    
    div.innerHTML = "<input name=\"files"+curFieldNameId+"\" type=\"file\" /> <a onclick=\"return deleteField(this)\" href=\"#\" style=\"font-size:11px;\">óäàëèòü</a>";
    
    document.getElementById("photos").appendChild(div);
    
    return false;
}




var count_photos = 0;
function del_div(id){

	document.getElementById(id).innerHTML = '';

}
function add_photo(){
	count_photos ++;
	
	document.getElementById('photos').innerHTML += '<div id="photo'+count_photos+'"><input type="file" name="files[]" />&nbsp;&nbsp;&nbsp;<a href="javascript: del_div(\'photo'+count_photos+'\');">ÑƒÐ´Ð°Ð»Ð¸Ñ‚ÑŒ</a></div>';
	
}

/*
tinyMCE.init({
	mode: "exact",
	elements: "body,",
	theme: "advanced",
	language: "ru",
	plugins : "table,advhr,advlink,iespell,preview,zoom,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable",
	//theme_advanced_buttons1_add_before : "newdocument,separator",
	//theme_advanced_buttons1_add : "fontselect,fontsizeselect",
	theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
	theme_advanced_buttons3_add_before : "tablecontrols,separator",
	theme_advanced_buttons3_add : "filemanager,imanager,ibrowser,iespell,flash",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_path_location : "bottom",
	plugin_insertdate_dateFormat : "%Y-%m-%d",
	plugin_insertdate_timeFormat : "%H:%M:%S",
	extended_valid_elements : "hr[class|width|size|noshade|style],font[face|size|color|style],span[class|align|style],li[class|style]",
	theme_advanced_resize_horizontal : false,
	document_base_url : "/",
	flash_wmode : "transparent",
	flash_quality : "high",
	flash_menu : "false",
	content_css: "/style.css",
	/*table_styles: "Header 11=header1;Header 2=header2;Header 3=>header3",
	table_cell_styles: "Header 111=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
	table_row_styles: "Header 1111=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",  * <<< comment end here
	table_cell_limit : 100000,
	table_row_limit : 100,
	table_col_limit : 100,
	theme_advanced_resizing: true,
	relative_urls: false,
	remove_script_host: true,
	convert_urls: true
});
 */

		var code = new Array();
	
		function showCode(id){
		
			if(!code[id] || code[id]==0){
				code[id] = 1;
				document.getElementById('codeCont'+id).style.display = 'block';
			}
			else {
				
				code[id] = 0;
				document.getElementById('codeCont'+id).style.display = 'none';
			
			}
			
			//alert(code[id]);
			
		}
	
	
	
      function basketUpdate(value) {
      var req = new JsHttpRequest();      
      req.onreadystatechange = function() {
        if (req.readyState == 4) {          
          document.getElementById('result').innerHTML = req.responseJS.c;          
//          document.getElementById('debug').innerHTML = req.responseText;
        }
      }
      // Prepare request object (automatically choose GET or POST).
      req.open(null, '/ajax/basket.php', true);
      // Send data to backend.
      req.send( { q: value } );
      }
    
	
	
	

	function getSelText(){
           var txt = '';
           if (window.getSelection){
                   txt = window.getSelection();
           }else if (document.getSelection){
                   txt = document.getSelection();
           }else if (document.selection){
                   txt = document.selection.createRange().text;
           }
          return txt;
   }
	

	
    document.onkeypress = function(){
		 
	
           var e = arguments[0] || window.event;
           var code=e.keyCode?e.keyCode:(e.which?e.which:e.charCode);
             
			//alert(e.ctrlKey);
			 
			 //alert(code);
			 
		   if(e.ctrlKey && (code==10 || code == 13)){
		   		   	
					
					
                   var text = getSelText();
                   document.getElementById('BoxOverlay').style.display = 'block';				  
				   document.getElementById('SexyAlertBox-Box').style.display = 'block';
				   document.getElementById('ertext').innerHTML = text;
				   
				   location.href="#message";
           }
    }
	
	function hide_fon(){
		document.getElementById('BoxOverlay').style.display = 'none';
		document.getElementById('SexyAlertBox-Box').style.display = 'none';
		//document.getElementById('ertext').innerHTML = '';
		//document.getElementById('BoxPromptInput').value = '';
	}
	
	function show_thanks(){
		document.getElementById('BoxOverlay').style.display = 'block';
		document.getElementById('SexyAlertBox-Box1').style.display = 'block';		
	}
	
	function hide_thanks(){
		document.getElementById('BoxOverlay').style.display = 'none';
		document.getElementById('SexyAlertBox-Box1').style.display = 'none';
	}




