
var windowOpenedSuccessfully = "false";

function focusAndCheck(openedWindow, displayError)
{
	if(!openedWindow||(openedWindow.closed||!openedWindow.focus))
	{
		if (displayError)
		{
			alert("Popup blocking software may be stopping this operation.  Please disable any popup blockers and try again.");
		}
		return false;
	}
	else
	{
		openedWindow.focus();
		return true;
	}
}

function replaceText(inString,oldText,newText)

{
	return (inString.split(oldText).join(newText));
}

function openPopup(inputUrl, inputWidth, inputHeight){

	var popupWindow = "";
	var stringArray = inputUrl.split(".aspx");
	
	var pagePath =  replaceText(stringArray[0],'/en/shoponline/', '');
	
	if (!popupWindow || popupWindow.closed)
	{
		windowOpenedSuccessfully = "false";
		popupWindow = window.open(inputUrl, pagePath, 'width=' + inputWidth + ',height=' + inputHeight + ',scrollbars=0');
		windowOpenedSuccessfully = focusAndCheck(popupWindow, true);
	}
}

function openPopupGeneric(inputUrl, inputWidth, inputHeight, scrollbars){

	var popupWindow = "";

	if (!popupWindow || popupWindow.closed)
	{
		windowOpenedSuccessfully = "false";
		popupWindow = window.open(inputUrl, "frettePopup", 'width=' + inputWidth + ',height=' + inputHeight + ',scrollbars=' + scrollbars);
		windowOpenedSuccessfully = focusAndCheck(popupWindow, true);
	}
}

function checkEnter(e, url)
{ 
	var characterCode 

	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e;
	characterCode = e.which; //character code is contained in NN4's which property
	}
	else{
	e = event;
	characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		submitSearchForm(url);
	return false; 
	}
	else{
	return true;
	}
}

function printpage() {
	window.print();  
}

function closeWindow()
{
	window.close();
}

var selected_id = null; 
var dom = document.getElementById; 

function swapIt(id, newclass) { 
if (dom) { 
if(selected_id != id) { 

el = document.getElementById(id); 
el.className = newclass; 
el.style.cursor = "hand"; 
el.style.cursor = "pointer";
 
} 
} 
} 

function down (id,oldclass,newclass){ 
if (dom) { 
if(selected_id != null) { 
document.getElementById(selected_id).className = oldclass; 
} 
el.className = newclass; 
selected_id = id; 
} 
} 

function setElementContent(id,content)
{
	document.getElementById(id).value = content;
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


