//Variable for all regsS
var allRegiSS = new Array();

//New window that will be used by Prod full Desc page
//by passing in all the properties

var httpRequestSupported = true;
// Initialize storeId with b2b storeid
var storeId=10101;

function setStoreId(storeIdValue){
storeId = storeIdValue;
}

function getStoreId(){
return storeId;
}

 function openWindow(url, name, properties)
 {
   var newWin = window.open(url, name, properties);
   newWin.focus();
 }

function goGlossary(url) {
    var glossWin= window.open(url, 'glossary', 'height=500,width=300,resizeable,scrollable');
    glossWin.focus();
}
    
function goPrintable(url) {
    var printWin= window.open(url, 'print_win');
    printWin.focus();
}

function checkSKUSelection() {
    var frm = document.forms["skuForm"];
    for (var i=0; i<frm.elements.length; i++) {
        var elm = frm.elements[i];
        if (elm.type.indexOf("select") != -1) { 
            if (elm.selectedIndex <= 0) { 
                alert("Please select an option for " + elm.options[0].value + ".");
                elm.focus();
                return false;
            }
        }
    }
    return true;
}

function submitSKUForm() {
    if (checkSKUSelection() == true) {
        document.forms["skuForm"].submit();
    }
}

function checkZip() {
  zip = document.forms["zipForm"].elements["zip"].value; 
  var lv_pattern = /^\d{5}$|^\d{5}\-?\d{4}$/;
  var passed = lv_pattern.test(zip); 
  if (!passed) {
    alert("The zipcode you entered is not valid.  Please re-enter zipcode.");
    return false;
  }
  else {
    return true;
  }
}


function openInstallationCost(url) {
  var win0 = window.open(url, 'install_cost', 'scrollbars=yes,menubar=yes,toolbar=no,status=no,width=375,height=325,screenX=300,screenY=175');
  win0.focus();
}

function openShipCalc(url) {
  var win1 = window.open(url, 'ship_calc', 'resizable=yes,directories=no,scrollbars=yes,menubar=no,toolbar=no,location=no,status=no,width=520,height=450');
  win1.focus();   
}

function openDeliveryCalc() {
    var win2 = window.open("/sears/popup_deliverycalc.html", "deliver_calc", "directories=no,scrollbars=yes,menubar=yes,toolbar=no,status=no,width=545,height=350");
    win2.focus();
}
    /*
 function openRebate(url) {
  var rebateWin = window.open(url, 'popup', 'scrollbars=yes,menubar,toolbar,width=450,height=300,screenX=300,screenY=175');
  rebateWin.focus();
 }*/

function fn_kw_checkKeyword()
{
    var k = null;
    if(document.keywordForm != null) {
        k = document.keywordForm.keyword;
    }
    else if(document.searchForm != null) {
        k = document.searchForm.keyword;
    }
    var v = k.value;
    if(v != null) {
        v = v.replace(/^\s+/,"");
        v = v.replace(/\s+$/,""); 
        if(v != null && v.length > 0 && !v.match(/\d+/)) {
              v = v.toLowerCase();
        }
        k.value = v;
    }

    if(v == null || v.length == 0) {
        return false;
    }

    return true;
}

function trimAll(sString) 
    {
    while (sString.substring(0,1) == ' ')
    {
    sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
    sString = sString.substring(0,sString.length-1);
    }
    return sString.toLowerCase();
}

 //
 // Email Verification and Validation (Date 07/27/2003)
 //
 
 function validateEmailAddress(email){
    var regex1 = /^[^\s@]+@([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]\.|[A-Za-z0-9]\.)+([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]|[A-Za-z0-9])$/;
    var regex2 = /^(root@|abuse@|spam@)/;
    if(!email.match(regex1)){
   //   alert("The e-mail address you entered appears incorrect. (Example of a correct address: sears@sears.com.) Please check your information and try again.");
        return false;
    } else if(email.match(regex2)){
        alert(email + " is not allowed");
        return false;
    }
    return true;
}


function verifyEmailAddresses(email1, email2)
{
    
    if(email1 == null || email2 == null){
        alert("Email address is required");
        return false;
    }
        if(!validateEmailAddress(email1)){
           alert("The e-mail address you entered appears incorrect. (Example of a correct address: sears@sears.com.) Please check your information and try again.");
            return false;
        email1.select(); 
        email1.focus();
    }
    
    if(!validateEmailAddress(email2)){
       alert("The Confirm Email address you entered appears incorrect. (Example of a correct address: sears@sears.com.) Please check your information and try again.");
            return false;
        email2.select(); 
        email2.focus();
    }
            
    
    var emailr = email1.replace(/\+/g, "\\+");      // SY 04/16/04 PD00018534
        var regex = new RegExp("^" + emailr + "$","i"); // in case there's '+' in the email address
    if(email2.match(regex) == null)
    {
         alert(" The e-mail addresses you entered below are not the same. Please check your address and try again.");
        return false;
        email1.select(); 
        email1.focus();
        }
    
    return true;
}

