var imgUrl = "";
var shoecolorpath = "";
var cssType = "";
// changes the Text of an Div elem
function changeDivTextByName(name, html) {
	document.getElementByName(name)[0].innerHTML = html;
}

/*
 * splits the URL into two parts and returns the action and the parameters in an array
 * example: url = NaviAction.do?show=5&all=true
 * action = NaviAction.do
 * parameters = show=5&all=true
 */
function splitURL(url) {
	var action;
	var parameter;
	if (url.indexOf("?") != -1) {
		action = url.substr(0, url.indexOf("?"));
		parameter = url.substr(url.indexOf("?") + 1);
	} else {
		action = url;
	}
	return [action, parameter];
}

function colorSwitchOn(elem,newId,newSrc,colortxt) {

	defaultColor = document.getElementById("shoemedium").src;
	defaultColorTxt = document.getElementById("colortxt").innerHTML;
	defaultItemTxt = document.getElementById("itemID").innerHTML;
	currentColorIndex = document.getElementById("coloroptions").getElementsByTagName("li")[0];

	document.getElementById("shoemedium").src = shoecolorpath + newSrc + imageext;
	document.getElementById("colortxt").innerHTML = colortxt;
	document.getElementById("itemID").innerHTML = newId;
	for (i=0; i<elem.parentNode.parentNode.getElementsByTagName("li").length; i++) {
		elem.parentNode.parentNode.getElementsByTagName("li")[i].className = "";
	}
}

function colorSwitchOff() {
	document.getElementById("shoemedium").src = defaultColor;
	document.getElementById("colortxt").innerHTML = defaultColorTxt;
	document.getElementById("itemID").innerHTML = defaultItemTxt;
	currentColorIndex.className = "focused";
	
	defaultColor = "";
}

function changeBagQuantity(html, quantity, bagPicture) {
	if (quantity != "0") {
		hideObjectById("checkoutOuter", 0);
	} else {
		hideObjectById("checkoutOuter", 1);
	}
	document.getElementById("mybaglnk").innerHTML = html;  // change # of items in bag

	if (bagPicture != undefined) {
		document.getElementById("bagPicture").src = bagPicture;
	}
	setTimeout('addToBagEnd("str")', 2500);
}

function changeLogout(html) {
	var obj = document.getElementById("logout");
	
	if (obj == undefined) {
		return;
	}
	obj.innerHTML = html;  // change # of items in bag
}

function changeRecentlyViewed(html) {
	var obj = document.getElementById("recentlyviewed");
	
	if (obj == undefined) {
		return;
	}

	if (html.length > 0) {
		hideObjectById("recentlyOuter", 0);
		obj.innerHTML = html;  // change # of items in bag
	} else {
		hideObjectById("recentlyOuter", 1);
	}
}

function listProperties(obj, objName) {
	var message = "";
	for (var i in obj) {
		message += objName + "." + i + "=" + obj[i] + "\n";
	}
	alert(message);
}

function setObjValue(name) {
	var obj;
	obj = document.getElementsByName(name);
	obj[0].value = name;
}


/*
 * hides / shows a object by obj
 * i == 0 => show
 * i == 1 => hide
 */
function hideObject(obj, i) {
	if (obj.style.display == "none" && i == 0) {
		obj.style.display = "";
	} else if(i != 0) {
		obj.style.display = "none";
	}		
}

/*
 * hides / shows a object by id
 * i == 0 => show
 * i == 1 => hide
 */
function hideObjectById(name, i) {
	var obj = document.getElementById(name);
	
	if (obj == undefined) {
		return;
	}
	hideObject(obj, i);
}

/*
 * hides / shows a object by obj
 * i == 0 => show
 * i == 1 => hide
 */
function hideObjectContent(obj, i) {
	if (obj.style.visibility  == "hidden" && i == 0) {
		obj.style.visibility = "visible";
	} else if(i != 0) {
		obj.style.visibility = "hidden";
	}		
}

/*
 * hides / shows a object by id
 * i == 0 => show
 * i == 1 => hide
 */
function hideObjectContentById(name, i) {
	var obj = document.getElementById(name);
	
	if (obj == undefined) {
		return;
	}
	hideObjectContent(obj, i);
}

function toggleSwitch(e, obj) {
    if ((obj.value == creditCardSwitch) 
    	|| (obj.value == creditCardSolo)
    	|| (obj.value == creditCardLaser)) {
		e.style.display = "";
	} else {
		e.style.display = "none";
	}		
}

