function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// Validate email address
function validate_emailaddress(arg){
	var str = arg;
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
	   return true;
	}
	else{
		return false;
	}
}

function chkloginfrm(frm)
{
	var errorMsg='';
	if (Trim(frm.username.value) == ""){
			errorMsg += "\n\tPlease enter the Username";	
	}
	if (Trim(frm.password.value) == ""){
			errorMsg += "\n\tPlease enter the Password";	
	}
	if (errorMsg != ""){
		msg = "Please correct the problem(s) and re-submit the form.\n";
		msg += "_____________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	return true;	
}


var reqObj = null;
function createRequest(){
	try {
	   reqObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (err)	{
			try {
			reqObj = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (err2) {
			try {
			   reqObj = new XMLHttpRequest();
			}
			catch (err3) {
			   reqObj = null;
			}
		}
	}
	return reqObj;
}

function show(id){
	xmlhttp = createRequest();
	if(xmlhttp != null){
		xmlhttp.open("GET", "getcontent.php?id="+id+"&rand="+Math.random(1,10), true);
		xmlhttp.onreadystatechange = display_content;
		xmlhttp.send(null);
	}	
}

function display_content(){
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
		  var disp = xmlhttp.responseText;
		  var disp_arr = disp.split('::');
		  document.getElementById('contenttitle').innerHTML = disp_arr[0];
		  document.getElementById('contentarea').innerHTML  = disp_arr[1];
		}
	}
}
function browser(strFile, intWidth, intHeight) {
  var desktop;
  if (desktop && desktop.location) desktop.close();
  desktop = window.open(strFile, "_blank","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=" + intWidth + ",height=" + intHeight);
}

function openpopup_printpage(theURL){
    window.open(theURL,'printpage','scrollbars,resizable,height=550,width=300');
}

function windowopen(URL,widthwin,heightwin){
	 var screenH = screen.height;
	 var screenW = screen.width;
	 var fromLeft = parseInt((screenW-widthwin)/2);
	 var fromTop = parseInt((screenH-heightwin)/2);
	var newwin=window.open(URL,'invitation_guest_email','width='+widthwin+',height='+heightwin+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,top='+fromTop+',left='+fromLeft)
	if(window.focus) newwin.focus();
}