function verifyCheckoutParameters(pwd,pwdconfirm,pwdhint)
{
    var lv_ok;
    if(pwd.value==null || pwd.value=="")
    {
        alert("Please, enter the password");
        lv_ok=-1;
        pwd.focus();
        return lv_ok;
        
    }
    else if(pwdconfirm.value==null || pwdconfirm.value=="")
    {
        alert("Re-enter password is required field");
        lv_ok=-1;
        pwdconfirm.focus();
        return lv_ok;
        
    }
    else if(pwd.value!=pwdconfirm.value)
    {
        alert("The password and the re-entered password must be the same");
        lv_ok=-1;
        pwdconfirm.focus();
        return lv_ok;
    }
    else if(hint.value ==null || hint.value =="")
    {
        alert("Password hint is required field");
        lv_ok=-1;
        hint.focus();
        return lv_ok;
    }
        return lv_ok;
}

// TABS FUNCTIONS ///
function hideTabs (a) {
    var d = document.getElementById("tabList");
    var dLength = d.getElementsByTagName("dt").length;
    
    for (var i = 1; i < dLength + 1; i++){
        if (document.getElementById("tab_" + i).className == "selected"){
            tabHide = document.getElementById("tab_" + i);
            tabHide.className = "unselected";
        }
        document.getElementById("tab" + i).style.display="none";
    } 
    
    tabHide = document.getElementById("tab_" + a);
    tabHide.className = "selected";
    document.getElementById("tab" + a).style.display="";
}


// this function below is for changing show and hiding
function showBox (id) {
    if(document.getElementById) document.getElementById(id).style.display="";
    return true;
}
function hideBox (id) {
    if(document.getElementById) document.getElementById(id).style.display="none";
    return true;
}

function showhideBox (id) {
    var d=document.getElementById(id);
    
    if(document.getElementById){
        if (d.style.display !== "none"){
            d.style.display="none";
        } else {
            d.style.display="";
        }
    }
    
    d.style.top = "15px";
    d.style.left = "-5px";
}


// find position of the image calling the function and set the infobox next to it //
function whereAt (a){
    var d = document.getElementById('tabContent');
    var c = d.getElementsByTagName('img');
    var f = findPosY(document.getElementById('tabContent'));
    var e = findPosX(document.getElementById('tabContent'));
    for(var i = 0; i < c.length; i++){
        if (i == a) {
            document.getElementById('prodSpecInfo').style.top = (findPosY(c[i])- f - 5) + "px";
            document.getElementById('prodSpecInfo').style.left = (findPosX(c[i])- e + 0) + "px";
            showBox ('prodSpecInfo');
        }
    }
}
function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

// Display Div over select form dropdown and switch z index //
function divFloat(id,state)
    {
        var DivRef = document.getElementById(id);
        var IfrRef = document.getElementById('iCover');
        if(state)
        {
            DivRef.style.display = "block";
            IfrRef.style.width = DivRef.offsetWidth;
            IfrRef.style.height = DivRef.offsetHeight - 2;
            IfrRef.style.top = DivRef.style.top;
            IfrRef.style.left = DivRef.style.left;
            IfrRef.style.zIndex = DivRef.style.zIndex - 1;
            IfrRef.style.display = "block";
        }
           else
        {
            DivRef.style.display = "none";
            IfrRef.style.display = "none";
        }
       // document.getElementById('contentWrapper').style.position = "static";
        document.getElementById('footer').style.position = "static";
    }

// hide and seek table cells //
function showCell (b) {
    var c = document.getElementsByTagName('tr');
    for(var i = 0; i < c.length; i++){
        if(c[i].getAttribute('hiding') == b){
            c[i].style.display = "";
        }
    }
}
function hideCell (b) {
    var c = document.getElementsByTagName('tr');
    for(var i = 0; i < c.length; i++){
        if(c[i].getAttribute('hiding') == b){
            c[i].style.display = "none";
        }
    }
}
// show hide divs //
function collapse(a,b) {
    if (document.getElementById(a).className=="hideAtt"){
        hideCell (b);
        tableHide=document.getElementById(a);
        tableHide.className="showAtt";
        tableHide.innerHTML="<a href=\"javascript:;\" onClick=\"collapse('"+a+"','"+b+"');\">See Details</a>";
        a = a + "_on";
    } else if (a + "_on"){
        showCell (b);
        tableHide=document.getElementById(a);
        tableHide.className="hideAtt";
        tableHide.innerHTML="<a href=\"javascript:;\" onClick=\"collapse('"+a+"','"+b+"');\">Hide Details</a>";
        a = a + "_off";
    }
}

// this function below is for changing CSS class of the size buttons and populating appropriate 'selected size' label with the correct value

// set initial selected size value to default before function is called
initialvalue=6;

