function changeOver(img, path) {
	imgSrc = img.src;
	imgSrcArray = imgSrc.split("/"); 
	imgArray = imgSrcArray[imgSrcArray.length-1].split(".");
	img.src = path + imgArray[0] +  "_on" + "." + imgArray[1];
	img.style.cursor = "pointer";
}

function changeOut(img, path, lng) {
	imgSrc = img.src;
	imgSrcArray = imgSrc.split("/"); 
	imgArray = imgSrcArray[imgSrcArray.length-1].split(".");
	imgNameArray = imgArray[0].split("_");
	img.src = path + imgNameArray[0] + "_" + imgNameArray[1] + "_" + lng + "." + imgArray[1];
	img.style.cursor = "default";
}

function formButtonOver(btn) {
	actBack = btn.style.backgroundImage;
	actBackUrl = actBack.substr(4, actBack.length-9);
	newUrl = actBackUrl + "_on.jpg";
	btn.style.backgroundImage = "url(" + newUrl + ")";
	btn.style.cursor = "pointer";
	//btn.style.fontWeight = "bold";
}

function formButtonOut(btn) {
	actBack = btn.style.backgroundImage;
	actBackUrl = actBack.substr(4, actBack.length-12);
	newUrl = actBackUrl + ".jpg";
	btn.style.backgroundImage = "url(" + newUrl + ")";
	btn.style.cursor = "default";
	//btn.style.fontWeight = "normal";
}

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;
	}

	return yScroll;
}

function checkBrowser() {
    var strChUserAgent = navigator.userAgent;
    var intSplitStart = strChUserAgent.indexOf("(",0);
    var intSplitEnd = strChUserAgent.indexOf(")",0);
    var strChStart = strChUserAgent.substring(0,intSplitStart);
    var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
    var strChEnd = strChUserAgent.substring(strChEnd);
	
	if(strChMid.indexOf("MSIE 8") != -1)
    	browser = "IE";
    else if(strChMid.indexOf("MSIE 7") != -1)
    	browser = "IE";
	else if(strChMid.indexOf("MSIE 6") != -1)
    	browser = "IE";
    else if(strChEnd.indexOf("Firefox/2") != -1)
    	browser = "FIREFOX";
    else if(strChEnd.indexOf("Firefox") != -1)
    	browser = "FIREFOX";
    else if(strChEnd.indexOf("Netscape/7") != -1)
    	browser = "NETSCAPE";
    else if(strChEnd.indexOf("Netscape") != -1)
    	browser = "NETSCAPE";
    else if(strChStart.indexOf("Opera/9") != -1)
    	browser = "OPERA";
    else if(strChStart.indexOf("Opera") != -1)
    	browser = "OPERA";
	else if(strChUserAgent.indexOf("Safari") != -1)
		browser = "SAFARI";
    else
		browser = "OTHER";
	
	return browser;
}

function moveDivAR() {
	if (document.getElementById('divAR').style.display == 'block') {
		document.getElementById('divAR').style.top = getPageScroll();
	}
}

function hideDivAR(offset) {
	document.getElementById('divAR').style.display = "none";
	decal = offset;
	interval = window.setInterval("scrollWin()", 1000);
}

function sleep(time) {
	d=new Date();
	diff=0;
	while(diff < time)
	{
		n=new Date();
		diff=n-d;
	} 
}

function showAR(img, message, offset) {
	pageDimensions = getPageSize();
	pageWidth = pageDimensions[0];
	pageHeight = pageDimensions[1];
	document.getElementById('divAR').style.width = pageWidth;
	document.getElementById('divAR').style.height = pageHeight;
	document.getElementById('message').innerHTML = message;  
	document.getElementById('divAR').style.display='block';
	document.getElementById('pixAR').src = img;

	imHeight = document.getElementById('pixAR').height;
	imWidth = document.getElementById('pixAR').width;
	
	
	//alert(pageDimensions[3]);
	if (imHeight < pageDimensions[3]) {
	//	if (checkBrowser() == "IE") {
			topPos = (pageDimensions[3] - imHeight) / 3;
	//	} else {
	//		topPos = pageYOffset;		
	//	}
		document.getElementById('divAR').style.paddingTop = Math.round(topPos, 0);
	} else {
		//if (checkBrowser() == "IE") {			  
		//	topPos = document.body.scrollTop;
		//} else {
			topPos = pageYOffset;		
		//}
		document.getElementById('divAR').style.paddingTop = Math.round(topPos, 0);
	}
	
	//document.getElementById('divAR').style.top = "900px";
	//interval = window.setInterval("scaleStep()", 10);
	decal = offset;
	
	interval = window.setInterval("scrollWin()", 1000);
	//window.scrollBy(0,1200);
	//setTimeout("hideDivAR()", 5000);
	
}

function scrollWin() {
	move = parseInt(decal) + 1;
	window.scrollBy(0, move); // horizontal and vertical scroll increments
	if (pageYOffset + 1000 > decal) {
		window.clearInterval(interval);
	}
}
/*function scaleStep() {
 	var step = 10;
	tmpWidth = document.getElementById('pixAR').width;
	tmpHeight = document.getElementById('pixAR').height;
	
	if (pixState == 'small')
 	{
 		tmpWidth += step;
		tmpHeight += Math.floor(step * ratio);
 		document.getElementById('pixAR').width = tmpWidth;
 		document.getElementById('pixAR').height = tmpHeight;
	}
	
	limit = parseInt(imWidth) - step;
	//alert(limit);
	if (tmpWidth > limit)
 	{
		//alert("high");
 		document.getElementById('pixAR').width = imWidth;
 		document.getElementById('pixAR').height = imHeight;
 		window.clearInterval(interval);
		pixState = "big";
	}
}*/