var pics=0;


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		cis_Home_over = newImage(webpath+"images/cis_Home-over.gif");
		cis_Services_cis_Home_over = newImage(webpath+"images/cis_Services-cis_Home_over.gif");
		cis_Services_over = newImage(webpath+"images/cis_Services-over.gif");
		cis_Pricing_cis_Services_over = newImage(webpath+"images/cis_Pricing-cis_Services_ov.gif");
		cis_Pricing_over = newImage(webpath+"images/cis_Pricing-over.gif");
		cis_Services_over016 = newImage(webpath+"images/cis_Services-over-16.gif");
		cis_About_Us_cis_Pricing_over = newImage(webpath+"images/cis_About-Us-cis_Pricing_ov.gif");
		cis_About_Us_over = newImage(webpath+"images/cis_About-Us-over.gif");
		cis_Infidelity_Investigations_cis_About_Us_over = newImage(webpath+"images/cis_Infidelity-Investiga-24.gif");
		cis_Infidelity_Investigations_over = newImage(webpath+"images/cis_Infidelity-Investiga-25.gif");
		cis_Custody_Investigations_cis_Infidelity_Investigations_over = newImage(webpath+"images/cis_Custody-Investigations-.gif");
		cis_Custody_Investigations_over = newImage(webpath+"images/cis_Custody-Investigatio-29.gif");
		cis_Fraud_Info_cis_Custody_Investigations_over = newImage(webpath+"images/cis_Fraud-Info-cis_Custody-.gif");
		cis_Fraud_Info_over = newImage(webpath+"images/cis_Fraud-Info-over.gif");
		cis_Custody_Investigations_over036 = newImage(webpath+"images/cis_Custody-Investigatio-36.gif");
		cis_Background_Check_cis_Fraud_Info_over = newImage(webpath+"images/cis_Background-Check-cis_Fr.gif");
		cis_Background_Check_over = newImage(webpath+"images/cis_Background-Check-over.gif");
		cis_Locate_cis_Background_Check_over = newImage(webpath+"images/cis_Locate-cis_Background-C.gif");
		cis_Locate_over = newImage(webpath+"images/cis_Locate-over.gif");
		cis_Background_Check_over046 = newImage(webpath+"images/cis_Background-Check-ove-46.gif");
		cis_Request_Info_cis_Locate_over = newImage(webpath+"images/cis_Request-Info-cis_Locate.gif");
		cis_Request_Info_over = newImage(webpath+"images/cis_Request-Info-over.gif");
		cis_Order_cis_Request_Info_over = newImage(webpath+"images/cis_Order-cis_Request-Info_.gif");
		cis_Order_over = newImage(webpath+"images/cis_Order-over.gif");
		cis_Request_Info_over056 = newImage(webpath+"images/cis_Request-Info-over-56.gif");
		preloadFlag = true;
	}
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		cis_Home_over = newImage(webpath+"images/cis_Home-over.gif");
		cis_Services_cis_Home_over = newImage(webpath+"images/cis_Services-cis_Home_over.gif");
		cis_Services_over = newImage(webpath+"images/cis_Services-over.gif");
		cis_Pricing_cis_Services_over = newImage(webpath+"images/cis_Pricing-cis_Services_ov.gif");
		cis_Pricing_over = newImage(webpath+"images/cis_Pricing-over.gif");
		cis_Services_over016 = newImage(webpath+"images/cis_Services-over-16.gif");
		cis_About_Us_cis_Pricing_over = newImage(webpath+"images/cis_About-Us-cis_Pricing_ov.gif");
		cis_About_Us_over = newImage(webpath+"images/cis_About-Us-over.gif");
		cis_Infidelity_Investigations_cis_About_Us_over = newImage(webpath+"images/cis_Infidelity-Investiga-24.gif");
		cis_Infidelity_Investigations_over = newImage(webpath+"images/cis_Infidelity-Investiga-25.gif");
		cis_Custody_Investigations_cis_Infidelity_Investigations_over = newImage(webpath+"images/cis_Custody-Investigations-.gif");
		cis_Custody_Investigations_over = newImage(webpath+"images/cis_Custody-Investigatio-29.gif");
		cis_Fraud_Info_cis_Custody_Investigations_over = newImage(webpath+"images/cis_Fraud-Info-cis_Custody-.gif");
		cis_Fraud_Info_over = newImage(webpath+"images/cis_Fraud-Info-over.gif");
		cis_Custody_Investigations_over036 = newImage(webpath+"images/cis_Custody-Investigatio-36.gif");
		cis_Background_Check_cis_Fraud_Info_over = newImage(webpath+"images/cis_Background-Check-cis_Fr.gif");
		cis_Background_Check_over = newImage(webpath+"images/cis_Background-Check-over.gif");
		cis_Locate_cis_Background_Check_over = newImage(webpath+"images/cis_Locate-cis_Background-C.gif");
		cis_Locate_over = newImage(webpath+"images/cis_Locate-over.gif");
		cis_Background_Check_over046 = newImage(webpath+"images/cis_Background-Check-ove-46.gif");
		cis_Request_Info_cis_Locate_over = newImage(webpath+"images/cis_Request-Info-cis_Locate.gif");
		cis_Request_Info_over = newImage(webpath+"images/cis_Request-Info-over.gif");
		cis_Order_cis_Request_Info_over = newImage(webpath+"images/cis_Order-cis_Request-Info_.gif");
		cis_Order_over = newImage(webpath+"images/cis_Order-over.gif");
		cis_Request_Info_over056 = newImage(webpath+"images/cis_Request-Info-over-56.gif");
		preloadFlag = true;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	 //else{alert("Can't Find: "+a[i]);}
}



