function getPageSize( ) {
  
  var xScroll, yScroll;
  
  if (window.innerHeight && window.scrollMaxY) {  
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }
  
  var windowWidth, windowHeight;
  if (self.innerHeight) { // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  } 
  
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else { 
    pageHeight = yScroll;
  }
  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){  
    pageWidth = windowWidth;
  } else {
    pageWidth = xScroll;
  }
    
  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
  return arrayPageSize;
  
}

function hide_selects() {
  var sel = document.getElementById('basis').getElementsByTagName('select');
  for ( var i = 0; i < sel.length; i++ ) {
    sel[i].style.visibility = "hidden";
  } 
  
}

function show_selects() {
  var sel = document.getElementById('basis').getElementsByTagName('select');
  for ( var i = 0; i < sel.length; i++ ) {
    sel[i].style.visibility = "";
  }   
}


function show_popup(){
  var bodyHeight = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
  
  document.getElementById('popup').style.display = '';
  document.getElementById('popup').style.height  = bodyHeight+"px";

  hide_selects();
}


/*Added by Vikas R pop for Registry Rules on Registry Guided Path*/ 
function show_popupRegistryRules(categoryName){
  var bodyHeight = 0;
  var bodyWidth = 0;
  document.getElementById('headerImage').innerHTML = "<h2 id=\"" + categoryName.toLowerCase() + "-header\"><span>&nbsp;</span></h2>";//"<h2 id=\"" + cateogoryName.toLowerCase() + "-header\"><span style=\"display:none;\" >cateogoryName.toLowerCase()</span></h2>";

    switch (categoryName) {
      case 'China':
            document.getElementById('china-content').style.display = '';
            document.getElementById('flatware-content').style.display = 'none';
            document.getElementById('barware-content').style.display = 'none';
            document.getElementById('stemware-content').style.display = 'none';
            document.getElementById('mattresses-content').style.display = 'none';
            document.getElementById('homefashion-content').style.display = 'none';
            
            document.getElementById('china-headertext').style.display = '';
            document.getElementById('flatware-headertext').style.display = 'none';
            document.getElementById('barware-headertext').style.display = 'none';
            document.getElementById('stemware-headertext').style.display = 'none';
            document.getElementById('mattresses-headertext').style.display = 'none';
            document.getElementById('homefashion-headertext').style.display = 'none';
          
            break;
      case 'Flatware':
            document.getElementById('china-content').style.display = 'none';
            document.getElementById('flatware-content').style.display = '';
            document.getElementById('barware-content').style.display = 'none';
            document.getElementById('stemware-content').style.display = 'none';
            document.getElementById('mattresses-content').style.display = 'none';
            document.getElementById('homefashion-content').style.display = 'none';
            
            document.getElementById('china-headertext').style.display = 'none';
            document.getElementById('flatware-headertext').style.display = '';
            document.getElementById('barware-headertext').style.display = 'none';
            document.getElementById('stemware-headertext').style.display = 'none';
            document.getElementById('mattresses-headertext').style.display = 'none';
            document.getElementById('homefashion-headertext').style.display = 'none';
            
            break;
      case 'Barware':
            document.getElementById('china-content').style.display = 'none';
            document.getElementById('flatware-content').style.display = 'none';
            document.getElementById('barware-content').style.display = '';
            document.getElementById('stemware-content').style.display = 'none';
            document.getElementById('mattresses-content').style.display = 'none';
            document.getElementById('homefashion-content').style.display = 'none';
            
            document.getElementById('china-headertext').style.display = 'none';
            document.getElementById('flatware-headertext').style.display = 'none';
            document.getElementById('barware-headertext').style.display = '';
            document.getElementById('stemware-headertext').style.display = 'none';
            document.getElementById('mattresses-headertext').style.display = 'none';
            document.getElementById('homefashion-headertext').style.display = 'none';
            
            break;
      case 'Stemware':
            document.getElementById('china-content').style.display = 'none';
            document.getElementById('flatware-content').style.display = 'none';
            document.getElementById('barware-content').style.display = 'none';
            document.getElementById('stemware-content').style.display = '';
            document.getElementById('mattresses-content').style.display = 'none';
            document.getElementById('homefashion-content').style.display = 'none';
            
            document.getElementById('china-headertext').style.display = 'none';
            document.getElementById('flatware-headertext').style.display = 'none';
            document.getElementById('barware-headertext').style.display = 'none';
            document.getElementById('stemware-headertext').style.display = '';
            document.getElementById('mattresses-headertext').style.display = 'none';
            document.getElementById('homefashion-headertext').style.display = 'none';
            break;
      case 'Mattresses':
            document.getElementById('china-content').style.display = 'none';
            document.getElementById('flatware-content').style.display = 'none';
            document.getElementById('barware-content').style.display = 'none';
            document.getElementById('stemware-content').style.display = 'none';
            document.getElementById('mattresses-content').style.display = '';
            document.getElementById('homefashion-content').style.display = 'none';
            
            document.getElementById('china-headertext').style.display = 'none';
            document.getElementById('flatware-headertext').style.display = 'none';
            document.getElementById('barware-headertext').style.display = 'none';
            document.getElementById('stemware-headertext').style.display = 'none';
            document.getElementById('mattresses-headertext').style.display = '';
            document.getElementById('homefashion-headertext').style.display = 'none';
            break;
      case 'HomeFashion': 
            document.getElementById('china-content').style.display = 'none';
            document.getElementById('flatware-content').style.display = 'none';
            document.getElementById('barware-content').style.display = 'none';
            document.getElementById('stemware-content').style.display = 'none';
            document.getElementById('mattresses-content').style.display = 'none';
            document.getElementById('homefashion-content').style.display = '';
            
            document.getElementById('china-headertext').style.display = 'none';
            document.getElementById('flatware-headertext').style.display = 'none';
            document.getElementById('barware-headertext').style.display = 'none';
            document.getElementById('stemware-headertext').style.display = 'none';
            document.getElementById('mattresses-headertext').style.display = 'none';
            document.getElementById('homefashion-headertext').style.display = '';
            break;
      default:
            document.getElementById('china-content').style.display = 'none';
            document.getElementById('flatware-content').style.display = 'none';
            document.getElementById('barware-content').style.display = 'none';
            document.getElementById('stemware-content').style.display = 'none';
            document.getElementById('mattresses-content').style.display = 'none';
            document.getElementById('homefashion-content').style.display = 'none';
            
            document.getElementById('china-headertext').style.display = 'none';
            document.getElementById('flatware-headertext').style.display = 'none';
            document.getElementById('barware-headertext').style.display = 'none';
            document.getElementById('stemware-headertext').style.display = 'none';
            document.getElementById('mattresses-headertext').style.display = 'none';
            document.getElementById('homefashion-headertext').style.display = 'none';
            break;
       }
  
   var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
   bodyWidth = sizes[0];
  
  if(categoryName == 'China')
  {
    bodyHeight = bodyHeight + 775;
  }
  else
  {
  bodyHeight = bodyHeight + 250;
  }
   
  document.getElementById('popupRegistryRules').style.display = '';
  document.getElementById('popupRegistryRules').style.height  = bodyHeight+"px";
  document.getElementById('popupRegistryRules').style.width  = bodyWidth+"px";
  hide_selects();
}

