function ShowHide(theTable)
{
     obj = document.getElementsByTagName('ul');
      for (i=0; i<obj.length; i++)
     {
          if (obj[i].id == theTable)
			if (obj[i].style.display != 'block')
				obj[i].style.display = 'block';
			else
				obj[i].style.display = 'none';
     }
}


function toggleTextOut(e,txtval) {
	if(e.value=="") e.value = txtval;
	
}
function toggleTextIn(e,txtval) {
	if(e.value==txtval) e.value="";
	else e.select();
}

/* print specific functions */

function GetData(id)
{
	var content = document.getElementById(id);
	if(content == null)
		return("");
	return(content.innerHTML);
}

function Print(printPage, id, title)
{
	if(title == '')
		title = document.title;
	var url = printPage + "?id=" + id + "&title=" + title
	var p = window.open(url, "print", "width=529, height=600, left=100, top=100, location=no, menubar=yes, resizable=yes, scrollbars=yes, status=no, toolbar=no, fullscreen=no");
}
	
function PrintThisPage(id, printId)
{ 	var content = document.getElementById(printId);
	if(content == null)
		return;
	if(window.opener == null)
		return;
	var html = window.opener.GetData(id);
	html = DisableHyperlinks(html);
	content.innerHTML = html;
	
	window.print();
}

function DisableHyperlinks(html)
{
	return(html.replace(/href\s*=\s*\"*[^\">]*"/ig,"href=\"#\""));
}

/* email specific functions */

function Email(url)
{
	url = url + "&page_title=" + document.title;
	var p = window.open(url, "email", "width=400, height=500, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, fullscreen=no");
}

function numbersonly(e){
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8){ 
		if (unicode<48||unicode>57) 
		return false
		}
	}
	function AllowOnly(e,type,allow_space)
	{
	  if (allow_space==null) allow_space=false; else allow_space=true; 
	  if(e.charCode==0) return true;
	  var unicode=e.charCode? e.charCode : e.keyCode;
	  if(unicode==13) return true;
	  if(allow_space && unicode==32)  
	   	return true;
	  switch(type)
	  {
	  case 'NUM_ONLY':
	    if(unicode < 48 || unicode > 57) return false; else return true;
	  case 'ALPHA_ONLY':
	    if(unicode <65 || unicode >90) 
	      if(!(unicode >= 97 && unicode <=122))
	        return false;
	      else
	        return true;
	  case 'NUM_SYMBOL_ONLY':
	   if(unicode >= 48 && unicode <= 57)
	      return true;
	   else if(unicode >= 40 && unicode <= 43)
	        return true;
	   else
	      return false;
	  case 'ALPHA_NUM_ONLY':
	   if(unicode >= 65 && unicode <= 90)
	      return true;
	   if(unicode >= 97 && unicode <= 120)
	        return true;
	   if(unicode >= 48 && unicode <= 57)
	      return true;
	   else
	      return false;
	   
	  }
	}
// 
function isAlphaOnly(e)
	{
		
	var unicode=e.charCode? e.charCode : e.keyCode
		
		if (unicode!=8 && unicode!=13 && unicode!=9){ 	
		str=String.fromCharCode(unicode);
		var re = /^[a-z A-Z]+$/; 
		 // validation fails if the input doesn't match the regular expression 
	 if(!re.test(str))
		  { 
		  	 return false;
		   }
		}
	   return true;
	}



sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

function isValidEmail(str)
	{
		filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		return(filter.test(str));
	}
	
function trimAll(sString)
{
		while (sString.substring(0,1) == ' ')
		{
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
			sString = sString.substring(0,sString.length-1);
		}
	return sString;
}

function searchboxValidate(){
	
	sb = document.getElementById('txtSearchBox').value;
	sb=trimAll(sb);
	if(sb=="Search here..." || sb==""){
	alert('Please enter a search query');
	document.getElementById('txtSearchBox').focus();
	return false;
	}
	return true;
}