function selectedsize_fn(id, newClass, actualsize){
    chosensize=actualsize;
    //updates value displayed to selected size///////////////
    //firefox/////////////////////////////////////////
    document.getElementById("size").innerHTML = actualsize;
    //IE/////////////////////////////////////////////
    document.getElementById("size").innerText = actualsize;

    identity1=document.getElementById("size_1");
    identity1.className="unselectedsize";
    identity2=document.getElementById("size_2");
    identity2.className="unselectedsize";
    identity3=document.getElementById("size_3");
    identity3.className="unselectedsize";
    
    //change ul class for id that called function/////////////////
    identity=document.getElementById(id);
    identity.className=newClass;
    
    initialvalue="";
}

// these 2 functions are called by product option pages to hide & show select box (IE bug) when dhtml layer (what's included P.A.)is viewed
function hideSelect(id)
{if (document.all){document.getElementById(id).style.display="hidden";}}

function unhideSelect(id)
{if (document.all){document.getElementById(id).style.visibility="visible";}}

// CHECK ALL CHECKBOX RELATED TO ID //
function checkAll(theElement, id) {
    var input = document.getElementsByTagName('input');
    for(z=0; z<input.length;z++){
      if(input[z].type == 'checkbox' && input[z].name == id){
        input[z].checked = theElement.checked;
      }
    }
}

// Disable select form elements //
function disableSelect()
{
    var select = document.getElementsByTagName('select');
    for(z=0; z<select.length;z++){
        select[z].disabled = true;
    }
}
function enableSelect()
{
    var select = document.getElementsByTagName('select');
    for(z=0; z<select.length;z++){
        select[z].disabled = false;
    }
}


// FIND POSITION //
function findPos(obj) {
    xPos = yPos = 0;
    if (obj.offsetParent) {
        xPos = obj.offsetLeft;
        yPos = obj.offsetTop;
        while (obj = obj.offsetParent) {
            xPos += obj.offsetLeft;
            yPos += obj.offsetTop;
        }
    }
    return [xPos,yPos];
}

// SHOW HIDE TABLE CELLS  //
function showCell (b) {
    var c = document.getElementsByTagName('tr');
    for(var i = 0; i < c.length; i++)
    {
        if(c[i].getAttribute('hiding') == b){
            c[i].style.display = "";
        }
    }
}
function hideCell (b) {
    var c = document.getElementsByTagName('tr');
    for(var i = 0; i < c.length; i++)
    {
        if(c[i].getAttribute('hiding') == b){
            c[i].style.display = "none";
        }
    }
}



// SHOW HIDE DIVs //
function collapse(a,b) {
    if (document.getElementById(a).className=="hideAtt")
    {
        hideCell (b);
        tableHide=document.getElementById(a);
        tableHide.className="showAtt";
        tableHide.innerHTML="<a href=\"javascript:;\" onClick=\"collapse('"+a+"','"+b+"');\">See Details</a>";
        a = a + "_on";
    } 
    else if (a + "_on")
    {
        showCell (b);
        tableHide=document.getElementById(a);
        tableHide.className="hideAtt";
        tableHide.innerHTML="<a href=\"javascript:;\" onClick=\"collapse('"+a+"','"+b+"');\">Hide Details</a>";
        a = a + "_off";
    }
}

// Browser Sniff //
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
    browser = "Konqueror";
    OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
    browser = "Netscape Navigator"
    version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
    if (checkIt('linux')) OS = "Linux";
    else if (checkIt('x11')) OS = "Unix";
    else if (checkIt('mac')) OS = "Mac"
    else if (checkIt('win')) OS = "Windows"
    else OS = "an unknown operating system";
}

function checkIt(string)
{
    place = detect.indexOf(string) + 1;
    thestring = string;
    return place;
}

// Set up page to do multiple loads //
function addLoadEvent(func) {

    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } 
    else 
    {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          }
          func();
        }
    }
    
}









// Set Up Links //
function prepareLinks (id, tag, clas) {
    if (document.getElementById || document.all){
        
        var li = document.getElementById(id).getElementsByTagName(tag);
        
        for (i=0; i<li.length; i++) 
        {
        
            /* commented out for send to friend
            if (li[i].className == clas && clas == "sendFriend"){
                li[i].onclick = function (){
                    send2friend(id);
                };
            }
            */  
            if (li[i].className == clas && clas == "print"){
                li[i].onclick = function (){
                    print();
                };
            }
            
            if (li[i].className == clas && clas == "shippingCal"){
                li[i].onclick = function (){
                    shippingCalculator(id);
                };
            }
            
        }
        
        flyOut();
    }
    
}
window.onresize=flyOut;
function flyOut(){
    // flyout menu //
    if (document.getElementById('nav'))
    {
        if (this.innerHeight) // all except Explorer
        {
            var pageHeight = (this.innerHeight)+window.pageYOffset-250;
        }
        else if (document.body) // other Explorers
        {
            var pageHeight = (document.body.clientHeight)+document.body.scrollTop-250;
        }
        var n = document.getElementById('nav');
        for (i=0; i < n.childNodes.length; i++)  {
            node = n.childNodes[i];
            if (node.nodeName=="LI") {
                node.onmouseover = function() {
                    this.className += " over";
                    //alert(pageHeight);
                    if(this.childNodes[2]!=undefined && this.childNodes[2].offsetHeight>pageHeight){
                        this.childNodes[2].style.overflow='auto';
                        this.childNodes[2].style.height=pageHeight+"px";
                    }
                }
                node.onmouseout = function() {
                    this.className = this.className.replace("over", "");
                }
            }
        }
    }
}

