var Tout;

function Toggle(id1,id2,obj,color){

  setTimeout(function(){ChangeColor(obj,color);},0);
  document.getElementById(id1).style.display ="none";
  document.getElementById(id2).style.display ="block";  
}

function ChangeColor(obj,color){
 obj.style.backgroundColor ="#"+color;
}


function linkMouseOver(obj){
 obj.style.backgroundColor ="#A33905";
 obj.style.color  = "#fff";

}


function linkMouseOut(obj){
 obj.style.backgroundColor="#fff";
 obj.style.color="#000";

}


function show(id,num){
 for(i=0;i<num;i++){
   if(document.getElementById('subm'+i)){
     document.getElementById('subm'+i).style.display="none";}
 }
 for(var i in document.getElementById('subm'))
   alert(i);
 if(Tout!="") clearTimeout(Tout); 
   document.getElementById('subm'+id+'').style.display="block";
}

function hide(id){
 if(Tout!="") clearTimeout(Tout); 
   Tout=setTimeout("document.getElementById('subm"+id+"').style.display='none'",500);
}
 
 
 

function lang(lang)
{
 var current=window.location.href;
 var new_loc;
 if(/lang=/.test(current))
   new_loc=current.replace(/lang=\w*/,"lang="+lang);
 else if(/\?/.test(current))
   new_loc=current+"&lang="+lang;
 else 
   new_loc=current+"?lang="+lang;  
 window.location.replace(new_loc);
}

var send = function(link){
 var dataToSend =document.getElementById('calendar_y').value+"."+document.getElementById('calendar_m').value;
 var ajax = new httpAjaxRequest(); 
 if(ajax)
  {  
     ajax.prepareHash({date:dataToSend}); 
     ajax.open("GET", "ajax.php");
     ajax.send();
     ajax.getData();
     ajax.onreadystatechange = function()
       { 
           data =ajax.getResult();
           document.getElementById("calendar_div").innerHTML =data.calendar; 
       }  
  }
 else window.location =link + document.getElementById('calendar_y').value+"."+document.getElementById('calendar_m').value; 
}
 
function showPic(pic,width,height)
{ 
  sDesrc = "width=" + width + ", height=" + height +
  		", status=no, toolbar=no, menubar=no, scrollbars=no";
  win=window.open("Gallery", "", sDesrc);
  win.document.write("<html><style>body{padding:0px;margin:0px;}</style><body>");
  win.document.write("<img src='uploads_script/gallery/"+pic+"' width='"+width+"' height='"+height+"'><br>");
  win.document.write("</body></html>");
  win.document.close();
} 


function ShowHide(elemID,param) {
	var obj = document.getElementById(elemID);
	if 		(param == 'block' || param == 'show') {
		obj.style.display = 'block';
	}
	else if	(param == 'none' || param == 'hide') {
		obj.style.display = 'none';
	}
	else {
		obj.style.display = (obj.style.display=='none')?'block':'none';
	}
}








function drawOptions(arr,selected){
  selected = selected||"";
  for(var i in arr){
     select = (i==selected)?"selected":'';
     document.write('<option value="'+i+'" '+select+'>'+arr[i]+'</option>');
   }
}

function switchCountry(obj,selected){
  selected = selected||'';
  var ind = obj.options[obj.selectedIndex].value; 
  var selbox2 = document.getElementById('city');
  delOptions(selbox2);
  for(var i in city){
    if(ind==city[i][0])
      createOption(selbox2,i,city[i][1],selected);
   } 
}

function createOption(parent,val,text,selected){
  var opt = document.createElement("option");
  opt.value = val;
  opt.innerHTML = text;
  if(val==selected)
	 opt.selected = true;
  parent.appendChild(opt);
}

function delOptions(obj){
  var count = obj.options.length-1; 
  for(i=count; i>0; i--)
	obj.removeChild(obj.options[i]);
}


