function PreloadImages(length, path, type)  {
    for(var i = 0; i<=length; i++) {
	this[i]= new Image()
	this[i].src= path + i + type
    }
    return this;
}
function rollOn(num) {
    if(document.images) { 
	eval('document.images["norm'+num+'"].src='+'overImg[num].src');
    }
}

function rolloff(num) {
    if(document.images){
	eval('document.images["norm'+num+'"].src='+'normImg[num].src');
    }
}

function mOvr(src,clrOver) {
    if (!src.contains(event.fromElement)) {
	src.style.cursor = 'hand'; src.bgColor = clrOver;
    }
}

function mOut(src,clrIn) {
    if (!src.contains(event.toElement)) {
	src.style.cursor = 'default'; src.bgColor = clrIn;
    }
}

function sizeImg(obj, _width) {
    var tmpImg = new Image();
    tmpImg.src = obj.src;
    if (tmpImg.width > _width) { obj.width = _width; }
}
function sizeImgWH(obj, _width, _height) {
    var tmpImg = new Image();
    tmpImg.src = obj.src;
    if (tmpImg.width > _width) { obj.width = _width; }
    if (tmpImg.height > _height) { obj.height = _height; }
}

function PrinterFriendly(url) {

	remote = window.open("","_self");
    remote.location.href=url;
    if (remote.opener == null) remote.opener = window;
}



function PrinterFriendly760(url) {
    var width = 760,
        height = 400;
    remote = window.open("", "opener", "menubar=0,scrollbars=0,resizable=0,toolbar=0,left=" + ((screen.availWidth  - width) / 2) + ",top=" + ((screen.availHeight  - height) / 2) + ",Width=" + width + ",height=" + height);
    remote.location.href=url;
    if (remote.opener == null) remote.opener = window;
}


function showText(obj) {
    obj.onmouseout = function() { window.status = ""; }
    window.status = obj.innerText;
}

function checkMail(mail) {
	var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return myRegExp.test(mail);
}

// from Root Header
function GoProd(s) {
    var d = s.options[s.selectedIndex].value;
    window.top.location.href = d;
    s.selectedIndex = 0;
}

function redirect(target_url) {
    document.location = target_url;
}

// Form checking utilities

function checkEmail(mail) {
	var myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return myRegExp.test(mail);
}

function Wrong(obj, message) {
	alert(message);
	obj.focus();
	return false;
}

function getCookie(name) {

	var regExp 	= new RegExp(name + "=([^;]*)","gi");
	var ck 		= regExp.exec(String(document.cookie));	
	ck 			= RegExp.$1;

	return ck;
}


function httpRequestCreate() {
	var httpRequest = false;
	if ( window.XMLHttpRequest ) 
	{ // Mozilla, Safari
		httpRequest = new XMLHttpRequest();
		if ( httpRequest.overrideMimeType ) {
			httpRequest.overrideMimeType('text/xml');
		}
	} else if ( window.ActiveXObject ) 
	{ // IE
		try {
			httpRequest = new ActiveXObject("MSXML2.XMLHTTP.3.0");
		} catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) { document.write(e); }
		}
	}
	return httpRequest;
}
function httpRequest(url, encoding, toReceive) {
	return httpRequestPost(url, encoding, toReceive,"");
}
function httpRequestPost(url, encoding, toReceive, params) {
	var toResolve		= 10000;
	var toConnect		= 10000;
	var toSend			= 40000;
	var request;
	var WinHttpReq;
	var request = "";
	try {
		var xmlHttpReq = httpRequestCreate(); //new ActiveXObject("MSXML2.XMLHTTP.3.0");
		xmlHttpReq.open("POST", url, false);
		xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttpReq.setRequestHeader('HTTP_COOKIE', document.cookie);
		xmlHttpReq.send(params);
		return xmlHttpReq.responseText;
		if(WinHttpReq.StatusText == "OK") {
			request = BinaryToString1(WinHttpReq.ResponseBody, encoding);
		} else { request = "2-1 " + WinHttpReq.StatusText; }
	} catch(e) { request = "2-2 " + "WinHttpRequest has caused an error"; }
	return request;
}

function launchWin(doc,name,w,h) {
	settings = "toolbar=0,scrollbars=yes,location=0,status=0,menubar=yes,resizeable=0,width=" + w + ",height=" + h;
	window.open(doc,name,settings);
	}

