function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function checkMultiWord() {
	if(CheckPlate(str) == 'invalid') {
		var str = document.getElementById("criteria").value;
		if(str.indexOf(' ') > -1) {
			alert('You seem to have entered more than one word. We suggest that you search on each word individually, as one word searches often produce the best matches.');
		}
		return true;
	} else
		return false;
}

function formCheck(){   
    var str = document.getElementById("criteria").value
    if (str.indexOf("=") >= 0)  {
		alert("Please only enter letters or numbers in the search box");
		document.getElementById("criteria").focus();
    }
	else if (str == "") {
		alert("Please enter something in the search box");
		document.getElementById("criteria").focus();
	}
	else {
		document.getElementById("frmGeneralSearch").submit();
	}
}

function disableEnterKey() 
{
	if (window.event && window.event.keyCode == 13) {
		formCheck();
		return false;
	}
}

function OpenCertDetails(){
	thewindow =window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=GBREGI2-1', 'anew',config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


	function setFavCookie(cookieName, cookieValue, cookiePath) {
		var nowDate = new Date();
		nowDate.setMonth(nowDate.getMonth() + 9);
		var cookieExpires = nowDate.toGMTString();
		var previousCookie = getCookieValue(cookieName);
		if (previousCookie == null){
			var cookieArray = new Array(5);
			cookieArray[0] = cookieValue;
			cookieArray[1] = "empty";
			cookieArray[2] = "empty";
			cookieArray[3] = "empty";
			cookieArray[4] = "empty";
		} else {
			var cookieArray = previousCookie.split(", ");
			if ((cookieValue != cookieArray[0]) && (cookieValue != cookieArray[1]) && (cookieValue != cookieArray[2]) && (cookieValue != cookieArray[3]) && (cookieValue != cookieArray[4])){
				cookieArray.pop();
				cookieArray.unshift(cookieValue);
			}
		}
// Write Cookie		
		document.cookie = cookieName + "=" + cookieArray.join(", ") + ";expires=" + cookieExpires + ";path=" + cookiePath + ";";
	}
	function setCookie(cookieName, cookieValue, cookiePath) {
		var nowDate = new Date();
		nowDate.setMonth(nowDate.getMonth() + 9);
		var cookieExpires = nowDate.toGMTString();
		var previousCookie = getCookieValue(cookieName);
// If no cookie exists, create an array with 6 values
// Else if cookie exists, split it up into its 6 components
		if (previousCookie == null){
			var cookieArray = new Array(6);
			cookieArray[0] = cookieValue;
			cookieArray[1] = cookieValue;
			cookieArray[2] = cookieValue;
			cookieArray[3] = cookieValue;
			cookieArray[4] = cookieValue;
			cookieArray[5] = cookieValue;			
		} else {
			var cookieArray = previousCookie.split(", ");
// Check to see if new search input matches any previous inputs		
			if ((cookieValue != cookieArray[0]) && (cookieValue != cookieArray[1]) && (cookieValue != cookieArray[2]) && (cookieValue != cookieArray[3]) && (cookieValue != cookieArray[4]) && (cookieValue != cookieArray[5])){
				cookieArray.pop();
				cookieArray.unshift(cookieValue);
			}
		}
// Write Cookie		
		document.cookie = cookieName + "=" + cookieArray.join(", ") + ";expires=" + cookieExpires + ";path=" + cookiePath + ";";
	}
	
// function to retrieve just the cookies value, retuns 'null' if nothing found	
	function getCookieValue(cookieName){
		var cookieValue = document.cookie;
		var cookieStartsAt = cookieValue.indexOf(" " + cookieName + " ");
		if (cookieStartsAt == -1) {
			cookieStartsAt = cookieValue.indexOf(cookieName + "=");
		}
		if (cookieStartsAt == -1) {
			cookieValue = null;
		}
		else {
			cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
			var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
			if (cookieEndsAt == -1) {
				cookieEndsAt = cookieValue.length;
			}
			cookieValue = unescape(cookieValue.substring(cookieStartsAt,cookieEndsAt));
		}
		return cookieValue;
	}

function clearCookie(cookieName){
	var nowDate = new Date();
	nowDate.setMonth(nowDate.getMonth() - 9);
	var cookieExpires = nowDate.toGMTString();
	document.cookie = cookieName + "=;expires=" + cookieExpires + ";";
	history.go(0);
}