function show_popupFP(message){
  
  var bodyHeight = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
  document.getElementById('popupforpwd').style.display = '';
  document.getElementById('popupforpwd').style.height  = bodyHeight+"px";
  if(message !="valid")
  {
    document.getElementById('lblForgottext').innerHTML = message;
    document.getElementById('lblForgottext').style.color = "red";
  }
  hide_selects();
}
function show_popupFPMailInfomation(){
  var bodyHeight = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
  document.getElementById('popupMailInfomation').style.display = '';
  document.getElementById('popupMailInfomation').style.height  = bodyHeight+"px";
  
  hide_selects();
}

function show_PopupShipTo(shipToName, shipToNameHidden,Id,regID,radioBtnList,shipto,shipToDrp,shipToYouAddr,LineItemId,ShipId,addressName,regidHidden,shipToHidden,pageFromHidden,page,varId,varIdHidd)
{

  var bodyHeight = 0;
   var bodyWidth = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
     bodyWidth = sizes[0];
  
  document.getElementById('popupShipTo').style.display = '';
  document.getElementById('popupShipTo').style.height  = bodyHeight+"px";
  document.getElementById('popupShipTo').style.width  = bodyWidth+"px";
  
  //hide_selects();
  
   var regRadioList = document.getElementById(radioBtnList);
   var shipToDrpList = document.getElementById(shipToDrp);
   var lineItemID =  document.getElementById(LineItemId);
   var shippingID =  document.getElementById(ShipId);
   var regIDValue =  document.getElementById(regidHidden);
   var shipToValue = document.getElementById(shipToHidden);
   var varIDHidden = document.getElementById(varIdHidd);
   var shipToOtherAddressName = document.getElementById(shipToNameHidden);
   var pageFromHiddenValue = document.getElementById(pageFromHidden);
   pageFromHiddenValue.value = page;
   regIDValue.value = regID
   shipToValue.value =  shipto;
   lineItemID.value = Id;
   varIDHidden.value = varId;
   shipToName = shipToName.replace("#","'");
   if(shipto=="SomeoneElse" || shipto=="You")
   {     
      shipToOtherAddressName.value = shipToName;
   }
   
   addressName = addressName.replace("#","'"); 
   if(regRadioList!=null)
    {
   
         var count = regRadioList.rows.length;     
         var regId =  regID; 
          if(count==1)
          {
           regRadioList.getElementsByTagName("input")[0].checked = true; 
          }
         for(var radioIndex=0; radioIndex < count;radioIndex++)
         {        
            var isTrue = "false";
            
            if(regRadioList.getElementsByTagName("input")[radioIndex].value!="No")
            {
                if(regRadioList.getElementsByTagName("input")[radioIndex].value == regId)
                {
                   isTrue = "true";              
                   regRadioList.getElementsByTagName("input")[radioIndex].style.display = "";
                   regRadioList.getElementsByTagName("label")[radioIndex].style.display = "";   
                   regRadioList.getElementsByTagName("input")[radioIndex].checked = true;                   
                }           
                  
                if(isTrue=="false")
                {
                   regRadioList.getElementsByTagName("input")[radioIndex].style.display = "none";
                   regRadioList.getElementsByTagName("label")[radioIndex].style.display = "none";
                }
            }
            else
            {
                if(shipto=="You" || shipto=="SomeoneElse")
                {
                     regRadioList.getElementsByTagName("input")[radioIndex].checked = true; 
                }
            }
         }
    }
    if(shipToDrpList!=null)
    {
            var maxlength =  shipToDrpList.length;
            //clear all selection in drp List
             for(var index=0; index<maxlength; index++)
             {
                 shipToDrpList.options[index].selected = false;
             }
          
        if(shipToYouAddr!='')
        {
            var isShipToYou = 'False';
            shippingID.value = shipToYouAddr;
            var maxlength =  shipToDrpList.length;
            for(var index=0; index<maxlength; index++)
                {            
                 if(shipToDrpList.options[index].text=='You')
                    {                    
                        shipToDrpList.options[index].text = addressName; 
                        if(shipto=="You")
                        {
                          shipToDrpList.options[index].selected = true;
                          isShipToYou ='True'; 
                         }
                        break;
                    }
                }
            
        }
        else
        {
           shippingID.value = '';
          
        }
        //Select the appropriate shipping adress name in the ship to dropdown
        if(shipto=="You")
        {
           //This flag checks if the Ship to You address name is given. If no then choose ShipTo You option from dropdown.
            var isShipToNameAvail = false;
            if(addressName!='')
            {
                for(var index=0; index<maxlength; index++)
                {
                    if(shipToDrpList.options[index].text.toLowerCase()  == addressName.toLowerCase() )
                    {
                        shipToDrpList.options[index].selected = true;
                        isShipToNameAvail = true;
                        break;
                    }
                }                
            }
            if(!isShipToNameAvail)
            {
                var maxlength =  shipToDrpList.length;
                for(var index=0; index<maxlength; index++)
                {            
                 if(shipToDrpList.options[index].text=='You')
                    {                    
                       shipToDrpList.options[index].selected = true;
                       break;
                    }
                }
            }
        }
        if(shipto=="SomeoneElse")
        {
            //Check if Ship To Other name exists in dropdown. If no then select "Other" option in Dropdown
            var isShipToOtherAvail = false;
            for(var index=0; index<maxlength; index++)
            {
                if(shipToDrpList.options[index].text.toLowerCase()  == shipToName.toLowerCase() )
                {
                    shipToDrpList.options[index].selected = true;
                    isShipToOtherAvail = true;
                    break;
                }
            } 
            if(!isShipToOtherAvail)   
            {
                var maxlength =  shipToDrpList.length;
                for(var index=0; index<maxlength; index++)
                {            
                 if(shipToDrpList.options[index].text=='Other')
                    {                    
                       shipToDrpList.options[index].selected = true;
                       break;
                    }
                }
            }
        }
    }
  
}