function loadCountrySWF(xmlfile, destinationURL, flashURL) {
	var fo = new SWFObject(flashURL + "shop/swf/languageLoader.swf", "language", "680", "540", "8", "#FFFFFF");
	fo.addParam("allowScriptAccess", "always");

	fo.addVariable("cl", xmlfile);
	fo.addVariable("destinationURL", destinationURL);
	fo.addVariable("flashURL", flashURL + "shop/swf/");
	fo.write("flashcontent");
}

// tests if a size on the product page is selected
function testAddToCart() {
    if( document.productForm.productPK.value == "#" ) {
        alert(selectSizeText);
        return false;
    }
}

// checks if the signup is filled
function checkSignup(fieldname) {
	var email = document.getElementById(fieldname);
    if (email.value == "") {
    	alert(wrongEmailText);
    	return false;
    } else {
        if (email.value.indexOf('@') == -1) {
        	alert(wrongEmailText);
	        return false;
	    }
	    if (email.value.indexOf('.') == -1) {
	    	alert(wrongEmailText);
	        return false;
	    }
    }
	return true;  
 }
 
function switchSignup() {
 	document.getElementById("emailRegForm").innerHTML = "<strong>" + signupThanksText + "</strong>";
	document.getElementById("emailRegForm").style.paddingTop = "12px";
	document.getElementById("emailRegistration").style.width = "200px";
}

function goToLeaf(cpk) {
	// If we switch AJAX on
	document.storeMenu.SetVariable("path", cpk);
	document.storeMenu.SetVariable("functionName", "goToLeaf");
}

function goToZeroIn() {
	document.storeMenu.SetVariable("functionName", "goToZeroIn");
}

function goToTree() {
	document.storeMenu.SetVariable("functionName", "goToTree");
}

function onTreeNodeRelease(url, path) {
	myForm.output.value = url;	
}

function onTreeNodeReleaseFinal(url, path) {
	 try{
		 if(url != ""){
			window.location.href = url;
			 }
	 }catch(err){}
}

function onZeroInSelect(selection) {
	myForm.output.value = selection;	
}

function goToLeafWithTimeout(cpk) {
	setTimeout('goToLeaf("' + cpk + '")', 1000);
}

function sleep(ms) {
	var zeit=(new Date()).getTime(); 
	var stoppZeit=zeit+ms; 
	while((new Date()).getTime()<stoppZeit){}; 
}

// Resizes the flash menue... is called from the falsh
function setMenuHeight(h){
	$('storeMenu').style.height=h+40+"px";
}

function showSizes(xmlfile, id, flashURL){
	var so = new SWFObject(flashURL + "shop/swf/sizing.swf", "sizing", "700", "460", "8", "#FFFFFF");

	so.addParam("allowScriptAccess", "always");

	so.addVariable("sizeXmlFile", xmlfile + "sizing-chart.xml");
	so.addVariable("measureXmlFile", xmlfile + "sizing-chart.xml");
	so.addVariable("langXmlFile", xmlfile + "lang-puma.jsp");
	so.addVariable("flashURL", flashURL + "shop/swf/");
	if(id) {
		so.addVariable("callId", id);
	}
	so.write("flashcontent");
}

function selectAllInterests() {
	var obj = document.getElementById("l_lifestyle");
	obj.checked = true ;

	var obj = document.getElementById("l_fashion");
	obj.checked = true ;
	
	var obj = document.getElementById("l_football");
	obj.checked = true ;
	
	var obj = document.getElementById("l_motorsports");
	obj.checked = true ;
	
	var obj = document.getElementById("l_golf");
	obj.checked = true ;
	
	var obj = document.getElementById("l_running");
	obj.checked = true ;
	
	var obj = document.getElementById("l_mbbq");
	obj.checked = true ;
}

// Detects if Flash is installed
function detectFlash() {
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	if (version['major'] == '0') {
		ajaxSwitch('DHTMLNavigationAction.do', 'flashblock', '1');
	}
}


function global_init_script(firstURL) {
	var Global = new Object();
	Global.SM = new StateManager("HistoryFrameContainer", firstURL);	

	Global.SM.onChange = function(args){
		implementSwitchContent(args.url, args.con);
	}

	top.Global = Global;

	var lastURL = document.getElementById("lastURL").value;
	if(lastURL != ""){
		implementSwitchContent(lastURL, "mainContentContainer");
	}

	var obj = document.getElementById('contentwrapper');
	hideObject(obj, 0);
}

function brandpanelPlane(imgsrv)
{
	var so = new SWFObject(imgsrv + "shop/swf/plane.swf", "plane", "345", "230", "8", "#EEEEEE");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "noscale");
	so.addParam("allowScriptAccess", "always");
	so.write("flash");
}

