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 newImage(arg) 
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() 
{
	if (document.images && (preloadFlag == true)) 
	{
		for (var i=0; i<changeImages.arguments.length; i+=2) 
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() 
{
	if (document.images) 
	{
		menu_micro_over = newImage("/images/menu_micro-over.gif");
		menu_compt_over = newImage("/images/menu_compt-over.gif");
		menu_cisco_over = newImage("/images/menu_cisco-over.gif");
		menu_sun_over = newImage("/images/menu_sun-over.gif");
		menu_oracl_over = newImage("/images/menu_oracl-over.gif");
		menu_novel_over = newImage("/images/menu_novel-over.gif");
		menu_cissp_over = newImage("/images/menu_cissp-over.gif");
		menu_ciw_over = newImage("/images/menu_ciw-over.gif");
		preloadFlag = true;
	}
}

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.  wwinn
*/
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);
	if (window.screen.width==800 && window.screen.height==600)		
		m_rWindow.moveTo(72,0)
	else if (window.screen.width<1280 || window.screen.height<1024)
		m_rWindow.moveTo(30,0)	
}

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;
	sURL='http://' + document.domain + sURL
	self.focus();
	if (window.screen.width<1280)
		iTop=0
	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;
	sURL='http://' + document.domain + sURL
	SpawnPop(sURL, sWindowName, sLocation, sMenubar, sScrollbars, sResizable, iTop, iLeft);

}
/*
end popup functions
*/
function GetReaction(imgName, newFileName)
{
	document.images[imgName].src='/images/' + newFileName;
}

//Vu added functions EmailPopup() and ValidateEmail()		
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;		
	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(src) 
{	
     var sEmailDefinition = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(sEmailDefinition);
     return (regex.test(src))?true: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;
}
//Vu added codes below for Cert Touch access	
function ReloadPage()
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf("tcertaccess");			
	if (index1>-1) 
	{
		Delete_Cookie('tcertaccess', '/', '');
		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";
}
