
function PreloadImages(length, path, type)  {
    for(var i = 0; i<=length; i++) {
	this[i]= new Image()
	this[i].src= path + i + type
    }
    return this;
}

	overImg = new PreloadImages(10,'/policeone/data/images/mb_','.gif');
	normImg = new PreloadImages(10,'/policeone/data/images/ma_','.gif');

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; }
    return true;
}

function sizeImgWH(obj, _w, _h) {
    var tmpImg = new Image();
    tmpImg.src = obj.src;
    if (tmpImg.height > _h) { obj.height = _h; }
    if (tmpImg.width > _w) { obj.width = _w; }

}
function sizeImgPower (im, w) {
	if (im.width > w) { im.style.width = w; }
	if (im.style.width > w) { im.style.width = w; }
	sizeImg(im, w)
	return true;
}

function PrinterFriendly(url) {

	if(url.indexOf("/") == 0) { url = "http://www.policeone.com" + url; }
	remote = window.open("","_self");
    remote.location.href=url;
    if (remote.opener == null) remote.opener = window;

}

function PrinterFriendly760(url) {

		if(url.indexOf("/") == 0) { url = "http://www.policeone.com" + url; }
    var width = 760,
        height = 410;
    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 httpRequest(url, encoding, toReceive) {
	/*var toResolve		= 10000;
	var toConnect		= 10000;
	var toSend			= 40000;

	var request;
	var WinHttpReq = null;

	var request = "";
	try {
	
		if(!WinHttpReq) try {
			WinHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");	
		} catch (e){}		

		if(!WinHttpReq) try {
			WinHttpReq=new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e){}

		if(!WinHttpReq) try {
			WinHttpReq=new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e){}

		if(!WinHttpReq) try {
			WinHttpReq=new XMLHttpRequest();
		} catch (e){}		
		
		WinHttpReq.open("GET", url, false);
		WinHttpReq.send();
		return WinHttpReq.responseText;

		
		if(WinHttpReq.StatusText == "OK") {
			request = BinaryToString1(WinHttpReq.ResponseBody, encoding);
		} else { request = "1- " + WinHttpReq.StatusText; }
	} catch(e) { request = "2- " + "WinHttpRequest has caused an error"; }
	return request;*/
	
	return httpRequestPost(url, encoding, toReceive,"");
}

function httpRequestPost(url, encoding, toReceive, params) {
	var toResolve		= 10000;
	var toConnect		= 10000;
	var toSend			= 40000;

	var request;
	var WinHttpReq = null;

	var request = "";
	try {
	
		if(!WinHttpReq) try {
			WinHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");	
		} catch (e){}		

		if(!WinHttpReq) try {
			WinHttpReq=new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e){}

		if(!WinHttpReq) try {
			WinHttpReq=new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e){}

		if(!WinHttpReq) try {
			WinHttpReq=new XMLHttpRequest();
		} catch (e){}	
	
	WinHttpReq.open("POST", url, false);
	WinHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	WinHttpReq.setRequestHeader('HTTP_COOKIE', document.cookie);
	
	WinHttpReq.send(params);
	return WinHttpReq.responseText;

		
		if(WinHttpReq.StatusText == "OK") {
			request = BinaryToString1(WinHttpReq.ResponseBody, encoding);
		} else { request = "1- " + WinHttpReq.StatusText; }
	} catch(e) { request = "2- " + "WinHttpRequest has caused an error"; }
	return request;
}