function brandpanelTop(imgsrv,name)
{
	var so = new SWFObject(imgsrv + "shop/swf/"+name+".swf", "plane", "690", "220", "8", "#EEEEEE");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "noscale");
	so.addParam("allowScriptAccess", "always");
	so.write("flash");
}

function brandpanelOthers(imgsrv,name)
{
	var so = new SWFObject(imgsrv + "shop/swf/"+name+".swf", "others", "334", "460", "8", "#EEEEEE");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "noscale");
	so.addParam("allowScriptAccess", "always");
	so.write("flash");
}

function brandpanelProduct(imgsrv, id)
{
	var so = new SWFObject(imgsrv + "shop/swf/instore_images.swf", "plane", "334", "460", "9", "#EEEEEE");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "noscale");
	so.addParam("allowScriptAccess", "always");
	so.addParam("salign", "t");
	so.addVariable("xmlFile", "xml/product.jsp");
	//ID for scene goes in here ('id' attribute in XML and spreadsheet)
	so.addVariable("image_id", id);
	so.addVariable("align", "middle");
	so.write("flash");
}
function brandpanelAir(imgsrv)
{
		var so = new SWFObject(imgsrv + "shop/swf/loader.swf", "airHockey", "157", "460", "8", "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.addParam("base",imgsrv + "shop/swf/");
		so.addVariable("imgServer", imgsrv + "shop/swf/pucks/");
		so.addVariable("flashURL", imgsrv + "shop/swf/");
		so.addVariable("maxGoals", "6");
		so.addVariable("discountKey", discountKey);
		so.addVariable("maxGoals", "1");
		so.addVariable("youLost_txt", youLost_txt);
		so.addVariable("betterLuck_txt", betterLuck_txt);
		so.addVariable("playAgain_txt", playAgain_txt);
		so.addVariable("promYouWon_txt", promYouWon_txt);
		so.addVariable("youWon_txt", youWon_txt);
		so.addVariable("allHail_txt", allHail_txt);
		so.addVariable("airHockey_txt", airHockey_txt);
		so.addVariable("startMessage_txt", startMessage_txt);
		so.addVariable("gameOn_txt", gameOn_txt);
		so.addVariable("goal_txt", goal_txt);
		so.addVariable("youScore_txt",youScore_txt);
		so.addVariable("pumaScore_txt",pumaScore_txt);
		so.write("flashtest");
}

function switchDropdown(value, label)
{		
	if(undefined != value)
	{
		window.document.addressForm.sa_country.value=label;
    }
}

function makeRequest(url, parameters) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
					     	// set type accordingly to anticipated content type
					        //http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType("text/html");
		}
	} else {
		if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
				}
			}
		}
	}
	if (!http_request) {
		alert("Cannot create XMLHTTP instance");
		return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open("GET", url + parameters, true);
	http_request.send(null);
}


function alertContents() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
						      //alert(http_request.responseText);
			result = http_request.responseText;
			document.getElementById("myspan").innerHTML = result;
		} else {
			alert("There was a problem with the request.");
		}
	}
}

function getChildElem(obj) {

	var getstr = "";
	var i = 0;
	
	if (obj == undefined) {
		return getstr;
	}

	for (i = 0; i < obj.childNodes.length; i++) {
		getstr = getstr + getChildElem(obj.childNodes[i]);
	}

	if ((obj.tagName == "INPUT") && (obj.name != "")) {
		if (obj.type == "text") {
				getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
			}
		if (obj.type == "hidden") {
			getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
		}
		if (obj.type == "password") {
			getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
		}
		if (obj.type == "checkbox") {
			if (obj.checked) {
				getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
			} else {
				getstr += obj.name + "=&";
			}
		}
		if (obj.type == "radio") {
			if (obj.checked) {
				getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
			}
		}
		if (obj.type == "image") {
			if (obj.value == obj.name) {
				getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
			}
		}
	}
	if ((obj.tagName == "TEXTAREA") && (obj.name != "")) {
			getstr += obj.name + "=" + encode_utf8(obj.value) + "&";
	}
	if (obj.tagName == "SELECT") {
		var sel = obj;
		if (sel.selectedIndex > -1)
		{
			if (sel.options[sel.selectedIndex] != undefined) {
				if (sel.name != "") {
					getstr += sel.name + "=" + encode_utf8(sel.options[sel.selectedIndex].value) + "&";
				}
			}
		}
	}
	return getstr;
}


function getParameterStringFromForm(formName) {
	var obj = document.getElementById(formName);
	getstr = getChildElem(obj);
	if(formName.indexOf('searchForm') == -1)
	{
		getstr= getstr.replace(/\?/g,"%3F");
	}
	return getstr;
}