// VERTICAL DROP DOWN FUNCTIONS //
var h;
function timeOutNav(id) {
    var hide = "hideBox('d"+id+"')";
    h = setTimeout(hide,500);
}
function dropNav(a,l) {
    var dLength = l; //how many drop downs on page
    
    for (var i = 1; i < dLength + 1; i++){
        document.getElementById("d" + i).style.display="none";
        document.getElementById("c" + i).style.position="static";
    } 
    document.getElementById("d" + a).style.display="block";
    document.getElementById("c" + a).style.position="relative";
    //document.getElementById("contentWrapper").style.zIndex = 10;
}


// TABS FUNCTIONS ///
function showTab (a,url) { 
    var d = document.getElementById("tabList");
    var dLength = d.getElementsByTagName("dd").length;
    
    for (var i = 1; i < dLength + 1; i++){
        if (document.getElementById("tab_" + i).className == "selected"){
            tabHide = document.getElementById("tab_" + i);
            tabHide.className = "unselected";
        }
        //document.getElementById("tab" + i).style.display="none";
        if(document.getElementById("tab" + i)) {
                    document.getElementById("tab" + i).style.display="none";
        }
    } 
    
    tabHide = document.getElementById("tab_" + a);
    tabHide.className = "selected";
    document.getElementById("tab" + a).style.display="";
    
    var cNodes = tabHide.childNodes;
    for (var i=0; i< cNodes.length; i++) {
        var curNode = cNodes[i];
        if (curNode.tagName == "A") {
            var tabName = curNode.innerHTML;
            if (tabName != null && tabName != 'Overview') {
                if (tabName.indexOf('Review') != -1) {
                    tabName = 'Reviews';
                }
                tabName += ' Tab';
            
                //Omniture tracking.
                if (typeof omPrefix != 'undefined') {
                    omPrefix='Product Summary > ' + tabName;
                }
                if (typeof s != 'undefined') {
                    s.t();
                }
            }
            break;
            
        }
    }
    
    selectOverview(a-1);
    
    if(a==2){
        //Ajax call for executing the specs tab
        ajaxCall(url,'displayTabContent',null,'tab2');
    }
    if(a==3 && url != null){
    	//Ajax call for executing the options tab
        ajaxCall(url,'displayTabContent',null,'tab3');
    }
}

// TABS FUNCTIONS  For Keyword Page///
function showSearchTab (a) {

    var d = document.getElementById("tabList");
    var dLength = d.getElementsByTagName("dd").length;

    for (var i = 1; i < dLength + 1; i++){
        if (document.getElementById("tab_" + i).className == "selected"){
            tabHide = document.getElementById("tab_" + i);
            tabHide.className = "unselected";
        }
        document.getElementById("tab" + i).style.display="none";  
    }     
    tabHide = document.getElementById("tab_" + a);
    tabHide.className = "selected";
    document.getElementById("tab" + a).style.display="";
    selectOverview(a-1);
}

function selectOverview(x){
    if (document.getElementById("overviewBox")){
        var d = document.getElementById("overviewBox");
        var li = d.getElementsByTagName("li");
        
        for (var i=0; i<li.length; i++){
            if (li[i].className == "selected"){
                li[i].className = '';
            }
        } 
        
        li[x].className = "selected";
    }
}

// HIDE AND SHOW //
function showBox (id) {
    if (document.getElementById) document.getElementById(id).style.display = "";
    return true;
}
function hideBox (id) {
    if(document.getElementById) document.getElementById(id).style.display = "none";
    return true;
}
// HIDE AND SHOW ADVANCE //
function showHideLite(id){
    var id = document.getElementById(id);
    id.style.display = (id.style.display == 'none') ? "" : "none";
}

function showHide(id){
    var d = document.getElementById(id);
    var d_edit = document.getElementById(id+"_edit");
    d.className = (d.className == 'open') ? "close" : "open";
    d_edit.style.display = (d_edit.style.display == 'none') ? "" : "none";
}

function showHideSelect(id,what) {
    if (!document.getElementsByTagName) return false;
    if (!document.getElementById) return false;
    var select = document.getElementById(id);
    var opts = select.getElementsByTagName("option");
    for (var j=0; j<opts.length; j++) {
        var option = opts[j].value;
        var optDivs = document.getElementById(option);
        if(optDivs){
            optDivs.style.display = "none";
        }
    }
    var elem = document.getElementById(what);
    if(elem){
        elem.style.display = "";
    }
}


// CHECK ALL CHECKBOX RELATED TO ID //
function checkAll(theElement, id) {
    var input = document.getElementsByTagName('input');
    for(z=0; z<input.length;z++){
      if(input[z].type == 'checkbox' && input[z].name == id){
        input[z].checked = theElement.checked;
      }
    }
}

