﻿function WarningMessage(whichMessage)
{
    if (whichMessage =="SIP")
    {
    var SIP_warningMessage;
    //SIP_warningMessage = confirm("This product can only be ordered seperately. If you add this item to your basket all existing basket items will be deleted.");
    SIP_warningMessage = "WARNING:This product should be ordered seperately. If you add this item to your basket all existing basket items will be deleted.";
    alert(SIP_warningMessage);
    }
}
function ShowContent(divId, obj, classNameB){

	for(i = 0; i < document.getElementsByTagName('div').length; i++){
		var objDiv = document.getElementsByTagName('div')[i];
		if(objDiv.id != null && objDiv.id.indexOf('divContent') != -1){
			objDiv.style.display = 'none';
		}
	}
	
	for(i = 0; i < document.getElementsByTagName('td').length; i++){
		var objDiv = document.getElementsByTagName('td')[i];
		if(objDiv.className != null && (objDiv.className != 'productSpecs' && objDiv.className.indexOf('productSpecs') != -1)){
			objDiv.className = 'productSpecs';
		}
	}
	
	document.getElementById(divId).style.display = '';
	obj.className = classNameB;
}

function HeadRollBut(obj, state){
    switch(state){
        case "out":
            obj.className = 'topMenuBut01';
            break;
        case "over":
            obj.className = 'topMenuBut02';
            break;
    }
}

var autoShowSubSubMenuObj = null;
var autoShowSubSubMenuID = null;
var autoShowSubSubMenuTimeOut = null;
function SubMenuRollOver(obj, state, subMenuId) {
    switch (state) {
        case "out":
            if (autoShowSubSubMenuTimeOut != null)
                self.clearTimeout(autoShowSubSubMenuTimeOut);
            if (lastParentTD != obj.offsetParent)
                obj.offsetParent.className = '';
            break;
        case "over":
            obj.offsetParent.className = 'SubMenuBut01';
            if (subMenuId != null) {
                autoShowSubSubMenuObj = obj;
                autoShowSubSubMenuID = subMenuId;
                if (autoShowSubSubMenuTimeOut != null)
                    self.clearTimeout(autoShowSubSubMenuTimeOut);
                autoShowSubSubMenuTimeOut = self.setTimeout('AutoShowSubSubMenu()', 500);
            }
            break;
    }
}

function AutoShowSubSubMenu() {
    if (lastSubPopupOpended == null || lastSubPopupOpended != autoShowSubSubMenuID) {
        ShowSubMenu(autoShowSubSubMenuObj, autoShowSubSubMenuID);
    }
    autoShowSubSubMenuTimeOut = null;
}

function SubSubMenuRollOver(obj, state) {
    switch (state) {
        case "out":
            obj.className = 'SubSubMenuBut01';
            break;
        case "over":
            obj.className = 'SubSubMenuBut02';
            break;
    }
}

var lastSubPopupOpended = null;
var closeLastOpendMenu = null;
var lastParentTD = null;
var fadeIn = 0;
var fadeInTimeout = null;

function ShowSubMenu(obj, menuId){
    if(closeLastOpendMenu != null)
        self.clearTimeout(closeLastOpendMenu);

    if (lastSubPopupOpended != null && lastSubPopupOpended != menuId) {
        document.getElementById(lastSubPopupOpended).style.display = 'none';
        lastParentTD.className = '';
    }

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
    //var IE = document.all?true:false

    if (lastSubPopupOpended != menuId) {

        if (fadeInTimeout != null) {
            self.clearInterval(fadeInTimeout);
            fadeInTimeout = null;
        }

        var ie = (document.all) ? 1 : 0;
        var p = (ie) ? "filter" : "MozOpacity";
        var v = 0; fadeIn = 0;
        v = (ie) ? "alpha(opacity=" + v + ")" : v / 100;


        obj.offsetParent.className = 'SubMenuBut01';

        var objMenuDiv = document.getElementById(menuId);
        objMenuDiv.style.position = 'absolute';
        objMenuDiv.style[p] = v;

        objMenuDiv.style.display = '';
        var parentWidth = obj.offsetWidth + 16;
        var menuWidh = (objMenuDiv.offsetWidth - parentWidth) / 2;
        objMenuDiv.style.left = fGetRealLeft(obj.offsetParent) - menuWidh + 'px';
        objMenuDiv.style.top = fGetRealTop(obj.offsetParent) + obj.offsetParent.offsetHeight - 2 + 'px';

        lastParentTD = obj.offsetParent;
        lastSubPopupOpended = menuId;
        closeLastOpendMenu = self.setTimeout('CloseSubPopupMenu()', 5000);
        fadeInTimeout = self.setTimeout('FadeIN()', 15);
    }
}

function FadeIN() {
    if (lastSubPopupOpended != null) {
        fadeIn += 10;
        if (fadeIn <= 100) {
            var ie = (document.all) ? 1 : 0;
            var p = (ie) ? "filter" : "MozOpacity";
            var v = fadeIn;
            v = (ie) ? "alpha(opacity=" + v + ")" : v / 100;
            var objMenuDiv = document.getElementById(lastSubPopupOpended);
            objMenuDiv.style[p] = v;
            fadeInTimeout = self.setTimeout('FadeIN()', 15);
        }
    }
}

function StopSubPopupClose(){
    if(closeLastOpendMenu != null)
        self.clearTimeout(closeLastOpendMenu);
} 
function StartSubPopupClose(){
    closeLastOpendMenu = self.setTimeout('CloseSubPopupMenu()', 1000);
}
function CloseSubPopupMenu(){
    document.getElementById(lastSubPopupOpended).style.display = 'none';
    lastParentTD.className = '';
    lastParentTD = null;
    lastSubPopupOpended = null;
}

function fGetRealTop(objElem) {
	yPos = eval(objElem).offsetTop;
	tempEl = eval(objElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function fGetRealLeft(objElem) {
	yPos = eval(objElem).offsetLeft;
	tempEl = eval(objElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft, curtop];
    }
}

function iBurstNext(divId) {
    for (i = 0; i < document.getElementsByTagName('div').length; i++) {
        var objDiv = document.getElementsByTagName('div')[i];
        if (objDiv.id != null && objDiv.id.indexOf('divContent') != -1) {
            objDiv.style.display = 'none';
        }
    }

    document.getElementById(divId).style.display = '';
    if (divId = 'divContentG') {
        document.getElementById(divId).visible = true;
    }
}