function implementSwitchContent(url, container) {
	var cnt = document.getElementById(container);
	cnt.innerHTML = "&nbsp;";
	cnt.style.height = "300px";
	cnt.style.backgroundImage = "url('" + imgUrl + "shop/contentpreloader.gif')";
	cnt.style.backgroundPosition = "center";
	cnt.style.backgroundRepeat = "no-repeat";
	document.getElementById("lastURL").value = url;
	ajaxSwitch(url, container, 1);
}

function switchContentEP(url, container, noReturn) {
	var parts = Array.from(url.split('?'));
	if (parts[1] != '') {
		parts[1] = encode_utf8(parts[1]);		
	}
	url = '';
	for(var index=0; index < parts.length; ++index){
		url = url + parts[index];
		if (index < (parts.length-1)) {
			url = url + '?';
		}
	} 
	return switchContent(url, container, noReturn);
}

function switchContent(url, container, noReturn) {
	if (noReturn == undefined) {
		noReturn = false;
	}
	Global.SM.put("url="+ escape(url) +"&con="+container);
	if (!noReturn) {
		return false;
	}
}
function encode_utf8(rohtext) {
	rohtext = rohtext.replace(/\r\n/g, "\n");
	var utftext = encodeURIComponent(rohtext);
	return utftext;
}
function switchContentAndSendForm(url, container, formName) {
	if (url.indexOf("?") != -1) {
		url = url + "&" + getParameterStringFromForm(formName);
	} else {
		url = url + "?" + getParameterStringFromForm(formName);
	}
	var test = url;
	test = test.replace(/'/g,"%27");
	return switchContent(test, container);
}

function createLightbox(action, parameter, width, height, type) {
	if (type == undefined)
		type = 'tb';
	if (parameter == undefined)
		parameter = '';
	pumaLightbox = new Lightbox(action, width, height, type, action, parameter, '', '');
	pumaLightbox.load();
	pumaLightbox.lightboxPosition(false);

}

function openLightbox(url, width, height, type) {
	
	var parts = splitURL(url);
	var action = parts[0];
	var parameter = parts[1];
	createLightbox(action, parameter, width, height, type);
}

function switchLightboxContent(url,resize) {
	pumaLightbox.contentSrc = url;
	pumaLightbox.populate();
	if(resize)
	pumaLightbox.centerLightbox();
}

function switchLightboxContentAndSendForm(url, formName) {
	var parts = splitURL(url);
	var action = parts[0];
	var parameter = parts[1];
	
	if ((parameter != undefined) && (parameter.length > 0)) {
		parameter = parameter + "&" + getParameterStringFromForm(formName);
	} else {
		parameter = getParameterStringFromForm(formName);
	}
	switchLightboxContent(action + "?" + parameter, false);
}

var StateManager = function(target, firstURL){

	var historyTag = "history=true&";
	var firstPageURL = firstURL;
	var lastArgs = firstPageURL;

	var container = document.getElementById(target);
	
	var setFrameHash = function(args){ //changes the URL of the iFrame with the new Parameters
		if(args != undefined && args != ""){
			container.src = "./historyFrame.jsp?"+historyTag+args+"&d="+(new Date()).getTime();
		}
	};
	
	return {
		stateChange:function(obj){ //fires when the iFrame changes or reloads

			if(obj.isHistory!="true") return;

			//check if the URL is the same from the last time stateChange was fired
			if(lastArgs != obj.url){
				lastArgs = obj.url;
				this.onChange(obj);
			}
		},
		put:function(args){ //pushes the new parameters to the iFrame
			setFrameHash(args);
		},
		changeFirstPageURL:function(firstURL){
			if (firstPageURL == lastArgs)
				lastArgs = firstURL;
			firstPageURL = firstURL;
		},
		onChange:function(o){
		}
	};
};
var img; 
var mywidth = 0;
var myheight = 0;
var filePath = "";
function getSize() {
	mywidth = img.width;
	myheight = img.height;
	if (img.complete) {
		mywidth = img.width;
		myheight = img.height;
		zoomInit2(filePath);
	} else {
		setTimeout("getSize()",10);
	}
}

function zoomInit(filename) {
	img = new Image();
	img.src = shoecolorpath + filename;
	filePath = filename;
	getSize();
}

function zoomInit2(filename) {
	var p = new PISAClient("imageViewerContainer");
	p.setHost(shoecolorpath);
	p.setFilename(filename);
	p.setBackground("0,0,0");
	if (mywidth > 0)
		p.setSize(mywidth,myheight);
	else
		p.setSize(275,300);
	p.setCanvasSize(670,500);  
	p.setIcons(imgUrl);
	p.render(); 
}

function zoomSetFilename(filename, clickedObj, zoom) {
	obj = document.getElementsByName("zoomMoreImages");
/*
	for (i=0; i<obj.length; i++) {
		obj[i].style.border = "solid #999999 1px";
	}
	obj[clickedObj].style.border = "solid #FF0000 1px";
*/
	var p = new PISAClient("imageViewerContainer");
	p.setHost(shoecolorpath);
	p.setFilename(filename);
	p.setBackground("255,255,255");

	img.src = shoecolorpath + filename;
	getSize();
	p.setSize(mywidth,myheight);
	p.setCanvasSize(670,500);
	p.setIcons(imgUrl);
	p.render(); 
	if(zoom == 'true')
	{
		p.doZoom(5); 
		return;
	}
}

function javascriptRelay(str){
		eval(str);
}

function postSearch(q,action)
{
	document.forms.sizeForm.productPK.value = q;
	document.forms.sizeForm.action = "javascript:openLightboxAndSendForm('"+action+"', 110, 110, 'sizeForm', 'tb', 'true');"
	document.forms.sizeForm.submit();
}

function createProductPage(cfg, flashURL){
	var so = new SWFObject(flashURL + "swf/product_component.swf", "product_page_flash", "699", "489", "8", "#EEEEEE");
	var data = encodeURIComponent(Object.toJSON(cfg));
	so.addParam("allowScriptAccess", "always");
	so.addVariable("config", data);
	so.addParam("wmode", "transparent");
	so.write("productDetailBox");
}

function copyToShippingAddress() {
		
	if (document.addressForm.bill_useasshippingaddress.checked == true) {
		document.addressForm.ship_titlePK.value=document.addressForm.bill_titlePK.value;
		document.addressForm.ship_firstname.value=document.addressForm.bill_firstname.value;
		document.addressForm.ship_lastname.value=document.addressForm.bill_lastname.value;
		document.addressForm.ship_company.value=document.addressForm.bill_company.value;
		document.addressForm.ship_postalcode.value=document.addressForm.bill_postalcode.value;
		document.addressForm.ship_streetname.value=document.addressForm.bill_streetname.value;
		document.addressForm.ship_streetnumber.value=document.addressForm.bill_streetnumber.value;
		document.addressForm.ship_town.value=document.addressForm.bill_town.value;
		document.addressForm.ship_birthday_day.options[document.addressForm.bill_birthday_day.selectedIndex].selected="selected";
		document.addressForm.ship_birthday_month.options[document.addressForm.bill_birthday_month.selectedIndex].selected="selected";
		document.addressForm.ship_birthday_year.options[document.addressForm.bill_birthday_year.selectedIndex].selected="selected";
	}
}

function copyAddress() {
	if (document.addressForm.bill_useasshippingaddress.checked == true) {
		document.addressForm.ship_titlePK.disabled=true;
		document.addressForm.ship_firstname.disabled=true;
		document.addressForm.ship_lastname.disabled=true;
		document.addressForm.ship_company.disabled=true;
		document.addressForm.ship_postalcode.disabled=true;
		document.addressForm.ship_streetname.disabled=true;
		document.addressForm.ship_streetnumber.disabled=true;
		document.addressForm.ship_town.disabled=true;
		document.addressForm.ship_birthday_day.disabled=true;
		document.addressForm.ship_birthday_month.disabled=true;
		document.addressForm.ship_birthday_year.disabled=true;
		copyToShippingAddress();
	} else {
		document.addressForm.ship_titlePK.disabled=false;
		document.addressForm.ship_firstname.disabled=false;
		document.addressForm.ship_lastname.disabled=false;
		document.addressForm.ship_company.disabled=false;
		document.addressForm.ship_postalcode.disabled=false;
		document.addressForm.ship_streetname.disabled=false;
		document.addressForm.ship_streetnumber.disabled=false;
		document.addressForm.ship_town.disabled=false;
		document.addressForm.ship_birthday_day.disabled=false;
		document.addressForm.ship_birthday_month.disabled=false;
		document.addressForm.ship_birthday_year.disabled=false;
	}
}

function createBirthdayString(){
	
	var birthdayString = document.myForm.birthday_day.options[document.myForm.birthday_day.selectedIndex].value + "." 
						 + document.myForm.birthday_month.options[document.myForm.birthday_month.selectedIndex].value + "."
						 + document.myForm.birthday_year.options[document.myForm.birthday_year.selectedIndex].value;
	document.myForm.birthday.value = birthdayString;
}

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

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;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll(){
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