function show_privateregistrypopup(){
  var bodyHeight = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
  bodyWidth = sizes[0];
  document.getElementById('privateregistrypopup').style.display = '';
  document.getElementById('privateregistrypopup').style.height  = bodyHeight+"px";
   document.getElementById('privateregistrypopup').style.width  = bodyWidth+"px";
  hide_selects();
}
function show_popupRFR(){
  var bodyHeight = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
  bodyWidth = sizes[0];
  document.getElementById('popupRFR').style.display = '';
  document.getElementById('popupRFR').style.height  = bodyHeight+"px";
   document.getElementById('popupRFR').style.width  = bodyWidth+"px";
  hide_selects();
}

function show_popupSameRegistry(){

  var bodyHeight = 0;
  var sizes = getPageSize( );
  
  bodyHeight = sizes[1];
  bodyWidth = sizes[0];
  document.getElementById('popupSameRegistry').style.display = '';
  document.getElementById('popupSameRegistry').style.height  = bodyHeight+"px";
   document.getElementById('popupSameRegistry').style.width  = bodyWidth+"px";
  hide_selects();
}

function clickButton(e)
{
      var evt = e ? e : window.event;   
      var elet = document.forms[0].elements;        
      
          if (evt.keyCode == 13)
          { 
               for(var i=0;i<elet.length;i++)
               {
                    if(elet[i].type=="button")
                    {
                        if(elet[i].id=='ShipToOtherBtn')
                        {
                            elet[i].click();
                             return false; 
                        }
                       
                    }                
               }
               
          }     
}


