
function PopUpPrint(sSource){
	//PrintWindow = window;
	PrintWindow = open(sSource);
	PrintWindow.print();
}

function pop564() {
	window.open("popframe.html", "", "height=564,width=448,left=174,top=55,scrollbars=0");	
}

function searchform()
{
  document.mainsearch.submit();
}

function CheckSearch(){
	document.all.FindProduct.value = document.all.txtFindProduct.value; 
	if(document.all.txtFindProduct.value != ''){ 
		searchform();
	}
}

/*
Added v2.6 for popup functionality.
*/
var m_rWindow
function isObject(a) {
	return (typeof a == 'object' && !!a) || isFunction(a);
}
function isFunction(a) {
	return typeof a == 'function';
}
function boom(){
	if (isObject(m_rWindow) == true) {
		m_rWindow.close();
	}
}
function SpawnPop(sURL, sWindowName, sLocation, sMenuBar, sScrollbars, sResizable, iTop, iLeft){

	var iWidth, iHeight, sFeatures;
	iWidth = 449;
	iHeight = 565;
	sFeatures = 'toolbar=no,location=' + sLocation + 
				',directories=no,status=no,menubar=' + sMenuBar + 
				',scrollbars=' + sScrollbars + 
				',resizable=' + sResizable + 
				',width=' + iWidth + 
				',height=' + iHeight + 
				',top=' + iTop + 'px' + 
				',left=' +iLeft+ 'px';
	boom();			
	m_rWindow = window.open(sURL,sWindowName,sFeatures);				
}

function SpawnPopDelayBoom(sURL,sWindowName,sLocation,sMenuBar,sScrollbars,sResizable,iTop,iLeft,iWidth,iHeight,iDelay){
	var iWidth, iHeight, sFeatures;
	sFeatures = 'toolbar=no,location=' + sLocation + 
				',directories=no,status=no,menubar=' + sMenuBar + 
				',scrollbars=' + sScrollbars + 
				',resizable=' + sResizable + 
				',width=' + iWidth + 
				',height=' + iHeight + 
				',top=' + iTop + 'px' + 
				',left=' +iLeft+ 'px';
	m_rWindow = window.open(sURL,sWindowName,sFeatures);
	setTimeout("boom()",iDelay);				
}

function Spawn(sURL, sWindowName, sLocation, sMenuBar, sScrollbars, sResizable, iTop, iLeft, iWidth, iHeight){

	var iWidth, iHeight, sFeatures;
	//iWidth = 449;
	//iHeight = 565;
	sFeatures = 'toolbar=no,location=' + sLocation + 
				',directories=no,status=no,menubar=' + sMenuBar + 
				',scrollbars=' + sScrollbars + 
				',resizable=' + sResizable + 
				',width=' + iWidth + 
				',height=' + iHeight + 
				',top=' + iTop + 'px' + 
				',left=' +iLeft+ 'px';
	boom();			
	m_rWindow = window.open(sURL,sWindowName,sFeatures);				
}

function SpawnPopDefault(sPopTarget) {
	var sURL = '/pop.aspx?source=' + escape(sPopTarget);
	var sWindowName = 'TheResourceWindow';
	var sLocation = 'no';
	var sMenubar = 'no';
	var sScrollbars = 'no';
	var sResizable = 'no';
	var iTop = 50	//(screen.width/2) - 262.5;
	var iLeft = 50	//(screen.height/2) - 137.5;

	SpawnPop(sURL, sWindowName, sLocation, sMenubar, sScrollbars, sResizable, iTop, iLeft);
}

function PopGen(sn){

	var sURL = '/pop.aspx' + '?source=' + escape('gen.aspx?pf=pop&sn=' + sn);
	var sWindowName = 'TheResourceWindow';
	var sLocation = 'no';
	var sMenubar = 'no';
	var sScrollbars = 'no';
	var sResizable = 'no';
	var iTop = 50	//(screen.width/2) - 262.5;
	var iLeft = 50	//(screen.height/2) - 137.5;
	
	SpawnPop(sURL, sWindowName, sLocation, sMenubar, sScrollbars, sResizable, iTop, iLeft);

}
/*Vu added 2 functions below*/
function EmailPopup(sPopTarget)
{	
	sPopTarget=sPopTarget + '&submittedemail=' + document.forms[0].txtCheckEmail.value;
	var sURL = '/pop.aspx?source=' + escape(sPopTarget);
	var sWindowName = 'TheResourceWindow';
	var sLocation = 'no';
	var sMenubar = 'no';
	var sScrollbars = 'no';
	var sResizable = 'no';
	var iTop = 50	//(screen.width/2) - 262.5;
	var iLeft = 50	//(screen.height/2) - 137.5;		
	
	/*vu commented below because does not work for FireFox
	if (RequiredFieldValidatorEvaluateIsValid(EmailFieldValidator)==true && RegularExpressionValidatorEvaluateIsValid(EmailValidator)==true)
		SpawnPop(sURL, sWindowName, sLocation, sMenubar, sScrollbars, sResizable, iTop, iLeft);
	else */
	if (ValidateEmail(document.forms[0].txtCheckEmail.value)==true)
	{
		SpawnPop(sURL, sWindowName, sLocation, sMenubar, sScrollbars, sResizable, iTop, iLeft);
		document.forms[0].txtCheckEmail.value="";
	}
	else
	{
		alert("A valid email address is required.");
		document.forms[0].txtCheckEmail.focus();
		return false;
	}
	
}
function ValidateEmail (emailStr) 
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
	{
  		return false
	}
	var user=matchArray[1]	
	if (user.match(userPat)==null) 
	{
		return false
	}	
	var atomPat=new RegExp(atom,"g")	
	return true;
}
/*
end popup functions
*/
function ReportPopup()
{	
	window.open("./assessments/report.aspx");
}
//Vu added for Cert Touch access
function ReloadPage()
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf("certaccess");			
	if (index1>-1) 
	{
		Delete_Cookie('certaccess', '/', '');
		reload();				
	}			
}
function reload()
{
	window.location.reload();
}
function Get_Cookie( name ) 
{	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function Delete_Cookie( name, path, domain ) 
{
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}