// JavaScript Document
//**************************************************************************************
//* Change History
//* DATE        AUTHOR              COMMENTS
//* ---------- ------------------- -------------------------------------------
//* 12Aug2009   MPACLAON            Mantis 453 - Ability for Multiple Auction
//***************************************************************************************/

function openQuickLookLauncherTVHPage()
{
	document.getElementById("quickLookLauncherTVH").style.visibility="visible"; 
}

function closeQuickLookLauncherTVHPage()
{
	document.getElementById("quickLookLauncherTVH").style.visibility="hidden"; 
	document.getElementById("submitLookLauncherTVH").style.visibility="hidden"; 
}
function launchQuickLookTVHPage()
{
	document.getElementById("submitLookLauncherTVH").style.left=document.getElementById("quickLookLauncherTVH").style.left;
	document.getElementById("submitLookLauncherTVH").style.top=document.getElementById("quickLookLauncherTVH").style.top;
	document.getElementById("submitLookLauncherTVH").style.visibility="visible"; 
	document.getElementById("quickLookLauncherTVH").style.visibility="hidden";   
}
function removeQuickLookTVHPage()
{
	document.getElementById("submitLookLauncherTVH").style.visibility="hidden";  
}
function openQuickLookLauncher(strProductId)
{
	openLauncher("submitLookLauncher"+strProductId,"quickLookLauncher"+strProductId);
}
function closeQuickLookLauncher(strProductId)
{
	closeLauncher("submitLookLauncher"+strProductId,"quickLookLauncher"+strProductId);
}
function launchQuickLook(strProductId)
{
	launchQuick("submitLookLauncher"+strProductId,"quickLookLauncher"+strProductId);   
}
function removeQuickLook(strProductId)
{
	removeQuick("submitLookLauncher"+strProductId,"quickLookLauncher"+strProductId); 
}
function openQuickWebLauncher(strProductId)
{
	document.getElementById("quickWebLauncher"+strProductId).style.visibility="visible"; 
	document.getElementById("submitWebLauncher"+strProductId).style.visibility="hidden";
}
function closeQuickWebLauncher(strProductId)
{
	document.getElementById("quickWebLauncher"+strProductId).style.visibility="hidden"; 
	document.getElementById("submitWebLauncher"+strProductId).style.visibility="hidden"; 
}

function launchWebLook(strProductId)
{
	launchQuick("submitWebLauncher"+strProductId,"quickWebLauncher"+strProductId); 
}
function removeWebLook(strProductId)
{
	document.getElementById("submitWebLauncher"+strProductId).style.visibility="hidden";  
}

function openQuickPickLauncher(strProductId)
{
	openLauncher("submitPickLauncher"+strProductId,"quickPickLauncher"+strProductId);	
}
function closeQuickPickLauncher(strProductId)
{
	closeLauncher("submitPickLauncher"+strProductId,"quickPickLauncher"+strProductId);
}
function launchQuickPick(strProductId)
{
	launchQuick("submitPickLauncher"+strProductId,"quickPickLauncher"+strProductId);  
}
function removeQuickPick(strProductId)
{
	removeQuick("submitPickLauncher"+ strProductId);  
}
function openLauncher(submitId,quickId)
{
	document.getElementById(quickId).style.visibility="visible"; 
	document.getElementById(submitId).style.visibility="hidden";
}
function closeLauncher(submitId,quickId)
{
	document.getElementById(quickId).style.visibility="hidden"; 
	document.getElementById(submitId).style.visibility="hidden"; 
}
function launchQuick(submitId,quickId)
{
	
	
	document.getElementById(submitId).style.left=document.getElementById(quickId).style.left;
	document.getElementById(submitId).style.top=document.getElementById(quickId).style.top;
	document.getElementById(submitId).style.visibility="visible"; 
	document.getElementById(quickId).style.visibility="hidden";   
}
function removeQuick(objId) {
	
	document.getElementById(objId).style.visibility="hidden";	
}

function openQuickLookLauncherCol(strProductId)
{

	document.getElementById("quickLookLauncherCol"+strProductId).style.visibility="visible"; 
	document.getElementById("submitLookLauncherCol"+strProductId).style.visibility="hidden";
}
function closeQuickLookLauncherCol(strProductId)
{

	document.getElementById("quickLookLauncherCol"+strProductId).style.visibility="hidden"; 
	document.getElementById("submitLookLauncherCol"+strProductId).style.visibility="hidden"; 
}

function launchQuickLookCol(strProductId)
{
document.getElementById("submitLookLauncherCol"+strProductId).style.left=document.getElementById("quickLookLauncherCol"+strProductId).style.left;
document.getElementById("submitLookLauncherCol"+strProductId).style.top=document.getElementById("quickLookLauncherCol"+strProductId).style.top;
document.getElementById("submitLookLauncherCol"+strProductId).style.visibility="visible"; 
document.getElementById("quickLookLauncherCol"+strProductId).style.visibility="hidden";   
}