var xinha_editors=new Array();
var dragee = null;
var div=null;
var allchecked=false;
var isWin=false;
var o=0;
var i=0;
var lmenu=new Array();
var fadeTime=1;
var picObject=null;
var selectOption;
var madeToolbar=0;
var catArray = new Array();
function remove(act,form,message)
{
	if(act=='Delete')
	{
		if(confirm(message))
		{
			form.submit();
		}
	}
}
function mouseOver(el,mID)
{
	el.mOver=1;
	if(el.tagName=="TD")
	{
		if(lastOver!=null)
		{
			lastOver.className="leagueMenu";
		}
		el.className="over";
		lastOver=el;
	}
	var menu;
	if(menu=document.getElementById(mID))
	{
		menu.caller=el;
		showMenu(mID);
	}
}
function mouseOut(el,mID)
{
	el.mOver=0;
	if(el.tagName=="TD")
	{
		el.className="leagueMenu";
	}
	if(mID != null)
	{
		window.setTimeout("hideMenu('"+mID+"')",100);
	}
}
function showMenu(mID)
{
	var menu;
	if(menu = document.getElementById(mID))
	{
		if(menu.show==1)
		{
			return;
		}
		menu.style.visibility="visible";
		if(document.all)
		{
			menu.style.filter='alpha(opacity=0)';
		}
		else
		{
			menu.style.opacity=0.00;
		}
		menu.show=1;
		menu.opacity=0;
		addOpacity(mID);
	}
}
function hideMenu(mID)
{
	var menu;
	if(menu = document.getElementById(mID))
	{
		if((menu.mOver!=1)&&(menu.caller.mOver!=1))
		{
			menu.show=0;
			subOpacity(mID);
		}
	}
}
function addOpacity(mID)
{
	var menu;
	if(menu = document.getElementById(mID))
	{
		if(menu.show==0)
		{
			return;
		}
		if(document.all)
		{
			menu.opacity+=1;
			menu.style.filter='alpha(opacity='+menu.opacity+')';
			if(menu.opacity<100)
			{
				window.setTimeout("addOpacity('"+mID+"')",fadeTime);
			}
		}
		else
		{
			menu.opacity+=0.01;
			menu.style.opacity=menu.opacity;
			if(menu.opacity<1)
			{
				window.setTimeout("addOpacity('"+mID+"')",fadeTime);
			}
		}
	}
}
function subOpacity(mID)
{
	var menu;
	if(menu = document.getElementById(mID))
	{
		if(menu.mOver==1)
		{
			showMenu(mID);
			return;
		}
		if(menu.show==1)
		{
			return;
		}
		if(document.all)
		{
			menu.opacity--;
			menu.style.filter='alpha(opacity='+menu.opacity+')';
		}
		else
		{
			menu.opacity-=0.01;
			menu.style.opacity=menu.opacity;
		}
		if(menu.opacity>0)
		{
			window.setTimeout("subOpacity('"+mID+"')",fadeTime);
		}
		else
		{
			menu.visibility="hidden";
		}
	}
}
function elClick(el)
{
	if(el=el.firstChild)
	{
		window.location=el;
	}
}
function checkAll(el)
{
	if(el.name.length==0)
	{
		var elements = document.getElementsByTagName("input");
		for(var c=0; c<elements.length; c++)
		{
			if(elements[c].className==el.className)
			{
				elements[c].checked=el.checked;
			}
		}
	}
	else
	{
		var check=true;
		var elements = document.getElementsByTagName("input");
		var controllers = new Array(0);
		for(var c=0; c<elements.length; c++)
		{
			if(elements[c].className==el.className)
			{
				if(elements[c].name.length>0)
				{
					if(elements[c].checked==false)
					{
						check=false;
					}
				}
				else
				{
					var old = controllers;
					controllers = new Array(old.length+1);
					var i;
					for(i=0; i<old.length; i++)
					{
						controllers[i]=old[i];
					}
					controllers[i]=elements[c];
				}
			}
		}
		for(var i=0; i<controllers.length; i++)
		{
			controllers[i].checked=check;
		}
	}
}
function performAction(el,form,message)
{//Delete-Edit (confirm for delete)
	if(el.value=="Delete")
	{
		if(confirm(message))
		{
			form.submit();
		}
		else
		{
			el.options[0].selected=true;
		}
	}
	else
	{
		form.submit();
	}
}
function showUpload(picObj)
{
	//alert(picObj.data+" "+picObj.field+" Primary Key = "+picObj.pri);
	picObj.copy=document.getElementById('uploadcopy');
	picObject=picObj;
	var upldWindow=window.open("?f=upload","Upload","width=375,height=200,scrollbars=no,status=yes");
	upldWindow.picObj=picObj;
}
function rePopulate(cat,subcat)
{//repopulate subCatagory menu
	if(subcat)
	{
		var array=subcat.optList[cat.value];
		if(!subcat.orgVal)
		{//set original selected value;
			subcat.orgVal=subcat.options[subcat.selectedIndex].value;
		}
		while(subcat.options.length>0)
		{
			subcat.options[subcat.options.length-1]=null;
			if(!document.all)
			{
				subcat.options.length--;
			}
		}
		if(array!=null)
		{
			for(var c=0; c<array.length; c++)
			{
				subcat.options[c]= new Option(array[c].name,array[c].value);
				if(array[c].value==subcat.orgVal)
				{
					subcat.selectedIndex=c;
				}
			}
		}
		if(subcat.optList[0])
		{
			subcat.options[subcat.length]=new Option('None',subcat.optList[0].value);
			if(subcat.orgVal==0)
			{
				subcat.selectedIndex=subcat.length-1;
			}
		}
	}
}
function makeToolbar()
{
		if((madeToolbar==0)&&(document.all)&&(document.execCommand('Bold')))
		{
			
		}
}
function onPost()
{
	return true;
}
function setDrag(event,el)
{
	if(!el.move)
	{
		if(document.all)
		{
			el.move=new Function('this.style.left = window.event.clientX - this.sx;this.style.top = window.event.clientY - this.sy;');
		}
		else
		{
			el.move=new Function('event','this.style.left = event.clientX - this.sx;this.style.top = event.clientY - this.sy;');
		}
	}
	if(!el.setSXY)
	{
		if(document.all)
		{
			el.setSXY=new Function('this.sx=(window.event.clientX-this.style.pixelLeft);this.sy=(window.event.clientY-this.style.pixelTop);');
		}
		else
		{
			el.setSXY=new Function('event','this.sx=(event.clientX-this.style.left);this.sy=(event.clientY-this.style.top);');
		}
	}
	dragee=el;
	dragee.setSXY(event);
	//event.returnValue = false;
	//event.cancelBubble = true;
}
function drag(event)
{
	if(dragee!=null)
	{
		dragee.move(event);
		//event.returnValue = false;
		//event.cancelBubble = true;
	}
}
function resetDrag()
{
	//document.getElementById('debug').innerHTML=dragee.sx;
	dragee = null;
}
function changeColor(grnd)
{
	var sColor = dlgHelper.ChooseColorDlg();
	sColor = sColor.toString(16);
	if (sColor.length < 6)
	{
		var sTempString = "000000".substring(0,6-sColor.length);
		sColor = sTempString.concat(sColor);
	}
	if(sColor!="Other")
	{
		document.execCommand(grnd, false, sColor);
	}
}
function pNums(num,element1,element2)
{
	if(element1.value.length==num)
	{
		element2.focus();
	}
}
function checkNum(el)
{
	if(event.keyCode!=8&&event.keyCode!=9&&(!(event.keyCode<41&&event.keyCode>36))&&(event.keyCode<46||event.keyCode>58))
	{
		//alert(event.keyCode);
		//event.returnValue=false;
	}
	//document.getElementsByName(mdiv.id).item(1).value=mdiv.innerHTML;
}
function uHTML(mdiv)
{
	/*if(event.keyCode==13)
	{
		//event.returnValue=false;
		var sRange  = document.selection.createRange();
		sRange.pasteHTML('<BR>&nbsp;');
		sRange.text="";
		event.keyCode=8;
	}*/
}
function showBar(el)
{
	document.getElementById('toolBar').style.visibility='visible';
	if(el!=div)
	{
		document.getElementById('toolBar').style.top=el.offsetTop-25;
		document.getElementById('toolBar').style.left=el.offsetLeft;
		div=el;
		//window.status="X: "+el.offsetTop+" Y: "+el.offsetLeft;
	}
}
function lookup( addr )
{
	var uWindow=window.open( addr, "Upload","width=600,height=400,scrollbars=yes,status=yes");

}
function chooseUser( user )
{
	var sel = window.opener.document.getElementById("userSelect");
	for(var c=0; c < sel.options.length; c++)
	{
		if(sel.options[c])
		{
			if(sel.options[c].value==user)
			{
				sel.selectedIndex=c;
				window.close();
			}
		}
	}
}
function clearForm()
{
	if(confirm("Do you really want to clear the form?"))
	{
		for(var c=0; c<document.f1.elements.length; c++)
		{
			var el = document.f1.elements[c];
			if(el.type=="text")
			{
				el.value="";
			}
		}
	}
}
function slideSize(w,h)
{
	var maxWidth=screen.width-200;
	var maxHeight=screen.height-300;
	w=parseInt(w);
	h=parseInt(h);
	maxWidth=parseInt(maxWidth);
	maxHeight=parseInt(maxHeight);
	if((w>h)&&(w>maxWidth))
	{
		h=((maxWidth*h)/(w));
		w=maxWidth;
		w=parseInt(w);
		h=parseInt(h);
	}
	if(h>maxHeight)
	{
		w=((maxHeight*w)/(h));
		h=maxHeight;
		w=parseInt(w);
		h=parseInt(h);
	}
	if(document.getElementById('slide'))
	{
		var slide=document.getElementById('slide');
		w=parseInt(w);
		h=parseInt(h);
		slide.width=w;
		slide.height=h;
	}
	var winWidth=w+20;
	var winHeight=h+100;
	//move - resize
	var x=(screen.width/2)-(winWidth/2);
	var y=(screen.height/2)-(winHeight/2);
	window.moveTo(x, y);
	window.resizeTo(winWidth,winHeight);
}
function slideShow(location)
{
	var slideWindow=window.open(location,"SlideShow","width=600,height=400,scrollbars=no,status=no");
}
function prcntCalc(off)
{
	var org = document.getElementById('Original').value;
	org = parseFloat(org);
	var dsc = document.getElementById('Discount').value;
	dsc = parseFloat(dsc);
	off = parseFloat(off);
	off=off/100;
	document.getElementById('Discount').value=org-(off*org);
}
function showPrcnt()
{
	var org = document.getElementById('Original').value;
	org = parseFloat(org);
	var dsc = document.getElementById('Discount').value;
	dsc = parseFloat(dsc);
	var off = org - dsc;
	window.status=off;
	document.getElementById('off').value = (off/org)*100;
}
