﻿if (top.frames.length > 0) top.location.href = location.href;

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 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_findObj(n, d) { //v4.0
	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 && document.getElementById) x=document.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_displayStatusMsg(msgStr) { //v1.0
    status=msgStr;
    document.MM_returnValue = true;
}

function setAddtoBagProductID(productID) {
    document.getElementById("addtoBagProductID").value = productID;
}

function emailLink(username,hostname,suffix, displaytext, emailclass) {
    if (displaytext=='') displaytext = username + "@" + hostname + "." + suffix;
	document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + "." + suffix +" class='" + emailclass + "'>" + displaytext + "</a>")
}
function showloginDialog() {
    document.getElementById("popupbox-login").style.display = "inline";
}

function getCookie(NameOfCookie) {
	if (document.cookie.length > 0) {              
		var begin = document.cookie.indexOf(NameOfCookie+"=");       
		if (begin != -1) {   
			var end = -1;        
			begin += NameOfCookie.length+1;
			var endAmpersand = document.cookie.indexOf("&", begin);
			var endSemiColon = document.cookie.indexOf(";", begin);
			if (endAmpersand == -1) 
				end = endSemiColon;
			else
				end = endAmpersand;
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		} 
	}
	return "";
}

var largeImageDiv = null;
function ViewLargeProduct(ProductID,BrandID) {
    winHeight = "460px"
    winWidth = "350px"

    if (largeImageDiv == null) {
        largeImageDiv = document.createElement("div");
        largeImageDiv.id = "largeImageDiv";
        largeImageDiv.className = "dialog";
        largeImageDiv.style.background = "#ffffff";
        largeImageDiv.style.height = winHeight;
        largeImageDiv.style.width = winWidth;
        largeImageDiv.style.display = "none";
        largeImageDiv.style.padding = "0";
    }
//window.open ('/viewImageLarge.aspx?ProductID=' + ProductID + '&BrandID=' + BrandID);

	largeImageDiv.innerHTML = '<iframe src="/viewImageLarge.aspx?ProductID=' + ProductID + '&BrandID=' + BrandID + '" style="width:' + winWidth + ';height:' + winHeight + ';" frameborder="0" scrolling="no" scrollbars="no"></iframe>';
    document.body.appendChild(largeImageDiv);
	show_modal_dialog("largeImageDiv");	
}
var GiftsetImageDiv = null;
function ViewGiftsetPopup(ProductID) {
    winHeight = "560px"
    winWidth = "400px"

    if (GiftsetImageDiv == null) {
        GiftsetImageDiv = document.createElement("div");
        GiftsetImageDiv.id = "GiftsetImageDiv";
        GiftsetImageDiv.className = "dialog";
        GiftsetImageDiv.style.background = "#ffffff";
        GiftsetImageDiv.style.height = winHeight;
        GiftsetImageDiv.style.width = winWidth;
        GiftsetImageDiv.style.display = "none";
        GiftsetImageDiv.style.padding = "0";
    }
//window.open ('/ViewImageLargeGiftset.aspx?ProductID=' + ProductID);

	GiftsetImageDiv.innerHTML = '<iframe src="/ViewImageLargeGiftset.aspx?ProductID=' + ProductID + '" style="width:' + winWidth + ';height:' + winHeight + ';" frameborder="0" scrolling="no" scrollbars="no"></iframe>';
    document.body.appendChild(GiftsetImageDiv);
	show_modal_dialog("GiftsetImageDiv");	
}

function LoginClick(objBtn) {
    objBtn.blur();
    objBtn.src='/images/btn_pleasewait.gif'; 
    if (Login_lblerror) Login_lblerror.style.visibility = "hidden";
}
var deliveryMethodDropDown=null;
function loginClientClick() {
    if (deliveryMethodDropDown) showHideDeliveryDropDown('hide');
}
function showHideDeliveryDropDown(showHide) {     
    if (showHide == 'hide') {
        if( Login_loginPanel && (deliveryMethodDropDown.style.visibility == 'visible' || deliveryMethodDropDown.style.visibility =='')) {
            if(deliveryMethodPageTop && deliveryMethodPageTop <350) {
                deliveryMethodDropDown.style.visibility = 'hidden';
                window.setTimeout("showHideDeliveryDropDown('show')", 25);
            }   
        }
        else 
            window.setTimeout("showHideDeliveryDropDown('hide')", 25);
    }
    if (showHide == 'show') {
        if(Login_loginPanel)
            window.setTimeout("showHideDeliveryDropDown('show')", 25);
        else
            if(deliveryMethodDropDown.style.visibility == 'hidden')
                deliveryMethodDropDown.style.visibility = 'visible';
    }
}

function ToolTipLink(MouseEvent, ElemId) {
    if(MouseEvent == "Over")
        window.status="What's this?";
    else
        window.status="";
		
    if(document.all) {
	
        Elem = document.all(ElemId)
	
        if(MouseEvent == "Over") {
            Elem.style.cursor='help';
            Elem.style.textDecorationUnderline = true;
        }
        else
            Elem.style.textDecorationUnderline = false;
    }
}

function getOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent)!=null) ot+=el.offsetTop;return ot;}
function getPageTop(layer){
    var y;
    y=0;
    while(layer.offsetParent!=null){
        y+=layer.offsetTop;
        layer=layer.offsetParent;
    }
    y+=layer.offsetTop;
    return y;
}

function ShowPleaseWait(image) {
    image.src='/images/btn_pleasewait.gif';
}

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;
}
//alert(pageWidth + " || " + pageHeight + " || " + windowWidth + " || " + windowHeight);
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
 
function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
 //Netscape compliant
 scrOfY = window.pageYOffset;
 scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
 //DOM compliant
 scrOfY = document.body.scrollTop;
 scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
 //IE6 standards compliant mode
 scrOfY = document.documentElement.scrollTop;
 scrOfX = document.documentElement.scrollLeft;
}
return [ scrOfX, scrOfY ];
}

function getWindowXY() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}