/* Copyright TypingMaster, Inc. */

var showTimeout = 100;
var hideTimeout = 500;

var timeouts = new Array();

function show(id) {
    if (timeouts[id] != null) {
        window.clearTimeout(timeouts[id]);
    }
    timeouts[id] = setTimeout('doShow(\'' + id + '\')', showTimeout);
}
function hide(id) {
    if(timeouts[id] != null) {
        window.clearTimeout(timeouts[id]);
    }
    timeouts[id] = setTimeout('doHide(\'' + id + '\')', hideTimeout);
}
function showNow(id) {
    if (timeouts[id] != null) {
        window.clearTimeout(timeouts[id]);
    }
    doShow(id);
}
function hideNow(id) {
    if(timeouts[id] != null) {
        window.clearTimeout(timeouts[id]);
    }
    doHide(id);
}

function doShow(id) {
    hideAll();
    document.getElementById(id).style.visibility = "visible";
}
function doHide(id) {
    document.getElementById(id).style.visibility = "hidden";
}

function hideAll() {
    for (i = 0; i <= 5; ++i) {
        menuname = 'menu' + i;
        if(timeouts[menuname] != null) {
            window.clearTimeout(timeouts[menuname]);
        }
        
        var temp1 = document.getElementById(menuname);
        if (temp1 != null) {
            temp1.style.visibility = "hidden";
        }
        
    }
}
/* not used
function selectMenuItem(menuName) {
    var menuDiv =  document.getElementById("menu");
    
    var children = menuDiv.getElementsByTagName("p");
    for (i = 0; i < children.length; ++i) {
        children.item(i).style.backgroundColor = "transparent";
    }
    document.getElementById("menu_" + menuName).style.backgroundColor = "#CAF789";
}
*/

/* Functions for making popup windows */
function openPopup(url, name, width, height, x, y, addprops) {
	if ( width >= screen.width ) {
		width = Math.round((screen.width-x)*0.9);
	}
	if ( height >= screen.height ) {
		height = Math.round((screen.height-y)*0.9);
	}
	
    if(addprops == null) {
        addprops = "";
    }
    if(url == null || url == "") {
        return false;
    }
    else {
        myWindow = window.open(url, name,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',left='+x+',top='+y+',resizable=yes,scrollbars=yes'+addprops);
        myWindow.focus();
        return false;
    }
}

function formPopup(form, name, width, height, x, y, addprops) {
    return openPopup(form.go[form.go.selectedIndex].value, name, width, height, x, y, addprops);
}

function sposti(text, domain, address) {
	if (text == null) {
		text = address + "&#64;" + domain;
	}
	document.write("<a href=" + "mail" + "to:" + address + "&#64;" + domain + ">" + text + "</a>");
}

function doLoad() {
}

function getElement(elementName) {
    var elem;
    if (document.getElementById) {
        elem = document.getElementById(elementName);
    }
    else if(document.all) {
        elem = document.all[elementName];
    }
    
    if (elem != null) {
        return elem;
    }
    else { //fall back
        return document.getElementsByName(elementName)[0];
    }
}

function shareitOrderRedir(elemNum) {
	if (elemNum == null) {
		elemNum = 1;
	}
	delivery = getElement("delivery" + elemNum).value;
	product = getElement("product" + elemNum).value.split(";");
	backupCD = "";
	if (delivery == "cd") {
		if (product[0] == "300188947" || product[0] == "300189430") {
			backupCD = "&PRODUCT[300192597]=1";
		}
		else {
			backupCD = "&PRODUCT[156430]=1";
		}
	}
	orderLink = "/goto/ordering/shareit-direct.asp?PRODUCT[" + product[0] + "]=1" + backupCD + 
	"&language=" + product[1] + "&currencies=" + product[2];
	
	createCookie("tmorder","from=" + document.location, 10);
	pageTracker._link(orderLink);
}

function trackerLink(orderLink) {
	createCookie("tmorder","from=" + document.location, 10);
	pageTracker._link(orderLink);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
