﻿  //change search div properties
  //to handle GUI problems in case of serach and size chart popup on same page[Start]
    $('topNav').style.position='relative';
     document.getElementById('topNav').style.zIndex='9998'
     $('DivShopActive').style.left='-33px';
    $('searchDiv').style.left='460px';
    //Removing style from the main div for size chart
    $('wrapper').removeAttribute('style');
  //to handle GUI problems in case of serach and size chart popup on same page[END]
  

 //to adjust width of size chart popup [start]
//Visible window width
var getWindowWidth=function(){return window.offsetWidth||document.body.clientWidth;};
//Visible window height
var getWindowHeight=function(){return window.offsetHeight||document.body.clientHeight;};
//Visible window width + scroll
var getTotalWidth=function(){return (window.innerWidth+window.scrollMaxX)||document.body.clientWidth;};
//Visible window height + scroll
//var getTotalHeight=function(){return (window.innerHeight+window.scrollMaxY)||document.body.clientHeight;};
var getTotalHeight=function(){
    if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
//		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
//		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
//		xWithScroll = document.body.offsetWidth;
	}
	return yWithScroll;
};

//Scrollable width
var getScrollWidth=function(){return getTotalWidth()-getWindowWidth();};
//Scrollable height
var getScrollHeight=function(){return getTotalHeight()-getWindowHeight();};
// Distance scrolled from top
var getScrollTop=function(){return document.documentElement.scrollTop||document.body.scrollTop;};
// Distance scrolled from top
var getScrollLeft=function(){return document.documentElement.scrollLeft||document.body.scrollLeft;};
// Get total occupied width of element
var getOffsetWidth=function(obj){return obj.offsetWidth;};
// Get total occupied height of element
var getOffsetHeight=function(obj){return obj.offsetHeight;};



var popupState='closed';
var scWindow=new Object();
var popupActive='';
var currentTotalHeight=0;
var currentTotalWidth=0;
/***** GET THE FUNCTIONS STARTED *****/
scWindow.Start=function(popupId){
// Activate the popup
scWindow.Open(popupId);
// Record the current total height of the window
currentTotalHeight=getTotalHeight();
currentTotalWidth=getTotalWidth();
// On resizing the page, run this function to reset the values
Event.observe(window,'resize',function(){scWindow.Change();});
}
/***** VERTICALLY ALIGN CENTRE THE CONTENT *****/
scWindow.contentPos=function(){
$(popupActive).show();
// How far down the content area needs to go
var windowHeightHalf=(getWindowHeight()/2);
var contentHeightHalf=(getOffsetHeight($('sc_content'))/1.3);
// How far across the content area needs to go
var windowWidthHalf=(getWindowWidth()/2);
var contentWidthHalf=(getOffsetWidth($('sc_content'))/2);
// Set the values in the CSS
$('sc_content').style.top=(windowHeightHalf-contentHeightHalf)+'px';
//Set the default top in case the top having negative value.
var sc_contenttop=(windowHeightHalf-contentHeightHalf);
if(sc_contenttop<0)
    $('sc_content').style.top='20px';
$('sc_content').style.left=(windowWidthHalf-contentWidthHalf)+'px';
}
/***** OPEN / CLOSE THE POPUP WINDOW *****/
scWindow.Open=function(popupId){
if(popupState=='closed'){
    popupActive=popupId;
    // Reveal the outermost area of the popup
    $('sc_area').show();
    $('sc_area').style.width='100%';
    $('sc_area').style.height=getTotalHeight()+'px';
    // Begin to show the faded popup background
    new Effect.Appear('sc_bg',{beforeStart:function(){
        // Set the background width and height
        if (DetectResult()=="Firefox")//k.singh | xplid: 113682 | Bug#8457- fixed
            $('sc_bg').style.width='100%';
        else
            $('sc_bg').style.width=getTotalWidth()+'px';
        $('sc_bg').style.height=getTotalHeight()+'px';},
    duration:0.5,from:0,to:0.40,afterFinish:function(){
        new Effect.Appear('sc_content',{beforeStart:function(){
            // Centre the content area in the window
            // Timeout allows the element a chance to activate, otherwise positioning would be impossible
            setTimeout('scWindow.contentPos()',50);},
        duration: 0.5,from:0,to:1,afterFinish:function(){
            // If anywhere outside of the content area is clicked, close the popup
            Event.observe($('sc_bg'),'click',scWindow.Close);}})}})
    popupState='open';
}else{
    // Firstly fade the content
    new Effect.Fade('sc_content',{duration:0.5,from:1,to:0,afterFinish:function(){
        $(popupActive).hide();
        // Then fade the background
        new Effect.Fade('sc_bg',{duration:0.5,from:0.40,to:0,afterFinish:function(){
            $('sc_area').hide();
            popupActive='';
            popupState='closed';}})}})}
}
/***** CLOSE THE POPUP IF CLICKED OUTSIDE THE CONTENT AREA *****/
scWindow.Close=function(e){
var theElement=Event.element(e);
// Rerun the main function to close the popup only if the background is clicked
if(theElement.id=='sc_bg'){scWindow.Open();}
}
/***** RESET VALUES WHEN THE PAGE RESIZES OR CHANGES *****/
scWindow.Change=function(){
// Reset window height settings
setTimeout('scWindow.ChangeHeight()',50);
}
scWindow.ChangeHeight=function(){
// Reset height values
if(currentTotalHeight>getWindowHeight()){$('sc_bg').style.height=getTotalHeight()+'px';$('sc_area').style.height=getTotalHeight()+'px';
}else{$('sc_bg').style.height= getWindowHeight()+'px';$('sc_area').style.height=getWindowHeight()+'px';}
// Reset window width settings
setTimeout('scWindow.ChangeWidth()',100);
}
scWindow.ChangeWidth=function(){
// Reset width values
$('sc_bg').style.width='100%';
$('sc_area').style.width='100%';
// Reset content area position
scWindow.contentPos();
}

 //to adjust width of size chart popup [END]



