window.onerror = function(msg, url, line)
{
	//alert(msg + "\r\n" + line);
	return(true);
}
window.AJAX_SERVER = '/cm-site/includes/ajax-server.php';
/* preload images */
function PreloadImage()
{ 
  var args = PreloadImage.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

/* 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=605, height=600, left=100, top=100, location=no, menubar=no, resizable=no, 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=432, height=480, left=100, top=100, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, fullscreen=no");
}

function toggleTextOut(e,txtval) {
	if(e.value=="") e.value = txtval;
	
}

function toggleTextIn(e,txtval) {
	if(e.value==txtval) e.value="";
	else e.select();
}
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 '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 changeImage(id,clsname){ 
	submitBtn = document.getElementById(id);
	submitBtn.className=clsname;
	
}
function restoreImage(id,clsname){
	submitBtn = document.getElementById(id);
	submitBtn.className=clsname;
}
function searchboxValidate(){
	sb = document.getElementById('txtSearchBox').value;
	if(sb=="Search here..."){
	alert('Please enter a search query');
	document.getElementById('txtSearchBox').focus();
	return false;
	}
	return true;
}

