// JavaScript Document

securePages = "login.w,remit.w,order-status.w,statement.w,addr_frame.w,quote-detail.w,inv.w,remit-info.w,addr_update.w,order-detail.w,logout-fm.w";
  var vColor=new Array();
  var vSponsor = "000001";
  var basePath = "/96live";
function golink(vLink,vTarget,vStatic)
{
 goToPage("link",vLink,vTarget,vStatic);
}
function goReplace(vLink,vTarget,vStatic)
{
 goToPage("replace",vLink,vTarget,vStatic);
 }
 function goToPage(vAction,vLink,vTarget,vStatic)
 {
  if (!checkClickFlag("YES"))
   return;
  if (quoteUnapplied())
   return;
  var hostUrl  = "http://www.bodekandrhodes.com";
  var sHostUrl = "https://www.bodekandrhodes.com";
  var host     = "";
  var sPages   = securePages.split(",");
  var vParams=""; 
  var vStart=vLink.indexOf("?") + 1; 
  var vEnd=vLink.length; 
  if (vStart>0 && vEnd>vStart && vLink.indexOf("?") != -1)
  {
   vParams = vLink.substring(vLink.indexOf("?") + 1,vLink.length); 
   vLink = vLink.substring(0,vLink.indexOf("?")); 
  }
  if (securePages != "")
  {
   for (var i=0; i< sPages.length; i++)
   {
      if (vLink.indexOf(sPages[i]) > -1)
      {
         host = sHostUrl;
         break;
      }
   }
  }
  if (host == "")
   host = hostUrl;
  if(vParams.indexOf("=")!=-1)
   vParams = vParams + "&frames=no&target=" + vTarget; 
  else 
   vParams = vParams + "frames=no&target=" + vTarget; 
  vParams = vParams + "&sponsor=000001&nocache=45327";
  if (vAction == "link")
  {
   if (vStatic)
    document.location.href = host + "/" + vLink + "?" + vParams;
   else if(vTarget=="top")
    document.location.href = host + "/cgi-bin/barlive/" + vLink + "?" + vParams; 
   else
    document.location.href = host + "/cgi-bin/barlive/site.w?location=" + vLink + "&" + vParams;
  }
  else
  {
   if (vStatic)
    document.location.replace(host + "/" + vLink + "?" + vParams);
   if(vTarget=="top")
    document.location.replace(host + "/cgi-bin/barlive/" + vLink + "?" + vParams); 
   else
    document.location.replace(host + "/cgi-bin/barlive/site.w?location=" + vLink + "&" + vParams);
  }
 }
 function addToCart(vProduct,vColor,vSize) 
{
  var vColorObj=eval("document.siteForm.color" + vProduct);
  if (vColorObj.selectedIndex==0)
 {
   alert("Please enter a color to continue.");
   return;
  }
  if (document.siteForm.qty!=null)
      var vQty = document.siteForm.qty.value;
  else var vQty = 1;
 }
 function setPrice(vName)
{
  if(vName!=="none")
 {
   var vObj=eval("document.siteForm.sc" + vName); 
   document.siteForm.price.value=vObj.value;
  }
 }
 function externalAdd(vLink,vProduct,vCookie) 
{
  if (document.siteForm.color!=null)
 {
   var colorObj=eval("document.siteForm.color" + vProduct);
   var vColorParam="&color=" + colorObj.value;
  }
 golink('olc/quickorder.w?style=' + vProduct + vColorParam,'main');
 }
 function selectColor(vColor) 
{
alert("in selectColor");
   var colorObj=eval("document.siteForm.color");
  if(colorObj!=null)
 {
   for (var i=0; i<colorObj.length; i++)
  {
    if(colorObj[i].value==vColor) 
    {
      colorObj.selectedIndex=i;
      if(document.siteForm.size!=null)
         validateSizes("",true);
     }
   }
  }
 }
function validateSearchString()
{
   var flgStringValid = true;
   var strSearchString = new String(document.forms[0].textsearch.value);
   if(strSearchString=="")
   {
      alert("Please enter a word or phrase to search for.");
      document.forms[0].textsearch.focus();
      return false;
   }
   var index;
   var strErrorMsg, strErrorMsgInvalidChars;
   var strArrayOfInvalidChars = 
    new Array("\?", "\/","\\","\@","\(","\)","$","%","!");
   index = 0;
   while (flgStringValid == true && index < strArrayOfInvalidChars.length)
   {
      if (strSearchString.indexOf(strArrayOfInvalidChars[index]) != -1)
      {
         strErrorMsg = "Were sorry, your search phrase cannot contain the following characters: ";
         strErrorMsgInvalidChars = "";
         for (index = 0; index < strArrayOfInvalidChars.length; index++)
         {
            strErrorMsgInvalidChars = strErrorMsgInvalidChars + "'" + strArrayOfInvalidChars[index] + "'";
            if (index + 1 < strArrayOfInvalidChars.length)
            {
               strErrorMsgInvalidChars = strErrorMsgInvalidChars + ", ";
            }
         }
         alert(strErrorMsg + strErrorMsgInvalidChars);
         flgStringValid = false;
      }
      index++;
   }
   return flgStringValid;
}
 
 function goSearch()
{
  if(validateSearchString()) 
 {
   goReplace('https://www.bodekandrhodes.com/cgi-bin/barlive/olc/word-search.w?search=yes&textsearch=' + document.forms[0].textsearch.value,'main'); 
  }
  return false;
 } 
