﻿
//hover for IE

 
	sfHover = function() {
	
	
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");			

		for (var i=0; i<sfEls.length; i++) {				    
		   
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";						

			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	
	
	if (window.attachEvent) window.attachEvent("onload", sfHover);

	tdHover = function() {
	
	
		var tdels = document.getElementById("ctl00_MainColumn_catalogTable").getElementsByTagName("TD");			

		for (var i=0; i<tdels.length; i++) {				    
		   
			tdels[i].onmouseover=function() {
				this.className+=" tdHover";						

			}
			tdels[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" tdHover\\b"), "");
			}
		}
	}
	
	
	//if (window.attachEvent) window.attachEvent("onload", tdHover);



    
    function previewCheckChanged(addtoCartButton, checked, detailConfirmCheck)
    {

        btn = document.getElementById(addtoCartButton); 
        ck = document.getElementById(detailConfirmCheck); 


        if (checked == true) {
        //btn.disabled = false;
        ck.checked = true;
        document.getElementById('ctl00_MainColumn_Tabs_Panel4_chk_Confirm').checked = true;
        }
        else
        {
        //btn.disabled = true;
        ck.checked = false;
        document.getElementById('ctl00_MainColumn_Tabs_Panel4_chk_Confirm').checked = false;
        }

    }  
    
    function changeImg(NewimgSrc, AltImgName, numImg)
    {
    document["Img_detail"].src = NewimgSrc;
    }
   /* for (var i = 0; i < numImg; i++)
    {
    var iname = "altimg_" + i;
    //document.getElementById(iname).style.border = "";    
    }      
    
    //document.getElementById(AltImgName).style.border = "1px solid red";  
    }*/
    
    
 

        //set class name of paragraphy to whatever the style

        function onOk() {

            alert('cool');
        }

         function PanelClick() {

            alert('tab clicked');

        }

function validateCheckbox(lbl, controlListLbl, lblgenericErrormsg, checkckconfirm)
 { 
 
 // add the checkckconfirm variable so that we can either check the confirm the personalization checkbox or not
 // so that we can use the same function for the preview button

// this function now validates all the required item options, as well as the confirm personalization checkbox


 // check to see that the confirm personalization check box is checked
  lblText = document.getElementById(lbl);
  errorMsg = document.getElementById(lblgenericErrormsg);
  
  if (errorMsg == null) {
    errorMsg = 'Error'
  }
  allgood = true;
  
   if ((document.getElementById('ctl00_MainColumn_Tabs_Panel4_chk_Confirm').checked == false) && (checkckconfirm == true))
        { 
        
            //alert(lblText.innerHTML);
            allgood = false;
          // document.getElementById('show_noshow').style.visibility ='visible';
        }
        else
        {
                        
           // access the label that contains the names of the required fields
           lblControlNames = document.getElementById(controlListLbl);
           
           // break the list apart into an array
           controls = lblControlNames.innerHTML.split(",");
           
           
           
           // loop through and check the rest of the controls
            
           numcontrols = controls.length;
           
           for (var x = 0; x < numcontrols; x++)
           {
           
                //alert(controls[x]);
            
                // check and see what type of control it is, using the value from the hidden field need to switch the name up a bit
            
                typeofControlLabel = controls[x].split("_");            
         
                var str2 = typeofControlLabel[0] + "_" + typeofControlLabel[1] + "_Type";
           
                //alert(str2 + " , Item_Option1_Type");
           
                   
                // check to see if the option can be found
                if (document.getElementsByName(str2) != null) {
            
                    TypeofControl = document.getElementsByName(str2);   
                    
                    strTypeofControl = ""
                    
                    if (TypeofControl != null) {
                    //alert(TypeofControl);
                            
                        strTypeofControl = TypeofControl[0].value;
                    //alert(strTypeofControl);
                    }
                    // having an issue if the name of the control has a space
                       
                        switch (strTypeofControl.toLowerCase())
                        {
                        case 'dropdown' : 
                            dd = document.getElementById('ctl00_MainColumn_Tabs_Panel4_' + controls[x]);
                            VARselectedIndex = dd.selectedIndex;
            
                                if (VARselectedIndex == 0) {
                                    //alert('dropdown required ' + controls[x]);
                                    //alert(errorMsg.innerHTML);
                                    allgood = false;
                                    }                                
                            break;
            
                      case 'radio': 
                        //alert('radio');
                            rbl = document.getElementsByName('ctl00$MainColumn$Tabs$Panel4$' + controls[x]);
                            var BoolCheck = false;
                            var numradios = rbl.length;            
           
                            for (var i = 0; i < numradios; i++)
                                if (rbl[i].checked)
                                BoolCheck = true;
                                //alert('true');
                      
                            if (BoolCheck == false)  {
                                //alert('no radio buttons selected'); 
                                //alert(errorMsg.innerHTML);
                                allgood = false;
                                }
                                
                            break;
            
                        case 'checkbox':
                            // not sure if checkboxes should be required, do last                             
                            cbl =    document.getElementsByName('ctl00$MainColumn$Tabs$Panel4$' + controls[x]);   
                            var BoolCheck = false;
                            var numcbs = cbl.length;            
                            
                            for (var i = 0; i < numcbs; i++)
                                if (cbl[i].checked)
                                BoolCheck = true;
                
                            if (BoolCheck == false) {
                               // alert('nothing is checked'); 
                                //alert(errorMsg.innerHTML);
                                allgood = false;
                                }   
                        case 'textbox' : 
                            tx = document.getElementById('ctl00_MainColumn_Tabs_Panel4_' + controls[x]);
                            
                            if (tx.value == '' || tx.value == null) {
                                allgood = false;
                            }
                                   
                        } // end switch
            
                } // end if object found
             
            } // end for loop
                  
           
          
      
       } // end if the confirm personalization checkbox is checked
          
    
    //return allgood;
   
    
     if (allgood == true)      { 
     return true;
     }
     else
     {
     alert(errorMsg.innerHTML);
     return false;
     }
     
     
     } // end function


