

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 Search(defaultText, searchField) {
    //alert(searchField);
    var criteria;
    if (searchField == undefined) {
        return false;
    }
    criteria = searchField.val()
    if (criteria != defaultText && criteria.length > 0) {
        window.location = '/site-search.aspx?s=' + escape(criteria);
    }
}

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 SpawnCourseDescription(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);
    Spawn(sURL, 'CourseDescription', 'no', 'no', 'yes', 'yes', 20, 20, 1070, 760);				
}

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 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 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 (isValid(document.forms[0].txtCheckEmail.value))
	{
		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 isValid(email) {
    // = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; Fails!
    // = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,6})+$/; Fails!
    var emailPattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    // =/^([\w-\.] )@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-] \.) ))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/

    return emailPattern.test(email);
}

/*
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";
}
function ClearText(control, defaultText) {
    if (control.value == defaultText) {
        control.value = '';
    }
}