//on click of thumbnail images change big image and zoom image[start]

// <![CDATA[
function MouseOver(imgID,bigimgID){
try
{
    var imgUrl=document.getElementById(imgID).src.replace("_thumb","");
    var ImageVar=document.getElementById(bigimgID);
    ImageVar.src=imgUrl;
     zoomimage(bigimgID);
}
catch(ex){}
}
function zoomimage(bigimgID)
    {
    try{
        var mainImg=document.getElementById(bigimgID);
        var imgZoom=document.getElementById('zoom_image');
        var imgSrc=mainImg.src;
        imgZoom.src=imgSrc.toLowerCase().replace(".jpg","_zoom.jpg")
        }catch(ex){}
    }
//on click of thumbnail images change big image and zoom image[END]

//[k.singh][20091222][xplid:112379][Update panel problem: Re-enable the AddtoCart button]
function DisableButton(btnAddToCart){try{ var btnAdd2Cart = document.getElementById(btnAddToCart);btnAdd2Cart.disabled = true; }catch(ex){}}
function EnableButton(btnAddToCart){try {var btnAdd2Cart = document.getElementById(btnAddToCart);btnAdd2Cart.disabled = false;}catch(ex){}}

//show hide specification panels[Start]
function showHideSpecificationPanels(DescPanel,MatPanel)
{
try{
        /***** Show/hide panels  *****/
    var hdnDesc = $(DescPanel);
    var hdnMat = $(MatPanel);
  
    if(hdnDesc.value == 1 && hdnMat.value == 0)//if description has contents but material not
        {
            $('uxDescptionOnly').style.display='block';
            $('uxMaterialOnly').style.display='none';
            $('uxDescMat').style.display='none';
            $('tab_content1').style.display='block';
            $('tab_content2').style.display='none';            
        }
    else if (hdnDesc.value == 0 && hdnMat.value == 1)//if description has no contents but material has
        {
            $('uxDescptionOnly').style.display='none';
            $('uxMaterialOnly').style.display='block';
            $('uxDescMat').style.display='none';
            $('tab_content1').style.display='none';
            $('tab_content2').style.display='block'; 
        }
    else if (hdnDesc.value == 0 && hdnMat.value == 0)//if both having no contents
        {
            $('uxDescBox').style.display='none'; 
        }
    
/***** CONTENT SWITCH *****/	
	var activeLink	= 'tab_link1';
	var activeDiv	= 'tab_content1';
	
	detailsSwitch = function(itemId) {
		if('tab_link' + itemId != activeLink) {
		// Reset active properties
			$(activeLink).className = '';
			$(activeDiv).hide();
		
		// Set the new elements active
			$('tab_link' + itemId).className = 'selected';
			$('tab_content' + itemId).show();
			
		// Reset active variables to new
			
			activeLink	= 'tab_link' + itemId;
			activeDiv	= 'tab_content' + itemId;
		}
	}
}catch(ex){}
}

//show hide specification panels[END]