function blank(a) { if(a.value == a.defaultValue) a.value = ''; }
function unblank(a) { if(a.value == '') a.value = a.defaultValue; }

function showpage(id){
	if(document.getElementById){
		document.getElementById(id).style.visibility='visible';
	}
	else if(document.all){
		document.all[id].style.visibility='visible';
	}
	else if(document.layers){
		document.layers[id].style.visibility='visible';
	}
}
function showid(id) {
	if (document.getElementById) {
		document.getElementById(id).style.display='block';
	}
	else {
		if (document.layers) {
			document.layers[id].style.display='block';
		}
		else {
			document.all[id].style.display='block';
		}
	}
}
function hideid(id) {
	if (document.getElementById) {
		document.getElementById(id).style.display='none';
	}
	else {
		if (document.layers) {
			document.layers[id].style.display='none';
		}
		else {
			document.all[id].style.display='none';
		}
	}
}

function standard(str,file,id){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){alert ("Your browser does not support this function, update to the latest version");return;}
	xmlHttp.onreadystatechange=function(){stateChangedSD(id)};
	var params = str;
	xmlHttp.open("POST",file,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
}
function stateChangedSD(id){if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){document.getElementById(id).innerHTML=xmlHttp.responseText;}}

function standardMSG(str,file,id,fname){
	var formname = eval("document."+fname);
	if(formname.content.value!=""){
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){alert ("Your browser does not support this function, update to the latest version");return;}
		formname.button.value="Posting...";
		formname.content.style.backgroundColor='#bbc6c0';
		xmlHttp.onreadystatechange=function(){stateChangedSDM(formname,id)};
		formname.content.value = formname.content.value.replace(/&/g,"and");
		var params = "&content="+formname.content.value+str;
		xmlHttp.open("POST",file,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
	}
	else{
		formname.button.value="No Content";
		formname.button.style.backgroundColor='Red';
	}
}
function stateChangedSDM(formname,id){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		formname.button.value="Post";
		if (formname!=document.CCountry && formname!=document.change_about && formname!=document.change_tlocation && formname!=document.change_tabout){formname.content.value="";}
		formname.content.style.backgroundColor='#FDF9DF';
		document.getElementById(id).innerHTML=xmlHttp.responseText;
	}
}


function js001(str){ 
	if (str.length==0){
		document.getElementById("txtHint").innerHTML="";
		return;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){alert ("Your browser does not support this function, update to the latest version");return;}
	xmlHttp.onreadystatechange=stateChangedHint;
	xmlHttp.open("GET","func/searchbox.php?p="+str,true);
	xmlHttp.send(null);
}

function stateChangedHint(){if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){document.getElementById("txtHint").innerHTML=xmlHttp.responseText;document.getElementById("txtHint").style.visibility = 'visible';}}

function GetXmlHttpObject(){
	if (window.XMLHttpRequest){return new XMLHttpRequest();}
	if (window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}
	return null;
}

//////////////////////////////////////////////////////

var DDSPEED = 2;
var DDTIMER = 15;
var OFFSET = 0;
var ZINT = 100;

function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    c.style.display = 'block';
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.left = (h.offsetWidth + OFFSET) + 'px';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    ZINT = ZINT + 1;
    c.style.zIndex = ZINT;
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}
/*
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = Math.round((c.maxh - currh) / DDSPEED);
  }else{
    dist = Math.round(currh / DDSPEED);
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if(currh > (c.maxh - 2) && d == 1){
    clearInterval(c.timer);
  }else if(dist < 1 && d != 1){
    clearInterval(c.timer);
    c.style.display = 'none';
  }
}

function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = Math.round((c.maxh - currh) / DDSPEED);
  }else{
    dist = Math.round(currh / DDSPEED);
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  if(d == 1){c.style.visibility = 'visible';}
  if(d == -1){c.style.visibility = 'hidden';}
  if(currh > (c.maxh - 2) && d == 1){
    clearInterval(c.timer);
  }else if(dist < 1 && d != 1){
    clearInterval(c.timer);
    c.style.display = 'none';
  }
}*/

function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  if(d == 1){c.style.visibility = 'visible';}//currh / c.maxh;
  if(d == -1){c.style.visibility = 'hidden';}
    
  //c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}


////////////////////////////////////

// main function to handle the mouse events //
function ddMenuD(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlideD(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapseD(c)},50);
  }
}

// collapse the menu //
function ddCollapseD(c){
  c.timer = setInterval(function(){ddSlideD(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHideD(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlideD(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlideD(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  if(d == 1){c.style.visibility = 'visible';}//currh / c.maxh;
  if(d == -1){c.style.visibility = 'hidden';}
    
  //c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}