// Determine browser version

var isNav;
    //CREDIT TO: http://www.creaweb.fr/DHTML/faq/browser.html
   
    // convert all characters to lowercase to simplify testing 
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION *** 
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5. 
    var is_major = parseInt(navigator.appVersion); 
    var is_minor = parseFloat(navigator.appVersion);
    var is_ie   = (agt.indexOf("msie") != -1); 
    var is_ie3  = (is_ie && (is_major < 4)); 
    var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
    var is_ie4up  = (is_ie  && (is_major >= 4)); 
    var isIE = is_ie4up
    var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
    var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

//END BROWSER DETECTION    
// Returns the cookie value with the specified name/subname.
// strName - Primary cookie grouping name.
// strSubName - Secondary cookie name.
//	If strSubName is blank, only strName's cookie value is returned.
function GetCookie(strName, strSubName)
{
	// Find strName in cookie
	var intStart = document.cookie.indexOf(strName + "=");
	if (intStart == -1)
		return "";
	intStart += strName.length + 1;
	var intEnd = document.cookie.indexOf(";", intStart);
	if (intEnd == -1)
		intEnd = document.cookie.length;
	var strCookie = document.cookie.substring(intStart, intEnd);

	if (strSubName == "")
		return unescape(strCookie);

	// Find strSubName within the strName cookie substring
	var arrayCookie = strCookie.split("&");
	for (var nItem = 0; nItem < arrayCookie.length; nItem++)
	{
		if (arrayCookie[nItem].indexOf(strSubName + "=") == 0)
			return unescape(arrayCookie[nItem].substring(strSubName.length + 1));
	}
	return "";
}

// Sets the cookie's name/subname to the specified value.
// strName - Primary cookie grouping name.
// strSubName - Secondary cookie name.
//	If strSubName is blank, only strName's cookie value is set.
// strValue - Value to store in the cookie.
function SetCookie(strName, strSubName, strValue)
{
	var strCookie;

	if (strSubName == "")
		strCookie = strName + "=" + escape(strValue);
	else
	{
		strCookie = strName + "=" + strSubName + "=" + escape(strValue);

		// Append the remaining name/value pairs, excluding strSubName
		var arrayCookie = GetCookie(strName, "").split("&");
		for (var nItem = 0; nItem < arrayCookie.length; nItem++)
		{
			if (arrayCookie[nItem].indexOf(strSubName + "=") != 0)
				strCookie += "&" + arrayCookie[nItem];
		}
	}
	var objDate = new Date(2017, 11, 15);
	strCookie += "; path=/; expires=" + objDate.toString();
	document.cookie = strCookie;
}
function winFeatFormat(s,t){
	if (s==""){
		return t
	}
	else
		return (s + "," + t)
}
function checkBlankValue(obj,descrpt){
 var ch;
 var v = obj.value;
 var prevValue;
  if (obj.value == "")
  {
    alert(descrpt);
    obj.focus();
    return (false);
  }
  //check leading blanks
  prevValue = v.charAt(0);
  for (var i = 0;  i < v.length;  i++)
  {
		ch = v.charAt(i);
		if (prevValue != ch){
				return true; //value is none blank;
		}
		if (i == (v.length-1)){
			if (ch == " "){
			  alert(descrpt);
			  obj.value = ""
			  obj.focus();
			  return false;  
			} 
		}
  }
  return true;
}