function show_PopupShipToOther()
{
  var bodyHeight = 0;
  var sizes = getPageSize( );
  var j=0;
  bodyHeight = sizes[1];
  bodyWidth = sizes[0];
  document.getElementById('popupShipToOther').style.display = '';
  document.getElementById('popupShipToOther').style.height  = bodyHeight+"px";
   document.getElementById('popupShipToOther').style.width  = bodyWidth+"px";
   
  var elet = document.forms[0].elements;  
  for(var i =0; i<elet.length;i++)
  {
    if(elet[i].type=="text")
    {
       if(j==3)
        {      
            elet[i].focus();   
            return false;        
        }
       j++;      
    }
    
  }
  hide_selects();
}

function show_PopupShipToOtherPIP()
{
  var bodyHeight = 0;
  var sizes = getPageSize( );
   var j=0;
  bodyHeight = sizes[1];
  bodyWidth = sizes[0];
  document.getElementById('popupShipToOtherPIP').style.display = '';
  document.getElementById('popupShipToOtherPIP').style.height  = bodyHeight+"px";
   document.getElementById('popupShipToOtherPIP').style.width  = bodyWidth+"px";
  var elet = document.forms[0].elements;
  for(var i =0; i<elet.length;i++)
  {
    if(elet[i].type=="text")
    {
       if(j==3)
        {      
            elet[i].focus();
            return false;
        }
       j++;
      
    }
  }
  hide_selects();
}

function show_faq_item(faq_item){
  answer   = faq_item.getElementsByTagName('div')[0];
  question = faq_item.getElementsByTagName('a')[0];

  if (question && answer){
    if ('selected' == question.className){ 
      question.className   = '';
      answer.style.display = 'none';      
    }
    else{
      question.className   = 'selected';
      answer.style.display = '';
    }
  }
}