function removeQuickLookCol(strProductId)
{
document.getElementById("submitLookLauncherCol"+strProductId).style.visibility="hidden";  
}

function fnShow(obj) {
                 if(document.getElementById){
                         document.getElementById(obj).style.display = "block";
                         if (document.getElementById("search") != null)
                        	 document.getElementById("search").style.display = "none";
                 }
                 
}

function fnHide(obj) {
document.getElementById("search").style.display = "block";
                 if(document.getElementById){
                        if(obj=="loginForm")
                        {
                                if(window.whoseFocus!="email" && window.whoseFocus!="password")
                                {
                                        document.getElementById(obj).style.display = "none";
                                }
                                else if(document.getElementById("email").value=="" && document.getElementById("password").value=="")
                                {
                                        document.getElementById(obj).style.display = "none";
                                }
                        }
                        else
                        {
                                document.getElementById(obj).style.display = "none";
                        }
                 }
                 
}

function fnShowHide(obj, obj2){
         if(document.getElementById){
                 var el = document.getElementById(obj);
                 var el2 = document.getElementById(obj2);
        
        
                 if(el.style.display == "none"){
                         el.style.display = "block";
                         el2.style.display = "none";
                
                
                 }else{
                        el.style.display = "none";
                 }
        
         }
}

function fnChangeBasket(offon) {
        
        if(offon == "off") {
        
        document.getElementById("basket").className = "basketselected";
        } else {
                document.getElementById("basket").className = "xxx";
        }
}

function MM_openBrWindow(theURL,winName,width,height) { //v2.0
        var screen_left = (screen.availWidth - width) / 2;
    var screen_top = (screen.availHeight - height) / 2;
  window.open(theURL,winName,'width='+width+',height='+height+',left='+screen_left+',top='+screen_top);
}

function buyNowProd(proId, ouCode, price) {
        document.buyNow.productId.value = proId;
        document.buyNow.ouCode.value = ouCode;
        document.buyNow.price.value = price;
        document.buyNow.submit();
}

function buyNowWebGameProd(proId, ouCode, price) {
        document.buyNowWebGame.productId.value = proId;
        document.buyNowWebGame.ouCode.value = ouCode;
        document.buyNowWebGame.price.value = price;
        document.buyNowWebGame.submit();
}
function buyNowSpecials(proId, ouCode, price) {
        document.buyNowSpecials.productId.value = proId;
        document.buyNowSpecials.ouCode.value = ouCode;
        document.buyNowSpecials.price.value = price;
        document.buyNowSpecials.submit();
}
//start mantis 453
function viewImage(imgId)
{
	
	
    var obj = document.getElementById("prodImgContent");
    
    obj.innerHTML = "<img height='180' width='180' src='http://www.gemstv.com/product-images/Products/Huge/" +imgId + ".jpg' />";
}