function validateCheckboxOld(lbl)
 { 

  
   if (document.getElementById('ctl00_MainColumn_Tabs_Panel4_chk_Confirm').checked == false)
        {
        lblText = document.getElementById(lbl);
        
            alert(lblText.innerHTML);
            return false;
          // document.getElementById('show_noshow').style.visibility ='visible';
        }else{
            return true;
           //document.getElementById('show_noshow').style.visibility ='hidden';
      
       }
 }       
 
 function validateCheckbox2(lbl)
 { 

  
   if (document.getElementById('ckConfirmPreview').checked == false)
        {
         lblText = document.getElementById(lbl);
         
            alert(lblText.innerHTML);
            return false;
          // document.getElementById('show_noshow').style.visibility ='visible';
        }else{
           
            return true;
           //document.getElementById('show_noshow').style.visibility ='hidden';
      
       }
  
 }
 

 
 	menubar = function() {
	
  var dnode=document.getElementById('mainnav');
alert(dnode.ID);	
dnode.insertAdjacentHTML("afterEnd", '<IFRAME style="position: absolute;z-index:4; filter:alpha(opacity=0);" src="javascript:false;" frameBorder="0" scrolling="no" id="_hvrShm" />');
var iframeShim = document.getElementById("_hvrShm");

iframeShim.style.top = dnode.style.top;
iframeShim.style.left = 300;
iframeShim.style.width = dnode.offsetWidth;
iframeShim.style.height = 300;
	 }

function showMoreCapLines()
 // this function depends on the style sheet being loaded in a specific order in store.master, if it is not working try changing the
 // index of the style sheet until you get the right one
 
 {
 document.styleSheets[3].disabled = true; 
 }
 
 function NewWindow(mypage,myname,w,h,scroll,resizable)
    {
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
		var settings ='height='+h+',';
		settings +='width='+w+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		settings +='scrollbars='+scroll+',';
		settings +='resizable=no';
		childWindow=window.open(mypage,myname,settings);
		childWindow.window.focus();
	}

//  MOD BY ALICIA -- OCT 19th 2009, functions for expanding menus
//  when the menu is created the first five items have the css class 'SHOW' anyother categories have the class 'HIDE'
//  when the 'show more' link is clicked the css class is changed on the hidden items and the class of the show more link
//  is also changed to hide it.

//  cookies are set to keep track of which categories have been expanded so that we can re-expand them when the page is re-loaded

//  the expand funciton is called on the bottom of the master page
 
//  The class is added in the stored procedure, to change the number of items that are displayed when the menu is
//  collapsed alter spGetSideNavList


function showListItems(strName)
{


a = document.getElementsByName('sideNav_' + strName );
numItems = a.length;

// set a cookie so we can leave this list expanded when the page refreshes

setCookie('sideNav_' + strName, strName, 1);

for (var i = 0; i < numItems; i++)
    {
    a[i].className = 'SHOW';
    a[i].parentNode.className = 'SHOW';
    }

lnk = document.getElementById('LnkMore_' + strName);
lnk.className = 'HIDE';

//lbl = document.getElementById('ctl00_PerzySideNav_lblExpandedIDs');
//lbl.innerHTML = lbl.innerHTML + " ," + strName;
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate());
/*exdate.setDate(exdate.getDate()+expiredays);*/
var minutes = exdate.getMinutes();
minutes += 1;           // Add 30 minutes to the time
exdate.setMinutes(minutes); // Reset to new value

document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
//alert("setcookie" + c_name);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function ExpandLists()
{

parentItems = document.getElementsByName('ParentCategoryIds');
numItems = parentItems.length;

for (var c = 0; c < numItems; c++)
    {
    
//alert("sideNav_" + parentItems[c].innerHTML);

var strCatID = getCookie("sideNav_" + parentItems[c].innerHTML)

//alert(strCatID);

    if (strCatID!=null && strCatID!="")
    {    
    showListItems(strCatID)
    }   
    }


}


// function that controls the image rotator on the home page

 function ShowNextImage()
{


ItemImages = document.getElementsByName('rotatorImage_Img');
numItems = ItemImages.length;

var ShowNext = false;


for (var c = 0; c < numItems; c++)
    {
   
    if (ShowNext == false)
        {    
        //alert(ShowNext);
        if (ItemImages[c].parentNode.className == 'SHOW')
            {
           // alert("Found one");
           
            ItemImages[c].parentNode.className = 'HIDE';
            ShowNext = true;       
            
            // check to see if this is the last item in the loop, if so make the first one show
            if ((c + 1) == numItems)
                {
                ItemImages[0].parentNode.className = 'SHOW';
                }
            
            } // end if class == 'SHOW'
        
        }
        else
        {   //alert(ShowNext);
           
            ItemImages[c].parentNode.className = 'SHOW';
            ShowNext = false;  
        }
    } // end for


}