function quoteUnapplied()
{ 
 var tbody = document.getElementById("color-grid-tbody");
 if (!tbody)
  return false;
 var inputs = document.getElementsByTagName("input");
 var inputsLength = inputs.length;
 var quoteLength = quoteQtyArray.length;
 for (var i=0; i<inputsLength;i++)
 {
  var inputObj = inputs[i];
  if (inputObj.type=="text" && inputObj.id.indexOf("in_") == 0)
  {
   if (quoteLength == 0)
   {
    var apply = confirm("Do you want to save this Style information to your \"Quote/Info Request\"?");
    if (apply)
    {
     submitQuoteForm();
     return true;
    }
    else
     return false;
   }
   else
   for(var j=0; j<quoteLength;j++)
   {
    if (inputObj.id == quoteQtyArray[j].id)
    {
     if (inputObj.value != quoteQtyArray[j].value && inputObj.value != "")
     {
      var apply = confirm("Do you want to save this Style information to your \"Quote/Info Request\"?");
      if (apply)
      {
       submitQuoteForm();
       return true;
      }
      else
       return false;
     }
    }
   } // qty ref array loop
  }
 } // inputs loop
} // quoteUnapplied() 


 /*function goSearch()
{
  if(validateSearchString()) 
 {
   goReplace('http://www.bodekandrhodes.com/cgi-bin/barlive/olc/word-search.w?search=yes&textsearch=' + document.forms[0].textsearch.value,'main'); 
  }
  return false;
 } */

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function linker(thePage)
{
   var vService = "";
       vService = "document.location.href = '/cgi-bin/barlive" + thePage + "';";
   eval(vService);
}

function acmess()
{ 
   var acwin = window.open("","acwin","toolbar=no,location=no,directories=no,scrollbars=no,status=no,menubar=no,height=145,width=595");
   if (acwin != null)
   {
     acwin.location = "/barlive/accountstatusmessage.html";
     acwin.focus();
   } 
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

 function isAnumber(vfield)
{
   var vform   = document.form1;
   var vexpire = new Date()
   var v365    = vexpire.getTime() + (365 * 24 * 60 * 60 * 1000)
   vexpire.setTime(v365)

   if (isNaN(vfield.value))
   {
      alert("Quantities must be in numeric format, please try again.");
      vfield.focus();
   }
   else
   {
      deleteCookie(vfield.name,"/",null);
      setCookie(vfield.name,vfield.value,vexpire,"/",null,null);
   }
}

function populateFields()
{
   var vform = document.form1;

   for (var i = 0; i < vform.elements.length; i++)
   {
      if (vform.elements[i].type == "text" || vform.elements[i].type.indexOf("select") > -1)
      {
         vform.elements[i].value = getCookie(vform.elements[i].name) 
          
        if (isNaN(vform.elements[i].value))
          vform.elements[i].value='';
      }
   }
}

function checkOK()
{
   var vform = document.form1;
   if (vform.Citem75499010.value!="" && !vform.subguide.checked)
   {
      alert("Have you read the submission guidelines and understand it?\nIf so check box to indicate that you have read and understand the submission guidelines.");
      vform.subguide.focus();
      return false;
   }
   return true;
}

//<!-- *****v AJAX for expiry date v***** -->

 function init()
	{
		makeRequest("/cgi-bin/barlive/xml/marketing-ajax.w?sponsor=000001&action=expiry&webprofile=" + getCookie("bodek96000001"),"GET","text/xml");
	}

	var http_request = false;
	var xmlResponse;
	var docDomain = false;
	var isMac = false;
	var isSafari = false;

	if (navigator.platform.toLowerCase().indexOf("mac") != -1)
		isMac = true;
	if (navigator.appVersion.search(/Safari/) != -1)
		isSafari = true;

	function makeRequest(url,vMethod,vMimeType) {
		if (url == "" || vMethod == "") return;
		http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType(vMimeType);
			}
		} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
}
if (!http_request) {
	alert("Giving up :( Cannot create an XMLHTTP instance");
	return false;
}
http_request.onreadystatechange = getRequest;
http_request.open(vMethod, url, true);
http_request.send(null);
}

function getRequest() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			if (docDomain && !document.all && isSafari == false)
			var xmldoc = (new DOMParser()).parseFromString(http_request.responseText, "text/xml");
			else
				var xmldoc = http_request.responseXML;
			processXML(xmldoc);
		}
		else
			return false;
	}
}

function processXML(xmlDoc) {
	xmlResponse = xmlDoc.documentElement;
	var topNode = xmlDoc.getElementsByTagName("ajaxml").item(0);
	var errorStatus = topNode.getAttribute("status");
	var errorMessage = "";
	if (errorStatus == "error")
		errorMessage = xmlResponse.getElementsByTagName("error")[0].firstChild.data;
	parseXML(errorStatus,errorMessage);
}


function getNodeValue(tagName) {
	if (xmlResponse.getElementsByTagName(tagName)[0] && xmlResponse.getElementsByTagName(tagName)[0].firstChild)
		return xmlResponse.getElementsByTagName(tagName)[0].firstChild.data;
}

/* Returns an HTMLCollection object of all the elements that matches the
			passed tagName. */

function getNodeValues(tagName) {
	if (xmlResponse.getElementsByTagName(tagName))
		return xmlResponse.getElementsByTagName(tagName);
}

function parseXML(errorStatus,errorMessage)
{
	var programName = getNodeValue("requestType");

	switch(programName)
	{
		case "expiry":
			processExpiry(errorStatus,errorMessage);
			break;
	}
}

function processExpiry(errorStatus,errorMessage)
{
	if (errorStatus == "error")
	{
	}
	else
	{
		var tmp = "";

		tmp = getNodeValue("expiry");

		if (tmp)
			document.getElementById("expiry").innerHTML = tmp;
	}
}

//<!-- *****^ AJAX ^***** -->