var winObj = null
function OpenCWin(arProps){
	 var winfeatures = ""
	 var url = ""
	 var w = ""
	 var h = ""
	 var xCord =""
	 var yCord = "" 
	 var winName = ""
	 var tbar = 0
	 var mbar = 0 
	 var scrollbars = ""
	 var resizable = ""
	 //menubar
//escape(location.href);
	/*
	arProps[x]
	when x=
	0=url, 1 = window Name, 2 = width, 3 = height, 4=x cordinate, 5 = y cordinate,scroll,resize
	6 =toolbar = 1
	*/
	var len = arProps.length
		
	for (var x = 0; x<len;x++){
		switch (x){
		case 0: 
			url = arProps[x];
			break;
		case 1: 
			winName = arProps[x];
			break;
		case 2: 
			w = arProps[x];	
			break;
		case 3: 
			h = arProps[x];
			break;
		case 4: 
			xCord = arProps[x];
			break;
		case 5: 
			yCord= arProps[x];	
			break;	
		case 6:  //scrollbar
			
			winfeatures = winFeatFormat(winfeatures,"scrollbars")
			break;				
		case 7: //resizable
			winfeatures = winFeatFormat(winfeatures,"resizable")
			break;		
		case 8: 
			tbar = arProps[x];	
			break;	
		case 9: 
			mbar = arProps[x];	
			break;			
		}
		
	}

	 if ((w=="") || (h=="")){
		   winfeatures = "scrollbars,resizable,height=200,width=300"
	 }
	 else{
	//	winfeatures = "scrollbars,resizable"
		winfeatures = winfeatures + ",height=" + h + ",width=" + w 
	 }
	 if ((xCord != "") || (yCord != "")){
	   if (isIE)
		   winfeatures = winfeatures + ",left=" + xCord + ",top=" + yCord
		else
			winfeatures = winfeatures + ",screenX=" + xCord + ",screenY=" + yCord
	 }
	 else{
		if (isIE)
		   winfeatures = winfeatures + ",left=0,top=0"
		else
			winfeatures = winfeatures + ",screenX=0,screenY=0"
	 }
	 
	if (tbar == 1){
		winfeatures = winfeatures + ",toolbar=1"
	}
	
	if (mbar == 1){
		winfeatures = winfeatures + ",menubar=1"
	}
	
	     if (winObj == null || winObj.closed)
				winObj = window.open (url,winName,winfeatures)
		else{
			winObj.close()
			winObj = window.open (url,winName,winfeatures)
		}
	
	//winObj = window.open (url,winName,winfeatures)
	//winObj.window.focus()
	 
}
//this function send a URL to the caller
function takeMeThere(url){
	if (window.opener != null){
		window.opener.window.location.href = url
		window.opener.window.focus()
	}
	else{
		window.location.href = url
	}
	
}
function checkRadioButton(obj){   
  obj = eval(obj)

  for (var i = 0; i< obj.length; i++){
           if (obj[i].checked){
           return obj[i].value
         }  

    }
  return null;  
   
 
}

function openModal(arVar){
	var sEdge ="";
	var bHelp ="no";
	var bResize ="no";
	var bStatus ="no";
	
	var len = arVar.length
		
	for (var x = 0; x<len;x++){
		switch (x){
		case 0: 
			var sUrl = arVar[0];
			break;
		case 1: 
			var sName = arVar[1];
			break;
		case 2: 
			var iHeight = arVar[2];
			break;
		case 3: 
			var iWidth = arVar[3];
			break;	
		case 4: 
			var bCenter = arVar[4];
			break;	
		case 5: 
			var iTop = arVar[5];
			break;
		case 56: 
			var iLeft = arVar[6];
			break;		
		}
	}
	
	if ((iWidth=="") || (iHeight =="")){
		   iWidth = 200;
		   iHeight = 300;
	 }

	if (isIE){
		//sFeatures="dialogHeight: " + iHeight + "px; dialogWidth: " + iWidth + "px; dialogTop: " + iTop + "px; dialogLeft: " + iLeft + "px; edge: " + sEdge + "; center: " + bCenter + "; help: " + bHelp + "; resizable: " + bResize + "; status: " + bStatus + ";";
		sFeatures="dialogHeight: " + iHeight + "px; dialogWidth: " + iWidth + "px; " + " center: " + bCenter + "; help: " + bHelp + "; resizable: " + bResize + "; status: " + bStatus + ";";
		return window.showModalDialog(sUrl, "", sFeatures)
	}
	else{
		//0=url, 1 = window Name, 2 = width, 3 = height, 4=x cordinate, 5 = y cordinate
		OpenCWin(Array(sUrl,sName,iWidth,iHeight,iLeft,iTop))
	}	
}

function hidestatus(v){
	if (v == '')
		window.status= "ABXstore.com - Not Just a Regular Retailer";
	else
		window.status= v;
	return true
}
//------------Standards
var bln1
bln1 = true
function search(){
	if (checkBlankValue(window.document.frmMain.pt,"Please enter a search keyword(s).")){
		window.document.frmMain.action = "/search/results.asp"
	   window.document.frmMain.submit(); 
	 }  
	 else
		bln1 = false;
}

function setFormAction(obj){
	if (bln1){
		obj = eval(obj)
		window.document.frmMain.action = "/search/results.asp"
		bln1 = false
	}
}
function tabPress(url) {
	if(url == 1){
		self.document.location.href = "/service-detail.asp?type=k"
	}
	if(url == 2){
		self.document.location.href = "/service-detail.asp?type=f"
	}
	if(url == 3){
		self.document.location.href = "/service-detail.asp?type=w"
	}
	if(url == 4){
		self.document.location.href = "/service-detail.asp?type=m"
	}
}
function syncDone(){

}