// Disable select form elements //
function disableSelect()
{
    var select = document.getElementsByTagName('select');
    for(z=0; z<select.length;z++){
        select[z].disabled = true;
    }
}
function enableSelect()
{
    var select = document.getElementsByTagName('select');
    for(z=0; z<select.length;z++){
        select[z].disabled = false;
    }
}


// FIND POSITION //
function findPos(obj) {
    xPos = yPos = 0;
    if (obj.offsetParent) {
        xPos = obj.offsetLeft;
        yPos = obj.offsetTop;
        while (obj = obj.offsetParent) {
            xPos += obj.offsetLeft;
            yPos += obj.offsetTop;
        }
    }
    xPos += 20;
    yPos += 20;
    return [xPos,yPos];
}
function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
    {
        curleft += obj.x;
    }
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
    {
        curtop += obj.y;
    }
    return curtop;
}






































// SHOW HIDE TABLE CELLS  //
function showCell (b) {
    var c = document.getElementsByTagName('tr');
    for(var i = 0; i < c.length; i++)

    {
        if(c[i].getAttribute('hiding') == b){
            c[i].style.display = "";
        }
    }
}
function hideCell (b) {
    var c = document.getElementsByTagName('tr');
    for(var i = 0; i < c.length; i++)
    {
        if(c[i].getAttribute('hiding') == b){
            c[i].style.display = "none";
        }
    }
}
// SHOW HIDE DIVs //
function collapse(a,b) {
    if (document.getElementById(a).className=="hideAtt")
    {
        hideCell (b);
        tableHide=document.getElementById(a);
        tableHide.className="showAtt";
        tableHide.innerHTML="<a href=\"javascript:;\" onClick=\"collapse('"+a+"','"+b+"');\">See Details</a>";
        a = a + "_on";
    } 
    else if (a + "_on")
    {
        showCell (b);
        tableHide=document.getElementById(a);
        tableHide.className="hideAtt";
        tableHide.innerHTML="<a href=\"javascript:;\" onClick=\"collapse('"+a+"','"+b+"');\">Hide Details</a>";
        a = a + "_off";
    }
}


/* this function parses the values from URL */

function gup( name )
{
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
    {
        return "";
    }
    else
    {
    return results[1];
    }
}


function remove(id){
    var obj=id.parentNode;
    obj.removeChild(id);
}
function removeID(id){
    var foo=document.getElementById(id);
    document.body.removeChild(foo);
}

// LOAD EVENTS //
addLoadEvent(function() 
	{ 
		if (document.getElementById("nav"))
		{
			prepareLinks ("nav", "li", "");
		}
	}
); 

// VERTICAL DROP DOWN FUNCTIONS //
var h = "";
function timeOutNav(id) {
    var hide = "hideBox('d"+id+"')";
    h = setTimeout(hide,500);
}
function dropNav(a,l) {
    var dLength = l; //how many drop downs
    
    for (var i = 1; i < dLength + 1; i++){
        document.getElementById("d" + i).style.display="none";
        document.getElementById("c" + i).style.position="static";
    } 
    document.getElementById("d" + a).style.display="block";
    document.getElementById("c" + a).style.position="relative";
    //document.getElementById("contentWrapper").style.zIndex = 10;
}

// Display Div over select form dropdown and switch z index //
function divFloat(id,state){
    var DivRef = document.getElementById(id);
    var IfrRef = document.getElementById('iCover');
    if(state)
    {
        DivRef.style.display = "block";
        IfrRef.style.width = DivRef.offsetWidth;
        IfrRef.style.height = DivRef.offsetHeight - 2;
        IfrRef.style.top = DivRef.style.top;
        IfrRef.style.left = DivRef.style.left;
        IfrRef.style.zIndex = DivRef.style.zIndex - 1;
        IfrRef.style.display = "block";
    }
       else
    {
        DivRef.style.display = "none";
        IfrRef.style.display = "none";
    }
    
}



// POSITION FIXED //
var verticalpos = "fromtop";

