
function preloadImages()
{
	var imgPreload;
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_start_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_next_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_prev_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_findoutmore_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_print_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_download_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_invite_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_send_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_reset_ov.png"; 
	imgPreload = new Image(); imgPreload.src = "/profilequiz/static/images/btn_takequiz_ov.png";
}


function printThisPage(strScriptPath, width, height) 
{ 
	var w=550;
	var h=600;
	if (width>0) { w=width; }
	if (height>0) { h=height; }
	var l=2;
	var t=2;	
	l=(screen.availWidth-w)/2;
	t=(screen.availHeight-h)/2;
	var sOption="toolbar=no,location=no,directories=no,menubar=yes,status=yes,scrollbars=yes,width="+ w  +",height="+ h +",left="+ l +",top="+ t +""; 			   
	var winprint=window.open(strScriptPath,"wFAQuizPrint",sOption); 			 
	winprint.focus(); 
}

function getPrintContent()
{     
	var PrintDiv =  document.getElementById('divPrintContent');
	var PrintTitleDiv = "";
	try { PrintTitleDiv = window.opener.document.getElementById('divPrintTitle'); } catch(errC) {}
	var ContentDiv =  "";
	try { ContentDiv = window.opener.document.getElementById('divPrintFriendlyContent'); } catch(errC) {}
	var SubContentDiv =  "";
	try { SubContentDiv = window.opener.document.getElementById('divPrintFriendlySubContent'); } catch(errC) {}
	var Parent_Title =  window.opener.document.title;
	document.title=Parent_Title;

	PrintDiv.innerHTML = "";
	if (PrintTitleDiv) { PrintDiv.innerHTML = PrintDiv.innerHTML + "<div class='clear'>" + PrintTitleDiv.innerHTML + "</div><hr/>"; }
	if (window.opener.document.getElementById('divPrintFriendlySubContent'))
	{ 
		if (SubContentDiv) { PrintDiv.innerHTML = PrintDiv.innerHTML + "<div id='content'>" + SubContentDiv.innerHTML + "</div>"; }
	}            
	else
	{ 
		if (ContentDiv) { PrintDiv.innerHTML = PrintDiv.innerHTML + "<div id='content'>" + ContentDiv.innerHTML + "</div>"; }
	}            
	
	var ai=0;
	for(ai=0;ai<document.getElementsByTagName('a').length;ai++)
	{
		if ((document.getElementsByTagName('a')[ai].id!='hyperlinkPrint')&&(document.getElementsByTagName('a')[ai].id!='hyperlinkClose'))
		{
			document.getElementsByTagName('a')[ai].href='#';
			document.getElementsByTagName('a')[ai].onclick='return false;';
			document.getElementsByTagName('a')[ai].target='_self';            
		}
	}


	try {
		for(ai=0;ai<document.getElementsByTagName('img').length;ai++)
		{
			if (document.getElementsByTagName('img')[ai].className=='printablePNG')
			{
			
				document.getElementsByTagName('img')[ai].src=document.getElementsByTagName('img')[ai].alt;
				
			}
		}
	} catch(errC) {}

}



function getXmlHttpRequest()
{ 	var httpRequest=null;
	try
	{ httpRequest=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e)
	{
		try
		{ httpRequest=new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(e)
		{ httpRequest=null; }
	}
	if(!httpRequest&&typeof XMLHttpRequest!="undefined")
	{ httpRequest=new XMLHttpRequest(); }
	return httpRequest;
}

function postURL(url, data, async, stateChangeCallback)
{
	var xmlHttpReq = getXmlHttpRequest();
	if (!xmlHttpReq)
		return;
	xmlHttpReq.open("POST", url, async);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttpReq.send(data);	
	xmlHttpReq.onreadystatechange=function()
	{ stateChangeCallback(xmlHttpReq); };
}

function postURLWithCallbackID(id, url, data, async, stateChangeCallback)
{
	var xmlHttpReq = getXmlHttpRequest();
	if (!xmlHttpReq)
		return;
	xmlHttpReq.open("POST", url, async);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttpReq.send(data);	
	xmlHttpReq.onreadystatechange=function()
	{ stateChangeCallback(xmlHttpReq, id); };
}

function postURLSingleObj(xmlHttpReq, url, data, async, stateChangeCallback)
{
	if (!xmlHttpReq)
		return;
	xmlHttpReq.open("POST", url, async);
	xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttpReq.send(data);	
	xmlHttpReq.onreadystatechange=function()
	{ stateChangeCallback(xmlHttpReq); };
}


function processReqChange(req)
{ 
	if (req.readyState==4||req.readyState=='complete')
	{
		if (req.status==200)
		{ }
	
	}
}


function LTrim(str)
{
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(0)) != -1) {
	var j=0, i = s.length;

	while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	j++;

	s = s.substring(j, i);
	}
	return s;
}

function RTrim(str)
{
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	var i = s.length - 1;       // Get length of string

	while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
	i--;

	s = s.substring(0, i+1);
	}
	return s;
}

function Trim(str)
{
	return RTrim(LTrim(str));
}
  
function validateEmail(str)
{
	var emailExp = new RegExp("[A-Za-z0-9\-\_\+\.][A-Za-z0-9]+@[A-Za-z0-9\-\_][A-Za-z0-9]+\.[A-Za-z][A-Za-z\-\.]*$");
	if ( (Trim(str) == "") || (!emailExp.test(str)) || (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Trim(str)) ) )  
	{  return false; }        
	else
	{ return true; }
}  
