﻿function isIE() {
	return (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1);
}
function ScrollIt(){
    window.scrollTo(0, 0);
    }
function setcoords(){
    var myPageX;
    var myPageY;
    if (document.all){
        myPageX = document.body.scrollLeft;
        myPageY = document.body.scrollTop;
        }
    else{
        myPageX = window.pageXOffset;
        myPageY = window.pageYOffset;
        }
    document.Form1.PageX.value = myPageX;
    document.Form1.PageY.value = myPageY;
    }
function switchLang(from,to) {
	var currentStr = window.location.href;
	currentStr = currentStr.replace("/" + from + "/", "/" + to + "/");
	currentStr = currentStr.replace("lang=" + from, "lang=" + to);
	window.location.href = currentStr;
}

function getBrowserClientWidth() {
	if (typeof(window.innerWidth) == 'number') {
		// Non-IE
		return window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
	    //IE 4 compatible
		return document.body.clientWidth;
	}
	return 0;
}

function getBrowserClientHeight() {
	if (typeof(window.innerHeight) == 'number') {
		// Non-IE
		return window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
	    //IE 4 compatible
		return document.body.clientHeight;
	}
	return 0;
}

function getParamString() {	// cody.ng 2006.12.18
	var url = location.href;
	var pos = url.indexOf("?");
	if (pos <= 0)
		return "";
	return url.substring(pos + 1, url.length);
}


function getParamStringToArray() { // cody.ng 2006.12.18, ps: the key is in lower case
	var ps = getParamString();
	if (ps == "")
		return;
	var psArray = ps.split("&");

	var arr = new Array();
	for (var i = 0; i < psArray.length; i++) {
		var chunk = psArray[i];
		if (chunk != "") {
			var pair = chunk.split("=");
			if (pair.length == 2) {
				arr[pair[0].toLowerCase()] = pair[1];
			}
		}
	}		
	return arr;
}

function setFlashWidth(divid, newW) {
	document.getElementById(divid).style.width = newW + "px";
}

function setFlashHeight(divid, newH) {
	
	/*
	abc='before position='+document.getElementById(divid).style.position+ ' \nzIndex='+document.getElementById(divid).style.zIndex+ '\n height='+document.getElementById(divid).style.height;
	document.getElementById(divid).style.position = "absolute";
	document.getElementById(divid).style.position = "relative";
	document.getElementById(divid).style.zIndex = "5";
	*/
	document.getElementById(divid).style.height = newH + "px";  
	
	//alert(abc+'\nafter position='+document.getElementById(divid).style.position+ ' \nafther zIndex='+document.getElementById(divid).style.zIndex+ '\n height='+document.getElementById(divid).style.height+divid+','+ newH);
}
function setFlashSize(divid, newW, newH) {
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}

function PopupPlayer(filename) {
	window.open(filename,'','width=110,height=60,toolbar=no,status=no,menubar=no,location=no');
}

function checkEmail(str){
	var testresults;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
		testresults=true;
	else{
		testresults=false;
	}
	return (testresults);
}