// Author: Dhanabal Duraisamy (dhanaps@ocenture.com)

// $Id: /scripts/general.css.php,v 1.1 $

function autoTab(eCtrl,len)
{
  if(eCtrl.value.length >= len)  { 
    eCtrl.value = eCtrl.value.slice(0, len);
    eCtrl.form[(getIndex(eCtrl)+1) % eCtrl.form.length].focus();
  }
  
  function getIndex(eCtrl)
  {
     var index = -1, i = 0, found = false;
     while (i < eCtrl.form.length && index == -1)
      if (eCtrl.form[i] == eCtrl) { index = i; } else { i++; }
     return index;
  }
  return true;
}

// openPopWin
// winFeatures = scrollbars,toolbar,menubar,resizable
var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
  }
function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
  }
function getLocation(winWidth, winHeight, winLeft, winTop){
  return ""
  }
//-->
// for Netscape 4+ and IE 4+
<!--
function getLocation(winWidth, winHeight, winLeft, winTop)
{
  var winLocation = ""
  if (winLeft < 0)
    winLeft = screen.width - winWidth + winLeft
  if (winTop < 0)
    winTop = screen.height - winHeight + winTop
  if (winTop == "cen")
    winTop = (screen.height - winHeight)/2 - 20
  if (winLeft == "cen")
    winLeft = (screen.width - winWidth)/2
  if (winLeft>0 & winTop>0)
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft	
                + ",screenY=" + winTop + ",top=" + winTop
  else
    winLocation = ""
  return winLocation
  }
//-->

function openWin(winURL) 
{
	window.open(winURL);
}

function addToCart(formName, prodId)
{
  formObj = eval("document." + formName);
  formObj.fProdId.value = prodId;
  formObj.submit();
}


function loadPaymentInfo(frmObj)
{
	var i = frmObj.fProducts.selectedIndex ;

	if ( parseInt(i) >= 0) {	
	  var srtingArr = billArr[i].split("~");
	  frmObj.fCardType.value=srtingArr[0];
	  frmObj.fCardNumber.value=srtingArr[1];
	  frmObj.fExpMonth.value=srtingArr[2];
	  frmObj.fExpYear.value=srtingArr[3];
	  frmObj.fCardHolderName.value=srtingArr[4];
	  frmObj.fCCV.value=srtingArr[5];
	  frmObj.fOrderId.value=srtingArr[6];
	  frmObj.fProcType.value=srtingArr[7];
	  frmObj.fProdTitle.value=srtingArr[8];
	}
}


// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var DH = 0;var an = 0;
var al = 0;var ai = 0;

if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} function fd(oi, wS) {if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); if (al) return wS ? document.all[oi].style: document.all[oi]; if (an) return document.layers[oi];}
function pw() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}
function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}
function popUp(evt,oi) {if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else {tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!an) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";}}} 

//IE has a problem with wanted select form tags to always be the topmost z-index or layer

function hideSelectBoxes(myDoc) {
 for(var i = 0; i < myDoc.forms.length; i++) {
   for(var e = 0; e < myDoc.forms[i].length; e++){
	 if(myDoc.forms[i].elements[e].tagName == "SELECT") {
    	myDoc.forms[i].elements[e].style.visibility="hidden";
	 }
   }
  }
}

var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);

if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
	hideSelectBoxes(document);
}

function checkCartQuantity(formObj)
{
	if (formObj.fQuantity.value == '') {
	  alert("Quantity cannot be empty.");
	  return false;
	} else if (isNaN(formObj.fQuantity.value)) {
	  alert("Please enter numeric values only in Quantity field.");
	  return false;
	} else if (formObj.fQuantity.value <= 0) {
	  alert("Quantity cannot be less than 1.");
	  return false;
	} else {
	  return true;
	}
}