function JSFX_FloatTopDiv()
{
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var startX = 690;
    var startY = (document.all) ? 100 : 120;
    if (document.getElementById("checkout-shipping")){
        var startY = (document.all) ? 135 : 120;
    }
    var d = document;
    function ml(id)
    {
        var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
        if(d.layers)el.style=el;
        el.sP = function(x,y){this.style.left=x;this.style.top=y;};
        el.x = startX;
        if (verticalpos == "fromtop")
            el.y = startY;
        else{
            el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
            el.y -= startY;
        }
        return el;
    }
    window.stayTopLeft = function()
    {
        if (verticalpos == "fromtop"){
            var pY = ns ? pageYOffset : document.body.scrollTop;
            ftlObj.y += (pY + startY - ftlObj.y)/8;
        }
        else{
            var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
            ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
        
        var newX = (document.body.clientWidth <= 800) ? 590 : ftlObj.x + ((document.body.clientWidth/2)-ftlObj.x)+188;
        var newY = (document.body.scrollTop < startY) ? startY : ftlObj.y - startY + 10;

        ftlObj.sP(newX, newY);
        setTimeout("stayTopLeft()", 10);
    }
    ftlObj = ml("rightColWrapper");
    d.getElementById("rightColWrapper").style.display = "block";
    stayTopLeft();
}

//Email me eligible submit //

/*
// Moved to softlinesproduct.js
function submitEmail()
{   
    
    var emailVal = document.emailNotify.userEmail.value;
    
    var partNumber = document.emailNotify.partNumber.value;
    var catEntryId = document.emailNotify.catEntryId.value;
    var skuDiff = document.emailNotify.skuDiff.value;
    var brandName = document.emailNotify.brandName.value;
    var productDescription = document.emailNotify.productDescription.value;
    var searsItemNumber = document.emailNotify.searsItemNumber.value;
    
    var manufacturerPartNumber = document.emailNotify.manufacturerPartNumber.value;
    
    
    document.cookie = "userEmail1="+emailVal+";"
    
        
    if((emailVal == '')){
        alert("Email address is required");
        return false;
    }
    
    if(validateEmailAddress(emailVal)){
    var ajaxcallUrl = "EmailMeWhenInStockCmd?userEmail="+emailVal+"&catEntryId="+catEntryId+
    "&skuDiff="+skuDiff+"&brandName="+brandName+"&productDescription="+productDescription+
    "&searsItemNumber="+searsItemNumber+"&manufacturerPartNumber="+manufacturerPartNumber;
    
    ajaxCall(ajaxcallUrl,'showEmailMe');
    }else{
       return false;
    }
    
    return true;
}

*/



// Send to friend submit //


function submitFinish()
 {
        var name = document.sendToFriendForm.visitorName.value;
        var vEmail = document.sendToFriendForm.visitorEmail.value;
        var fEmail = document.sendToFriendForm.friendsEmail.value;
        var msg = document.sendToFriendForm.message.value;
        var locationurl = top.location.href;
        document.sendToFriendForm.url.value = locationurl;
       
        if(!nameValidation(name))
        {
            return false;
        }
        
       function nameValidation(name){
       
           for(iLoop=0;iLoop<name.length;iLoop++){
            if(!((name.charCodeAt(iLoop)>64 && name.charCodeAt(iLoop)<91)||(name.charCodeAt(iLoop)>96 && name.charCodeAt(iLoop)<123) || (name.charCodeAt(iLoop)==32) || (name.charCodeAt(iLoop)== 46))){
             alert("The name you entered appears incorrect. Please check your information and try again.");
              return false;
              }
            }                       
          if(iLoop == name.length )
          {
            return true;
          }
       }
       
        
    if((vEmail == '') || (fEmail == '')){
        alert("Email address is required");
        return false;
    }

    if (!validateEmailAddress(vEmail.toLowerCase(),vEmail))
        {
                
                return false;
        }

    // fEmail = removeSpaces(fEmail); 
         var vArray = fEmail.split(";");
                  
     var count;
          for (count=0; count < vArray.length; count++)
          {
                var vElem = vArray[count];
                if (!validateEmailAddress(vElem.toLowerCase(),vElem))
                        {
                
                        return false;
                        }
          }

    if ((msg.length > 200))
    {
        alert("Message exceeds 200 characters");
            return false;
        }

        var locationurl = top.location.href;
        var stringUrl = locationurl.replace(/&/g,"*");
        var visitorName  = document.sendToFriendForm.visitorName.value;
        var visitorEmail = document.sendToFriendForm.visitorEmail.value;
        var friendsEmail = document.sendToFriendForm.friendsEmail.value;
        var message      = document.sendToFriendForm.message.value;
        document.cookie = "userEmail="+visitorEmail+";"
        var storeIdValue = document.sendToFriendForm.storeValue.value;
        var ajaxurl = "SendToAFriendCmd?storeId="+storeIdValue+"&visitorName="+visitorName+"&visitorEmail="+visitorEmail+"&friendsEmail="+friendsEmail+"&message="+message+"&url="+stringUrl;
        ajaxCall(ajaxurl,'showSendToFriend');
         
    return true;
}




//submitfinish function ends




// function for validating email //
function validateEmailAddress(tempemail,displayEmail){
var email1 = rtrim(tempemail);
var email =  ltrim(email1);
if(email == '' ){
        alert("Email address is required");
        return false;
}
var regex1 = /^[^\s@]+@([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]\.|[A-Za-z0-9]\.)+([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]|[A-Za-z0-9])$/;
var regex2 = /^(root@|abuse@|spam@)/;
if(!email.match(regex1)){
alert("The e-mail address you entered appears incorrect. (Example of a correct address: sears@sears.com.) Please check your information and try again.");
    return false;
} else if(email.match(regex2)){
alert(displayEmail + " is not allowed");
return false;
}else if(!checkEmailChar(email)){
    alert("The e-mail address you entered appears incorrect. (Example of a correct address: sears@sears.com.) Please check your information and try again.");
    return false;
}
return true;
}

// function to removespaces
function removeSpaces(string) {
var tstring = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
tstring += splitstring[i];
return tstring;
}


//Ajax call
var httpRequestSupported = true;

function ajaxCall(url,callbackFunction,returnData,linkId) 
{ 
    var httpRequest = false; 

    // Exit if this function is not supported
    if (!httpRequestSupported) {
        return;  
    }
    
    // check if supported
    httpRequest = isHttpRequestSupported();
    
    if (!httpRequest) { 
        httpRequestSupported = false;
        return false; 
    } 
   
    // Map the response to the callback function
    httpRequest.onreadystatechange = function() { 
        if (httpRequest.readyState == 4) {  
            if (httpRequest.status == 200) {
                if (returnData) { 
                    eval(callbackFunction + '(httpRequest.responseXML,linkId)'); 
                } else { 
                    eval(callbackFunction + '(httpRequest.responseText,linkId)'); 
                }  
            } else { 
                // TODO:  Keep this line commented in production.  The user will have no idea what this means.
                //('The AJAX request was made to our backend server and the following error occurred: ' + httpRequest.status); 
                eval(callbackFunction + '("")'); 
            } 
        }
        else{
            if(callbackFunction == 'displayTabContent'){
                
                htmlValue = "<img src= '"+ imagePath + "img/backgrounds/loading.gif' />";
                document.getElementById(linkId).innerHTML = htmlValue;
            }
            if(callbackFunction == 'browseSpecialOffer'){   
                htmlValue = "<img src= '"+ imagePath + "img/backgrounds/loading.gif' />";
                linkId.innerHTML = htmlValue;           
            }
        } 
    } 
    
    httpRequest.open('GET', url, true); 
    httpRequest.send(null); 
}

function isHttpRequestSupported() {

    if (window.XMLHttpRequest) {   
        // Test if the Gecko engine is running.  Gecko supports AJAX
        httpRequest = new XMLHttpRequest(); 
        if (httpRequest.overrideMimeType) { 
            httpRequest.overrideMimeType('text/xml'); 
        }  
    } else if (window.ActiveXObject) { 
        // Test if an IE engine is running
        try {      
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
        } catch (e) { 
            try {  
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
            } catch (e) {} 
        } 
    } 
     
    if (!httpRequest) { 
        httpRequestSupported = false;
    } 
    return httpRequest;
}



/* This function is for calling rebate controller command */

function openRebate(rebateId){
    
    var rebateDetail = 'RebateDetailsCmd?RebateId='+rebateId+'&storeId='+storeId;
    window.open(rebateDetail,'enlargedview','scrollbars=yes,titlebar=no,resizable=no,width=400,height=500');

}
// This function is for recently viewed items.

function compareRecentlyViewed()
{
    var a = document.compare.prodCount.value;
    var count=0;
    var anotherCount=0; 
        
    for (var i = 1; i <= a; i++){
      var object = 'document.compare.partNum'+i;
      var chkBox = eval(object);
                   
      if(chkBox.checked){
        count++;
      }
    }
 if(count<2){
   alert("You must check atleast 2 items to compare.");
 }
 if(count>=2){
    for (var j = 1; j <= a; j++){
    var object = 'document.compare.partNum'+j;
    var chkBox = eval(object);
    if(chkBox.checked){
    anotherCount++;
    //tempString = tempString + 'partNumber_'+count+'='+chkBox.value+'&';
    currentElement = document.createElement("input");
    currentElement.setAttribute("type", "hidden");
    currentElement.setAttribute("name", "partNumber_"+anotherCount);
    currentElement.setAttribute("id", "partNumber_"+anotherCount);
    currentElement.setAttribute("value", chkBox.value);
    document.tempform.appendChild(currentElement);
    
  }
 }
  // document.tempform.prodCount.value = count +'&'+tempString ;
  document.tempform.prodCount.value = count;
  document.tempform.submit();
  }
}
function uncheckAndSubmit(){
    var totalCount = document.compare.prodCount.value;
    for (var k = 1; k <= totalCount; k++){
      var object = 'document.compare.partNum'+k;
      var chkBox = eval(object);
      if(chkBox.checked){chkBox.checked=false;}
    }
    document.compare.submit();
}

// Pop Up Window //
function popUpWin(url,width,height){
   var newWin=window.open(url,'NewWindow','width='+width+',height='+height+',status=no,scrollbars=yes,resizable=yes,directories=no,menubar=no,toolbar=no,location=no');
   newWin.focus();
}

// Set up Row Grid switcher //
/*var Switch = {
    buttons : function(which){
        var changeButton=document.getElementById('changeButton');
        changeButton.firstChild.onclick=function(){
            switch(which){
                case "row" : Switch.row();Switch.buttons('grid');this.src="img/icons/switch_grid.gif";break;
                case "grid" : Switch.grid();Switch.buttons('row');this.src="img/icons/switch_row.gif";break;
            }
        }
    },
    grid : function(){
        var contentWrapper=document.getElementById('contentWrapper');
        contentWrapper.className="grid";
    },
    row  : function(){
        var contentWrapper=document.getElementById('contentWrapper');
        contentWrapper.className="row";
    }
};
addLoadEvent(
    function(){
        if(document.getElementById('subcategory') && document.getElementById('changeButton')){
            var contentWrapper=document.getElementById('contentWrapper');
            if(contentWrapper.className=="row"){ contentWrapper.className="grid"; Switch.row();Switch.buttons('grid');} 
            else if(contentWrapper.className=="grid"){ contentWrapper.className="row"; Switch.grid();Switch.buttons('row'); }
        }
    }
);*/

// Check the querystring for guidElms and if they exist load the delivery_guide.js //
if (window.location.search.match( "guide" )){
	$('head').append('\n<link rel="stylesheet" href="css/delivery_guide.css">\n<script type="text/javascript" src="js/delivery_guide.js"></script>\n<script type="text/javascript" src="js/ifxscrollto.js"></script>\n');
}

/*-------------------------------
        CENTER OBJECT ONTO SCREEN FOR MODALs
---------------------------------*/




function popupSubmit(){
              var storeId = document.getElementById("storeId").value;
              var langId = document.getElementById("langId").value;
              var catalogId = document.getElementById("catalogId").value;
              for (i=0;i<document.GRForm.registry.length;i++) 
              {
                if (document.GRForm.registry[i].checked) 
                { 
                    var extId = document.GRForm.registry[i].value;
                    if (extId == 'create'){
                      var cattId = '&catEntryId_1='+catEntryIdScim+'&quantity_1=1';
                      var rew = "~";
                      cattId = cattId.replace(/&/g,rew);
                      window.location = 'WeddingRegistryCreateView?storeId='+storeId+'&langId='+langId+'&catalogId='+catalogId+'&cattId='+cattId;
                    }
                    else{
                      onRegistry(extId);
                    }
                }
              }
              
              if (document.GRForm.registry.checked)
              {
                if (document.getElementById("registry").value == 'create')
                  {
                     var cattId = '&catEntryId_1='+catEntryIdScim+'&quantity_1=1';
                     var rew = "~";
                     cattId = cattId.replace(/&/g,rew);
                     window.location = 'WeddingRegistryCreateView?storeId='+storeId+'&langId='+langId+'&catalogId='+catalogId+'&cattId='+cattId;
                     
                  }
              }
     }

     function popupWishlistSubmit(){
              var storeId = document.getElementById("storeId").value;
              var langId = document.getElementById("langId").value;
              var catalogId = document.getElementById("catalogId").value;
              for (i=0;i<document.GRForm.registry.length;i++) 
              {
                if (document.GRForm.registry[i].checked) 
                { 
                    var extId = document.GRForm.registry[i].value;
                    if (extId == 'create'){
                       var cattId = '&catEntryId_1='+catEntryIdScim+'&quantity_1=1';
                      var rew = "~";
                      cattId = cattId.replace(/&/g,rew);
                      location.href = "WeddingWishListCreateView?storeId="+storeId+"&langId="+langId+"&catalogId="+catalogId+"&cattId="+cattId;
                    }
                    else{
                      onWishlist(extId);
                    }
                }
              }
              
              if (document.GRForm.registry.checked)
              {
                if (document.getElementById("registry").value == 'create') 
                  {
                      var cattId = '&catEntryId_1='+catEntryIdScim+'&quantity_1=1';
                     var rew = "~";
                     cattId = cattId.replace(/&/g,rew);
                     location.href = "WeddingWishListCreateView?storeId="+storeId+"&langId="+langId+"&catalogId="+catalogId+"&cattId="+cattId;
                  }
              }
     }

//Omniture tracking
function omnitureTracking(name) { 
    //Omniture tracking.
    if (typeof omPrefix != 'undefined') {
        omPrefix='Product Summary > '+name;
    }
    if (typeof s != 'undefined') {
        s.t();
    }
}

// SEND TO A FRIEND FUNCTIONS
function sendToFriend(ajaxUrl,a) { 
    
    omnitureTracking('sendToFriend');
    //Ajax call for executing the send to a friend
    ajaxCall(ajaxUrl,a);    
}





//Gets a cookie from the session based on the cookiename. if there is no cookie present an empty string is returned
function getCookie(cookieName)
{
    var cookieArray = document.cookie.split("; ");
    var searchString = cookieName+"=";
    var returnValue = '';

    for(var index = 0; index < cookieArray.length ; index++)
    {
        var cookie = cookieArray[index];
        var position = cookie.indexOf(searchString);

        if(position == 0)
        {
            var name_value = cookie.split("=");
            

            if(name_value[1] != '')
            {
                    returnValue = name_value[1];
            }
            else
            {
                returnValue = '';
            }

        }
    }
    return returnValue;
}

//Sets a cookie in the session based on the cookiename and cookievalue

function setCookie(cookieName,cookieValue)
{
    document.cookie = cookieName + "=" + cookieValue + ";";
}

/////////////////////////////////////////////////////////////
// xBrowser page dims (returns width height and scrolltop) //
/////////////////////////////////////////////////////////////