var reqMultiProduct;
function preBuyNowTVGame(primaryProdId, ouCode, purchaseAmount, purchasePrice, channelId, gameId, size)
{
          var prodIds = "";
          var  ctr = 0;
          for (i=0;i<size;i++)
                {
                        if (document.getElementsByName("buyThisItem" + i).item(0).checked == true)
                        {
                                //alert(document.getElementsByName("buyThisItem" + i).item(0).checked);
                                prodIds = prodIds + document.getElementsByName("buyThisItem" + i).item(0).value + ",";
                                ctr = ctr + 1;
                        }
                }
        prodIds = prodIds.substring(0, prodIds.length - 1);
        //alert("preBuyNowTVGame() product_ids = " + prodIds);
        if (ctr == 0)
        {
                alert("Please select at least one item to add to your cart.");
                return false;
        }
        else
        {
                //validate shopping cart restrictions against number of products to buy
                var isRestricted = "false";
                var url = "multipleProductAuction.htm?validateCart=true&addlItems="+ctr+"&page=TV&productId="+prodIds+"&ouCode="+ouCode+
                          "&purchaseAmount=" + purchaseAmount + "&dummy="+Math.floor(Math.random()*1000000);
                 try{
                        if (window.XMLHttpRequest){
                          reqMultiProduct = new XMLHttpRequest();
                        }else if (window.ActiveXObject){
                          reqMultiProduct = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                    reqMultiProduct.open("POST", url, true);
                    reqMultiProduct.onreadystatechange=function()
                {
                        if(reqMultiProduct.readyState==4)
                          {
                                if (reqMultiProduct.status == 200)
                                          {
                                                   try 
                                                   {
                                                           isRestricted = reqMultiProduct.responseText;
                                                           var message_array = isRestricted.split(";");
                                                           var restrict = {};
                                                           
                                                           var msg_num=0;
                                                           while (message_array.length -1 > msg_num)
                                                             {
                                                                        var temp_array = message_array[msg_num].split("=");
                                                                        restrict[temp_array[0]] = temp_array[1]; 
                                                                        msg_num = msg_num + 1;
                                                                 }

                                                           if (restrict.cartRestrict == "true")
                                                           {
                                                                   alert(restrict.cartRestrictMessage);
                                                                   return false;
                                                           }
                                                           else if (restrict.prodRestrict == "true")
                                                           {
                                                                   alert(restrict.prodRestrictMessage);
                                                                   return false;
                                                           }
                                                           else
                                                           {
                                                                 buyNowTVGame(prodIds, ouCode, purchaseAmount, purchasePrice, channelId, gameId);
                                                           }
                                                   }
                                                   catch (exception)
                                                   {
                                                   }
                                        }
                          }
                }
                    reqMultiProduct.send(null);
                 }
                 catch(exception)
                 {
                 }
                
        }
}
// END mantis 453 

function buyNowTVGame(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId, page) {
        document.buyNowTVGame.productId.value = proId;
        document.buyNowTVGame.ouCode.value = ouCode;
        document.buyNowTVGame.purchaseAmount.value = purchaseAmount;
        document.buyNowTVGame.purchasePrice.value = purchasePrice;
        document.buyNowTVGame.channelId.value = channelId;
        document.buyNowTVGame.gameId.value = gameId;
        
        if (page != null || page != 'undefined')
        	document.buyNowTVGame.curPage.value = page;
        else
        	document.buyNowTVGame.curPage.value = 'webtvgame';

        document.buyNowTVGame.submit();
}

// start mantis 453
function buyNowTVGameProduct() {
        var proId = document.buyNowTVGame.productId.value = window.parent.document.tvgameform.productId.value;
        var ouCode = window.parent.document.tvgameform.ouCode.value;
        var purchaseAmount = window.parent.document.tvgameform.purchaseAmount.value;
        var purchasePrice = window.parent.document.tvgameform.purchasePrice.value;
        var channelId = window.parent.document.tvgameform.channelId.value;
        var gameId = window.parent.document.tvgameform.gameId.value;
        buyNowTVGameProd(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId, 'webtvgame');
}
// end mantis 453

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 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 EnterKey(e)
{
  var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
  if (keyCode == 13)
    {
   e.cancelBubble = true;
   e.returnValue = false;
   document.getElementById("btnLogin").click();
    }
}

function EnterKeyLogin(e)
{
  var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
  if (keyCode == 13)
    {
   e.cancelBubble = true;
   e.returnValue = false;
   document.getElementById("btnLoginPage").click();
    }
}

function login() {
        if (document.getElementById("email").value.length > 0 &&
                document.getElementById("password").value.length > 0)
        {
                        document.login.mode.value = "login";
                document.login.submit();
        } else {
                // open the main login page
                document.login.submit();
        }
}

function loginForm() {
        if (document.getElementById("email").value.length > 0 &&
                document.getElementById("password").value.length > 0)
        {
                        document.login.mode.value = "login";
        } 
}

/* Code For basket Layer */
function randomStr(length)
{
  chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  pass = "";
  for(x=0;x<length;x++)
  {
    i = Math.floor(Math.random() * 62);
    pass += chars.charAt(i);
  }
  return pass;
}

var reqBasket;
        
function getShopDet(fullPath)
{
                        var num1=Math.floor(Math.random()*101);
                        var strCall = randomStr(num1);
                        
                        var url = fullPath+"basketInfoGems.htm?call="+strCall;
                        
                        if (window.XMLHttpRequest){
                        reqBasket = new XMLHttpRequest();
                        }else if (window.ActiveXObject){
                                reqBasket = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        reqBasket.onreadystatechange = callbackShopDetails;
                        reqBasket.open("GET", url, true);
                        reqBasket.send(null);
                }
                
                function callbackShopDetails()
                {
                        if (reqBasket.readyState == 4){
                                if (reqBasket.status == 200){
                                        var l = reqBasket.responseText;
                                        var p = l.split(/\^\#\#\^/);
                                        var index = -1;
                                        
                                        for (i=1;i<=p.length;i++) {
                                                if (i==1) {
                                                        if ((p[i+index] != 'no'))
                                                        {
                                                                obj = document.getElementById("navBarTop");
                                                                obj.innerHTML = p[i+index];
                                                        }
                                                }
                                                
                                                if(i==2){
                                                        if ((p[i+index] != 'no'))
                                                        {
                                                                obj = document.getElementById("basketList");
                                                                obj.innerHTML = p[i+index];
                                                        }
                                                }
                                                
                                                if(i==3){
                                                        if ((p[i+index] != 'no'))
                                                        {
                                                                obj = document.getElementById("basketTop");
                                                                obj.innerHTML = p[i+index];
                                                        }
                                                }
                                        }
                                }
                        }
}               

/* Code For basket Layer */
//Added by Tejswita

//Anu - July 30 _ Mantis issue,Shipping address should be validated
function validateShippingAddress() {

                 //Fecth the address
                 var addrline1 = trim(document.shippinggems.saddr1.value);
                 var addrline2 = trim(document.shippinggems.saddr2.value);
                 var city = trim(document.shippinggems.scity.value);
                 var state = trim(document.shippinggems.sstate.value);
                 var zipcode = trim(document.shippinggems.szipCode.value);
                 
                 document.getElementById("ajaxModeId");
                 
                 $("#ajaxModeId").val("");
                 //alert("AjaxModeId 00 : " + $("#ajaxModeId").val());
                 document.shippinggems.hidAddrValid.value="N";
                 //Check valid data
                 if(addrline1.length >0 && city.length > 0 && state.length > 0 && zipcode.length == 5 && isNumber(zipcode)){
                 //function which will establish the AJAX connection object,
                 createXMLHttpRequest();
                 xmlHttp.open("GET", "validateAddress.htm?addrline1=" + addrline1 + "&addrline2=" + addrline2 + "&city=" + city + "&state=" + state + "&zipcode=" + zipcode , true);
                 xmlHttp.onreadystatechange = handleShippingAddress;
                 xmlHttp.send(null);
                 
                 }
                 else{
                        errMsg.innerHTML = "Please enter valid shipping address details";
                        alert("Please enter valid shipping address details");
                        document.shippinggems.saddr1.focus();
                 }
}

/*  script to process UPS Response XML*/
function handleShippingAddress(){
        
	    $("#ajaxModeId").val("process");
        if (xmlHttp.readyState == 4) {
                
                if (xmlHttp.status == 200) {
                        
                	//alert("AjaxModeId : " + $("#ajaxModeId").val());
                	
                	//Response UPS XML received
                        var xmlres = xmlHttp.responseText;
                        //if no response just return control as validation is done
                        if(xmlres==null||xmlres.length<=0)      
                                         {
                                alert("System Error in validation, please continue to place your order");
                                document.shippinggems.hidAddrValid.value = "Y"; 
                                return false;
                         }
                        var xmldoc = xmlHttp.responseXML;
                        //Check the reponse tag
                        var responseNode = xmldoc.getElementsByTagName("Response")[0];   
                        
                        var waitDiv = window.document.createElement("div");
 
                        //Fetch response status code 
                        
                         var resStatusNode = responseNode.getElementsByTagName("ResponseStatusCode")[0];
                         var resStatCode =resStatusNode.childNodes[0].nodeValue;
                        //Fetch response status description                      
                         var resStatusDescNode = responseNode.getElementsByTagName("ResponseStatusDescription")[0];
                         var resStatusDesc =resStatusDescNode.childNodes[0].nodeValue;
                        
                         if(resStatCode =='0')
                         {
                                errMsg.innerHTML = "System Error in validation:, please continue to place your order";
                                alert("System Error in validation:, please continue to place your order");
                                document.shippinggems.hidAddrValid.value = "Y"; 
                                return false;
                         }
                         else
                         {
                                //Fetch Indicator information
                                
                                //Default indicator ValidAddressIndicator
                                        var indicator='V';
                                // Check if indicator AmbiguousAddressIndicator
                                        if(xmldoc.getElementsByTagName("AmbiguousAddressIndicator").length>0)
                                   {
                                   indicator='A';
                                   
                                   }
                                // Check if indicator ValidAddressIndicator
                                        else  if (xmldoc.getElementsByTagName("ValidAddressIndicator").length>0)
                                         { 
                                                  indicator='V';
                                                  //alert("Address is valid");
                                                  
                                         }
                                // Check if indicator NoCandidatesIndicator      
                                         else 
                                         {
                                           indicator='N';
                                           errMsg.innerHTML = "Shipping address not found. Please check the address again. If this is a new address, please proceed with your order."
                                           alert("Shipping address not found. Please check the address again. If this is a new address, please proceed with your order.");
                                           /* Fix Santosh Kumar Sahoo*/ 
                                           document.shippinggems.hidAddrValid.value = "Y";
                                         }
             
         
                                  //if the resposne has Candidates adderesses or if address is valid
                                   if(indicator!='N')
                                   {
                                                var addressKeyFormatList = xmldoc.getElementsByTagName("AddressKeyFormat");
                                                
                                                var totalAddr=addressKeyFormatList.length;
                                                
                                                //if total matches are only one then just get confirmation
                                                  if(totalAddr==1)
                                                   {
                                                          var addressKeyFormat=addressKeyFormatList[0];
                                                          var addressline1Node = addressKeyFormat.getElementsByTagName("AddressLine")[0];
                                                          var addressline1Node1 = addressKeyFormat.getElementsByTagName("AddressLine")[1];
                                                          var residentialNode1 = addressKeyFormat.getElementsByTagName("Code")[0];
                                                          var cityNode = addressKeyFormat.getElementsByTagName("PoliticalDivision2")[0];
                                                          var stateNode = addressKeyFormat.getElementsByTagName("PoliticalDivision1")[0];
                                                          var zipcodeNode = addressKeyFormat.getElementsByTagName("PostcodePrimaryLow")[0];
                                                          var addressline1 = addressline1Node.childNodes[0].nodeValue;
                                                          var addressline2 = "";
                                                          if(addressline1Node1 != null){
                                                                  addressline2 = addressline1Node1.childNodes[0].nodeValue;
                                                                }
                                                                var residentialCode = residentialNode1.childNodes[0].nodeValue;
                                                                var residentialInd = "";
                                                                if(residentialCode == "2"){
                                                                        residentialInd = "Y";
                                                                }
                                                          var city = cityNode.childNodes[0].nodeValue;
                                                          var state = stateNode.childNodes[0].nodeValue;
                                                          var zipcode = zipcodeNode.childNodes[0].nodeValue;
                                                          
                                                          var answer = confirm('Address Match found \n'+addressline1+''+ (addressline2 != ""?", "+addressline2:"") +', '+city+', '+getStatename(state)+', '+zipcode);
                                                          
                                                                                                                    
                                                          if(answer == true)
                                                                  {
                                                                        document.shippinggems.saddr1.value=addressline1;
                                                                        if(addressline2 != ""){
                                                                                document.shippinggems.saddr2.value=addressline2;
                                                                        }
                                                                        //if(residentialInd == "Y"){
                                                                                //document.shippinggems.rIndicator.checked = true;
                                                                        //}
                                                                        //else{
                                                                //              document.shippinggems.rIndicator.checked = false;       
                                                                        //}

                                                                        document.shippinggems.scity.value=city;
                                                                        document.shippinggems.sstate.value=state;
                                                                        document.shippinggems.szipCode.value=zipcode;
                                                                        document.shippinggems.hidAddrValid.value="Y";
                                                                  }
                                                         else{
                                                                        document.shippinggems.hidAddrValid.value="Y";
                                                                 }
                                                                  return;

                                                        }
                                                        /* address showing pop up start*/
                                                         var popup  = window.open("","popup","width=700,height=700,resizable=0,scrollbars=1");
 
                                                          popup.document.write("<html><head>")
                                                          popup.document.write("<title>Gems TV USA</title>")
                                                          popup.document.write("<link href='/include/font.css' rel='stylesheet' type='text/css'>")
                                                          popup.document.write("<link href='/include/font3.css' rel='stylesheet' type='text/css'>")
                                                          popup.document.write("</head>")
                                                           popup.document.write("<script>")
                                                           popup.document.write("function setAddress(){ var rad_val=''; ")
                                                           popup.document.write("for (var i=0; i < document.validateAddress.address.length; i++){")
                                                           popup.document.write("if (document.validateAddress.address[i].checked) {")
                                                           popup.document.write("rad_val = document.validateAddress.address[i].value; }  }")
                                                           popup.document.write("if(rad_val == ''){alert('Please select one of the options or cancel to re-enter shipping address'); return false;}")   
                                                           popup.document.write("var p = rad_val.split(':'); ")
                                                           popup.document.write("window.opener.document.shippinggems.saddr1.value = p[0];")
                                                           popup.document.write("if(p[1] != ''){window.opener.document.shippinggems.saddr2.value = p[1];}")
                                                          //Anu-July 30 Not used in new site
                                                          // popup.document.write("if(p[5] == 'Y'){window.opener.document.shippinggems.rIndicator.checked = true;}else{window.opener.document.shippinggems.rIndicator.checked = false}")
                                                           popup.document.write("window.opener.document.shippinggems.scity.value = p[2];")
                                                           popup.document.write("window.opener.document.shippinggems.sstate.value = p[3];")
                                                           popup.document.write("window.opener.document.shippinggems.szipCode.value = p[4];")
                                                           popup.document.write("window.opener.document.shippinggems.hidAddrValid.value = 'Y'; ")
                                                           popup.document.write("window.close();}")
                                                           popup.document.write("function cancelAddress(){")
                                                           popup.document.write("window.opener.document.shippinggems.hidAddrValid.value = 'Y'; ")
                                                           popup.document.write("window.close();}")
                                                           popup.document.write("<\/script>")
                                                                popup.document.write("<body><div align='center'><center>")
                                                                popup.document.write("<table border='0' cellpadding='0' cellspacing='0' width='657'>")
                                                                popup.document.write("<tr><td valign='top' colspan='2' height='10'></td></tr>")
                                                                popup.document.write("<tr><td width='13%' rowspan='3' valign='top'><img border='0' src='images/LOGO_L.gif' width='80' height='70'></td>")
                                                                popup.document.write("<td width='73%' valign='top'>")
                                                                popup.document.write("<table width='100%'><tr><td align='center'>&nbsp;</td><td align='right' valign='bottom'></td></tr></table>")
                                                                popup.document.write("</td></tr>")
                                                                popup.document.write("<tr><td valign='top' height='13'><p align='center'><img border='0' src='images/ups_banner.gif' align='left'></td></tr>")
                                                                popup.document.write("<tr><td width='73%' valign='bottom'>&nbsp;</td></tr>")
                                                                popup.document.write("<tr><td width='86%' colspan='2' bgcolor='#024669'><img border='0' src='/images/menu/spec-2.gif' width='10' height='2'></td></tr>")
                                                                popup.document.write("</table></center></div>")
                                                                popup.document.write("<p><CENTER><TABLE BORDER='0' CELLPADDING='3' CELLSPACING='0' WIDTH='657' ID='AutoNumber30'>")
                                                                popup.document.write("<TR><TD WIDTH='95%'><P><CENTER><FONT SIZE='+1' FACE='Arial' color='#024669'>Address list matching with your shipping address.</FONT></CENTER></TD></TR>")
                                                                popup.document.write("<TR><TD WIDTH='95%'><P><CENTER><FONT SIZE='3' FACE='Arial' color='#024669'>Please select one of the UPS matching addresses as your shipping address.</FONT></CENTER></TD></TR>")
                                                                popup.document.write("<TR><TD WIDTH='95%' HEIGHT='11'></TD></TR>")
                                                                popup.document.write("</TABLE></CENTER></p>")
                                                         
                                                                popup.document.write("<form name='validateAddress' method='get' action='' onsubmit='return false;'>")
  
                                                                popup.document.write("<P><CENTER>")

                                                        /* Display all addresses pop up start*/
                                                        for (var adrcnt=0;adrcnt<totalAddr;adrcnt++){
                                                        
                                                                var addressKeyFormat=addressKeyFormatList[adrcnt];
                                                        
                                                                var addressline1Node = addressKeyFormat.getElementsByTagName("AddressLine")[0];
                                                                /* Start fix issue 155, UPS Address Validation, Santosh Kumar Sahoo, 4th Mar 2008
                                                                        Reading the address line and residensial indicator node from UPS response XML*/
                                                          var addressline1Node1 = addressKeyFormat.getElementsByTagName("AddressLine")[1];
                                                          var residentialNode1 = addressKeyFormat.getElementsByTagName("Code")[0];
                                                          /* End fix issue 155, UPS Address Validation, Santosh Kumar Sahoo, 4th Mar 2008*/
                                                                var cityNode = addressKeyFormat.getElementsByTagName("PoliticalDivision2")[0];
                                                                var stateNode = addressKeyFormat.getElementsByTagName("PoliticalDivision1")[0];
                                                                var zipcodeNode = addressKeyFormat.getElementsByTagName("PostcodePrimaryLow")[0];
                                                          
                                                                var addressline1 = addressline1Node.childNodes[0].nodeValue;
                                                           
                                                           /* Start fix issue 155, UPS Address Validation, Santosh Kumar Sahoo, 4th Mar 2008
                                                                        parsing the address line 2 and residential indicator values from their respective
                                                                        XML nodes*/
                                                                var addressline2 = "";
                                                                if(addressline1Node1 != null){
                                                                  addressline2 = addressline1Node1.childNodes[0].nodeValue;
                                                                }
                                                                
                                                                //var residentialCode = residentialNode1.childNodes[0].nodeValue;
                                                                //var residentialInd = "";
                                                                //if(residentialCode == "2"){
                                                                        //residentialInd = "Y";
                                                                //}
                                                                
                                                                var city = cityNode.childNodes[0].nodeValue;

                                                                var state = stateNode.childNodes[0].nodeValue;

                                                                var zipcode = zipcodeNode.childNodes[0].nodeValue;

                                   
                                                                popup.document.write("<TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='657' ID='AutoNumber10'>")
                                                                popup.document.write("<TR><TD BGCOLOR='#024669' HEIGHT='3'></TD></TR>")
                                                                popup.document.write("<TR><TD VALIGN='TOP'><TABLE BORDER='0' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'>")
                                                                popup.document.write("<TR><TD WIDTH='100%' COLSPAN='3'></TD></TR>")
                                                                popup.document.write("<TR><TD COLSPAN='3' HEIGHT='3'></TD></TR>")
                                                                popup.document.write("<TR><TD width='20%'><TABLE BORDER='0' CELLPADDING='2' CELLSPACING='0' WIDTH='100%' ID='url'>")
                                                                popup.document.write("<TR><TD WIDTH='95%'><CENTER><p>")
                                                                popup.document.write("<input type='radio' value='"+ addressline1  +":"+ addressline2  +":"+ city  +":"+ state +":"+ zipcode  +":"+ residentialInd +"' name='address'>   ");  
                                                                popup.document.write(" </p></CENTER></TD></TR></TABLE></TD>");
                                                                popup.document.write("<TD BACKGROUND='images/table/BG.gif' WIDTH='1%'>&nbsp;</TD>")
                                                                popup.document.write("<TD VALIGN='TOP'><TABLE CELLSPACING='0' CELLPADDING='0' style='border-collapse: collapse' WIDTH='100%'>")
                                                                popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='middle' BGCOLOR='#ffffff' HEIGHT='25' width='23%'><b><font face='Arial' color='#01184e' style='font-size: 11px'>Address Line 1:</font></b></TD>")
                                                                popup.document.write("<TD width='76%' HEIGHT='25' valign='middle' BGCOLOR='#ffffff' colspan='4'><font face='Arial' style='font-size: 11px' color='#01184E'>" + addressline1  + "</font></TD</TR>")
                                                                popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='TOP' BGCOLOR='#024669' HEIGHT='1' COLSPAN='5'></TD></TR>")
                                                                popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='middle' BGCOLOR='#ffffff' HEIGHT='25'><b><font face='Arial' color='#01184e' style='font-size: 11px'>Address Line 2:</font></b></TD>")
                                                                popup.document.write("<TD width='76%' HEIGHT='25' valign='middle' BGCOLOR='#ffffff' colspan='4'><font face='Arial' style='font-size: 11px' color='#01184E'>" + addressline2  + "</font></TD</TR>")
                                                                popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='TOP' BGCOLOR='#024669' HEIGHT='1' COLSPAN='5'></TD></TR>")
                                                                popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='middle' BGCOLOR='#ffffff' HEIGHT='25' width='23%'><b><font face='Arial' color='#01184e' style='font-size: 11px'>City:</font></b></TD>")
                                                                popup.document.write("<TD HEIGHT='25' valign='middle' BGCOLOR='#ffffff' width='25%'><font face='Arial' color='#01184e' style='font-size: 11px'>" + city + "</font></TD>")
                                                                popup.document.write("<TD HEIGHT='25' valign='middle' BGCOLOR='#ffffff' width='20%' colspan='2'><b><font face='Arial' color='#01184e' style='font-size: 11px'>State:</font></b></TD>")
                                                                popup.document.write("<TD HEIGHT='25' valign='middle' BGCOLOR='#ffffff' width='29%'><font face='Arial' color='#01184e' style='font-size: 11px'>" + getStatename(state) + "</font></TD></TR>")
                                                                popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='TOP' BGCOLOR='#024669' HEIGHT='1' COLSPAN='5'></TD></TR>")
                                                                popup.document.write("<TR><TD VALIGN='middle' BGCOLOR='#ffffff' HEIGHT='25' width='23%'><b><font face='Arial' color='#01184e' style='font-size: 11px'>Zip Code:</font></b></TD>")
                                                                popup.document.write("<TD HEIGHT='25' valign='middle' BGCOLOR='#ffffff' width='25%'><font face='Arial' color='#01184e' style='font-size: 11px'>" + zipcode + "</font></TD>")
                                                                popup.document.write("<TD HEIGHT='25' valign='middle' BGCOLOR='#ffffff' width='20%' colspan='2'><b><b><font face='Arial' color='#01184e' style='font-size: 11px'>Country:</font></b></TD>")
                                                                popup.document.write("<TD HEIGHT='25' valign='middle' BGCOLOR='#ffffff' width='29%'><font face='Arial' style='font-size: 11px' color='#01184E'>USA</font></TD></TR>")
                                                                //Anu-July 30 MAntis issue-Shipping address should be validated
                                                                //popup.document.write("<TR ALIGN='LEFT'><TD VALIGN='TOP' BGCOLOR='#024669' HEIGHT='1' COLSPAN='5'></TD></TR>")
                                                                //popup.document.write("<TD width='76%' HEIGHT='15' valign='middle' BGCOLOR='#ffffff' colspan='4'>&nbsp;</font></TD</TR>")
                                                                //popup.document.write("<TR><TD VALIGN='TOP' BGCOLOR='#024669' HEIGHT='1' COLSPAN='5'></TD></TR>")
                                                                //popup.document.write("<TR><TD VALIGN='TOP' BGCOLOR='#024669' HEIGHT='1' COLSPAN='5'></TD></TR>")
                                                                popup.document.write("</TABLE></TD></TR><TR><TD COLSPAN='3' HEIGHT='3'></TD></TR></TABLE></TD></TR>")
                                                                popup.document.write("<TR><TD BGCOLOR='#024669' HEIGHT='1'></TD></TR><TR> <TD></TD></TR><TR><TD HEIGHT='2'></TD></TR>")
                                                                popup.document.write("</TABLE>")
 
                                                /* address showing pop up End*/
                                                        }/* for loop ends*/
                        
                        
                        
                        
                                                        /*popup.document.write("</CENTER></P>")
                                                        popup.document.write("<P><CENTER><div style='color:#024669;font:bold 18px Arial, Helvetica, sans-serif'")
                                                        popup.document.write("<span style='cursor:pointer;' onclick='return cancelAddress();'>Cancel</span>")
                                                        popup.document.write("<span style='cursor:pointer;' onclick='return setAddress();'>&nbsp&nbsp&nbspSubmit Address</span>")
                                                        popup.document.write("</div>")
                                                        popup.document.write("</CENTER></P></form></body></html>")*/
                                                        
                                                        popup.document.write("<P><CENTER><TABLE BORDER='0' CELLPADDING='2' CELLSPACING='0'ID='AutoNumber20'>")
                                                        popup.document.write("<TR><TD WIDTH='40%'><P><CENTER><button name='Validate' width='25' height='15' style='width: 58; height: 24' onclick='cancelAddress()'>")
                                                        popup.document.write("<FONT FACE='Arial'><span style='font-size: 12px'>Cancel</span></FONT></button></CENTER></TD>")
                                                        popup.document.write("<TD WIDTH='60%'><P><CENTER><button name='Validate' width='25' height='15' style='width: 100; height: 24' onclick='setAddress()'>")
                                                        popup.document.write("<FONT FACE='Arial'><span style='font-size: 12px'>Submit Address</span></FONT></button></CENTER></TD></TR>")
                                                        popup.document.write("</TABLE></CENTER></P></form></body></html>")
                                                
                                }//if indicator block ends
                        }//else response status code ends

                }//if xmlHttp.status ends
        }//if xmlHttp.readyState ends
}

function createXMLHttpRequest() {
        if (window.ActiveXObject)       {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }       
        else if (window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
        }
}

//mantis 453 :: mary ann paclaon
function buyNowTVGameProd(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId, page)
{
        var url = "multipleProductAuction.htm?productId="+proId+"&isParent=YN&dummy="+Math.floor(Math.random()*1000000);
         try{
                if (window.XMLHttpRequest){
                        xmlHttp = new XMLHttpRequest();
                }else if (window.ActiveXObject){
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlHttp.open("POST", url, true);
                xmlHttp.onreadystatechange=function()
        {
                if(xmlHttp.readyState==4)
                  {
                        if (xmlHttp.status == 200)
                                  {
                                           try 
                                           {
                                                   var status = xmlHttp.responseText;
                                                   if (status == "false")
                                                   {
                                                           //alert("continue as usual procedure...");
                                                           buyNowTVGame(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId, page);
                                                   }
                                                   else
                                                   {
                                                           showLayerTVProductGrpWeb(proId, ouCode, purchaseAmount, purchasePrice, channelId, gameId);
                                                   }
                                           }
                                           catch (exception)
                                           {
                                           }
                                }
                  }
        }
                xmlHttp.send(null);
         }
         catch(exception)
         {
         }
}


/**** Avelarde Last 10 Games *****/
function closeLookLast10GLauncher(strProductId)
{
document.getElementById("quickLookLast10GLauncher"+strProductId).style.visibility="hidden"; 
document.getElementById("submitLookLast10GLauncher"+strProductId).style.visibility="hidden"; 
}


function openQuickLookLast10GLauncher (strProductId)
{
document.getElementById("quickLookLast10GLauncher"+strProductId).style.visibility="visible"; 
document.getElementById("submitLookLast10GLauncher"+strProductId).style.visibility="hidden";
}


function launchQuickLast10GLook(strProductId)
{

document.getElementById("submitLookLast10GLauncher"+strProductId).style.left=document.getElementById("quickLookLast10GLauncher"+strProductId).style.left;
document.getElementById("submitLookLast10GLauncher"+strProductId).style.top=document.getElementById("quickLookLast10GLauncher"+strProductId).style.top;
document.getElementById("submitLookLast10GLauncher"+strProductId).style.visibility="visible"; 
document.getElementById("quickLookLast10GLauncher"+strProductId).style.visibility="hidden";   
}

function removeQuickLast10GLook(strProductId)
{
document.getElementById("submitLookLast10GLauncher"+strProductId).style.visibility="hidden";  
}
