// JS basics for nikewomen.com
// author : Kim Jensen
// created : 15.01.2004

// browsercheck...
var NN403 = false;
var NN405 = false;
var NN47 = false;
var NN6 = false;
var NN4X = false;
var NNX = false;
var IE5 = false;
var IE55 = false;
var IE6 = false;
var IE5plus = false;
var IEX = false;
var safari = false;
var Mac = false;
var Win = false;
var WinXP = false;
var firefox = false;

NN403 = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.appVersion.indexOf('4.03')>-1)) ? true : false;
NN405 = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.appVersion.indexOf('4.05')>-1)) ? true : false;
NN47 = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.appVersion.indexOf('4.7')>-1)) ? true : false;
NN6 = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.appVersion.indexOf('5.0')>-1) && (navigator.appVersion.indexOf('4.')==-1)) ? true : false;
NN4X = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.appVersion.indexOf('4.')>-1)) ? true : false;
NNX = (navigator.appName.indexOf('Netscape')>-1) ? true : false;

IE5 = ((navigator.appName.indexOf('Microsoft')>-1) && (navigator.appVersion.indexOf('MSIE 5.0')>-1)) ? true : false;
IE55 = ((navigator.appName.indexOf('Microsoft')>-1) && (navigator.appVersion.indexOf('MSIE 5.5')>-1)) ? true : false;
IE6 = ((navigator.appName.indexOf('Microsoft')>-1) && (navigator.appVersion.indexOf('MSIE 6.0')>-1)) ? true : false;
IE5plus = ((navigator.appName.indexOf('Microsoft')>-1) && (navigator.appVersion.slice(navigator.appVersion.indexOf('MSIE')+5,navigator.appVersion.indexOf('MSIE')+6)) <= 5) ? true : false;
IEX = (navigator.appName.indexOf('Microsoft')>-1) ? true : false;

safari = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.appVersion.indexOf('Safari')>-1)) ? true : false;
firefox = ((navigator.appName.indexOf('Netscape')>-1) && (navigator.userAgent.indexOf('Firefox')>-1)) ? true : false;

Win = (navigator.platform.indexOf('Win32')>-1) ? true : false;
WinXP = (navigator.userAgent.indexOf('NT 5.1')>-1) ? true : false;
Mac = (navigator.platform.indexOf('Mac')>-1) ? true : false;

// window.open function...
function makePop(windowPosX,windowPosY,windowName,url,name,w,h,extra){
	var titlebarHeight = 28; // titlebar + chrome at bottom on a standard IE5 on a Win2kPro installa. // Used for correct centering of pop...
	str="height="+h+",width="+w+","+extra;
	if(parseInt(navigator.appVersion)>3)
		if (windowPosX == -1) {
			str+=",left="+(screen.width -w)/2+",top="+parseInt(((screen.height -h)-titlebarHeight)/2);
		}
		else {
			str+=",left="+windowPosX+",top="+windowPosY;
		}
	var k = eval(windowName + "=window.open('" + url + "','" + name + "','" + str + "')");
	if (k) {
	 	k.focus();
		return k;
	}
}

// Writes to a layer...
function writeLayer(which, content) {
   if (NN4X) {
       document[which].document.open();
       document[which].document.write(content);
       document[which].document.close();
   } else if (IEX) {
	   document.all[which].innerHTML = content;
	}
	else {
		document.getElementById(which).innerHTML = content;
	}
}

// moves a layer...
function moveLayerTo(theLayer,x,y) {
	if (IEX) {
		document.all[theLayer].style.left = x;
		document.all[theLayer].style.top = y;
	}
	else if (NN4X) {
		eval('document.'+theLayer+'.left = x;');
		eval('document.'+theLayer+'.top = y;');
	}
	else {
		document.getElementById(theLayer).style.left = x;
		document.getElementById(theLayer).style.top = y;
	}
}

// shows a layer...
function showLayer(which) {
	if (IEX) {
		document.all[which].style.visibility = 'visible';
	}
	else if (NN4X) {
		document[which].visibility = 'visible';
	}
	else {
		document.getElementById(which).style.visibility = 'visible';
	}
}

// hides a layer...
function hideLayer(which) {
	if (IEX) {
		document.all[which].style.visibility = 'hidden';
	}
	else if (NN4X) {
		document[which].visibility = 'hidden';
	}
	else {
		document.getElementById(which).style.visibility = 'hidden';
	}
}

// Image position functions...
// ---------------------
// Ask for image-position:
function ysPos(what){
	if(IEX){
		return yIE(eval('document.'+what));
	}
	else if(NN4X){
		return eval('document.'+what+'.y');
	}
	else {
	return parseInt(yIE(eval('document.getElementById("' + what + '")')));
	}
}
 
function xsPos(what){
	if(IEX){
		return xIE(eval('document.'+what));
	}
	else if(NN4X){
		return eval('document.'+what+'.x');
	}
	else {
		return parseInt(xIE(eval('document.getElementById("' + what + '")')));
	}
}
 
function yIE(what) {
	if(what.offsetParent) {
		return parseInt((what.offsetTop + yIE(what.offsetParent)));
	} else {
		return parseInt(what.offsetTop);
	}
}

function xIE(what) {
	if(what.offsetParent) {
		return parseInt((what.offsetLeft + xIE(what.offsetParent)));
	} else {
		return parseInt(what.offsetLeft);
	}
}
// ---------------------



// repositions a layer according to the offsets from a specified image.
// remember to include both a name and an id reference on the image.
function positionLayerFromImage(theImage,theLayer,theXOffset,theYOffset,visibilityState) {
	theX = xsPos(theImage);
	theY = ysPos(theImage);
	moveLayerTo(theLayer,theX+theXOffset,theY+theYOffset);
	if (visibilityState == 'show') {
		showLayer(theLayer);
	}
	else if (visibilityState == 'hide') {
		hideLayer(theLayer);
	}
}

// gets a cookie
function getCookie(strCookieName) {
	strCookieName += "=";
	var pos = document.cookie.indexOf(strCookieName);
	if(pos != -1){
		var start = pos+strCookieName.length;
		var end = document.cookie.indexOf(";",start);
		if(end == -1)
			end = document.cookie.length;
		var cookieValue = document.cookie.substring(start, end);
		
		return unescape(cookieValue);
		
	}
	return null;
}

// sets a cookie
function setCookie (name, value){
	document.cookie = name + "=" + escape(value) + ";expires=Mon, 18-Jan-12 00:00:01 GMT;path=/;";
}

/*
// used by index.jsp
function isBrowserOk() {
	if (document.getElementById || NN4X || IE5 || IE55) {
		return true;
	}
	else {
		return false;
	}
}

//used by index.jsp
function isFlashOk() {
	var flashversion = getCookie('flashversion');
	if(flashversion!=null && parseInt(flashversion) >= 9){
		return true;
	}
	else {
		return false;
	}
}
*/