// JavaScript Document

images = new Array(4);

images[0] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner.gif' alt='Visit Computer Hope'></a>";

images[1] = "<a href = 'http://www.computerhope.com/history/index.htm'><img src='http://www.computerhope.com/banners/banner2.gif' alt='Computer History'></a>";

images[2] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'></a>";

images[3] = "<a href = 'http://www.computerhope.com/newslet.htm'><img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter'></a>";

index = Math.floor(Math.random() * images.length);

////////////////Rollover menu/////////////////
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];}
}


//// mypsc.net login script ////////
function win_open(url, w, h, scrol) {
			window.open(url, "", "width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrol+",resizable=no,copyhistory=no");
		}

// JavaScript Document
 
var ctrl=false; 
function phone_keydown(o,e) { 
 var k; 
 if (!e) var e = window.event 
 if (e.keyCode) k = e.keyCode; 
 else if (e.which) k = e.which; if(!o.value.match(/[!@#$%^&*()]+/) && ((k >= 48 && k <= 57) || (k >= 96 && k <= 105) ) && o.value.replace(/\-/,'').length <= 10) { 
       if(o.value.length == 3 || o.value.length == 7){ 
               o.value+="-"; 
       } 
return true; 
 }else if(k==8 || k==9 || k==37 || k==39 || k==46  || (k >= 35 && k <= 40) || (ctrl && (k==86 || k==67))) { 
       return true; 
 }else if(k==17){ 
       ctrl=true; 
 } 
return false; 
} 
function phone_keyup(o,e) { 
 var k; 
 if (!e) var e = window.event 
 if (e.keyCode) k = e.keyCode; 
 else if (e.which) k = e.which; 
if(k==17) 
       ctrl=false; 
o.value = o.value.replace(/[^0-9\-]/g,''); 
 
} 
 
function date_keydown(o,e) { 
 var k; 
 if (!e) var e = window.event 
 if (e.keyCode) k = e.keyCode; 
 else if (e.which) k = e.which; if(!o.value.match(/[!@#$%^&*()]+/) && ((k >= 48 && k <= 57) || (k >= 96 && k <= 105) ) && o.value.replace(/\-/,'').length <= 7) { 
       if(o.value.length == 2 || o.value.length == 5){ 
               o.value+="/"; 
       } 
return true; 
 }else if(k==8 || k==9 || k==37 || k==39 || k==46  || (k >= 35 && k <= 40) || (ctrl && (k==86 || k==67))) { 
       return true; 
 }else if(k==17){ 
       ctrl=true; 
 } 
return false; 
} 

function zip_keydown(o,e) { 
 var k; 
 if (!e) var e = window.event 
 if (e.keyCode) k = e.keyCode; 
 else if (e.which) k = e.which; if(!o.value.match(/[!@#$%^&*()]+/) && ((k >= 48 && k <= 57) || (k >= 96 && k <= 105) ) && o.value.replace(/\-/,'').length <= 4) { 
return true; 
 }else if(k==8 || k==9 || k==37 || k==39 || k==46  || (k >= 35 && k <= 40) || (ctrl && (k==86 || k==67))) { 
       return true; 
 }else if(k==17){ 
       ctrl=true; 
 } 
return false; 
}
function state_keydown(o,e) { 
 var k; 
 if (!e) var e = window.event 
 if (e.keyCode) k = e.keyCode; 
 else if (e.which) k = e.which; if(!o.value.match(/[!@#$%^&*()]+/) && (k >= 65 && k <= 90) && o.value.replace(/\-/,'').length <= 1) { 
return true; 
 }else if(k==8 || k==9 || k==37 || k==39 || k==46  || (k >= 35 && k <= 40) || (ctrl && (k==86 || k==67))) { 
       return true; 
 }else if(k==17){ 
       ctrl=true; 
 } 
return false; 
}

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}	
	
	function getCity(strURL,div) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById(div).innerHTML=req.responseText;					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}	

var counter = 0;

function showhideText(box){
	var elm1 = document.getElementById('outofcacourt'); 
	//var elm2 = document.getElementById('outofcabranch'); 
	var elm3 = document.getElementById('localcounty'); 
	var elm4 = document.getElementById('localcourt'); 
	//var elm5 = document.getElementById('localbranch'); 
	if(box.checked==false){
		elm1.style.display="none";
		//elm2.style.display="none";
		elm3.style.display="";
		elm4.style.display="";
		//elm5.style.display="";
	}else{
		elm1.style.display="";
		//elm2.style.display="";
		elm3.style.display="none";
		elm4.style.display="none";
		//elm5.style.display="none";
	}
}
function showhideServe(box){
	var elmServe = document.getElementById('serve'); 
	if(box.value=="M"){
		elmServe.style.display="none";	
	}else{
		elmServe.style.display="";
	}
	var elmServeEntity = document.getElementById('serveentity'); 
	var elmServeEntityOpt = document.getElementById('serveentityoption'); 
	var elmServeEOption=document.getElementsByName('serveentity'); 
	if(box.value=="X"){
			elmServeEntity.style.display="";	
		if(eval('frm.serveentity.value')=="O" || eval('frm.serveentity.value')=="+"){
			elmServeEntityOpt.style.display="";
		} 
	}else{
		elmServeEntity.style.display="none";
		elmServeEntityOpt.style.display="none";
	}	
}
/*function showhideName(box){
	var elmDoc = document.getElementById('docType'); 
	if(box.value=="OTHER"){
		elmDoc.style.display="";	
	}else{
		elmDoc.style.display="none";
	}
}*/
function showhideServeEntity(box){
	var elmServeEntityOpt = document.getElementById('serveentityoption'); 
	if(box.value=="O" || box.value=="+"){
		elmServeEntityOpt.style.display="";	
	}else{
		elmServeEntityOpt.style.display="none";
	}
}
function init() {
	document.getElementById('moreFields').onclick = moreFields;
	moreFields();
}

function moreFields() {
	counter++;
	var newFields = document.getElementById('readroot').cloneNode(true);
	newFields.id = '';
	newFields.style.display = 'block';
	var newField = newFields.childNodes;
	for (var i=0;i<newField.length;i++) {
		var theName = newField[i].name
		if (theName)
			newField[i].name = theName + counter;
	}
	var insertHere = document.getElementById('writeroot');
	insertHere.parentNode.insertBefore(newFields,insertHere);
}
var counter = 1;
var limit = 3;
function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the limit of adding " + counter + " inputs");
     }
     else {
          var newdiv = document.createElement('div');
         // newdiv.innerHTML = "Entry " + (counter + 1) + " <br><input type='text' name='myInputs[]'>";
		  newdiv.innerHTML = " <hr />Address " + (counter + 1) + " <br><input type='text' name='"+(counter + 1)+"'><br>City, State, Zip<br><input type='text' name='city"+(counter+1)+"' class='medium'> <input type='text' name='state"+(counter+1)+"' class='small'> <input type='text' name='zip"+(counter + 1)+"' class='medium' value='' > Home " + (counter + 1) + "<input type='radio' name='addresstype"+(counter + 1)+"' class='checkbox' checked='checked'/> Business " + (counter + 1) + "<input type='radio' name='addresstype"+(counter + 1)+"' class='checkbox'/>";

		  //newdiv.innerHTML = "Address " + (counter + 1) + " <br><input type='text' name='myInputs'"+(counter + 1)+"'>";
          document.getElementById(divName).appendChild(newdiv);
          counter++;
     }
}

////////////////auto complete for document name/////////
/*var xmlHttp;
			textfocus = false;
			function getvalue(){
				value = document.getElementById('docname').value;
				return value;
			}
			function dataget(){	
				value = getvalue();
				if(value.length > 0){
					xmlHttp = GetXmlHttpObject();
					if (xmlHttp==null)
					  {
					  alert ("Your browser does not support AJAX!");
					  return;
					  } 
					var url="/order/docname.php?ajax=dropdown&value="+value+"";
					url=url+"&sid="+Math.random();
					xmlHttp.onreadystatechange = function(){
															if (xmlHttp.readyState == 4){   
																var output = xmlHttp.responseText;
																if(output != ""){
																	dropshow();
																	document.getElementById('drop').innerHTML=output;
																}
																else{
																	drophide();
																}
															}
												}
					xmlHttp.open("GET",url,true);
					xmlHttp.send(null);
				}
				else{
					drophide();
				}
			}
			function drophide(){
				if(document.getElementById('drop')){
					document.getElementById('drop').style.display="none";
				}
			}
			function dropshow(){
				if(document.getElementById('drop')){
					document.getElementById('drop').style.display="block";
				}
			}
			function insert(place){				
				drophide();
				document.getElementById('docname').value=place;
				
			}
			function GetXmlHttpObject(){
				var xmlHttp=null;
				try{
					xmlHttp=new XMLHttpRequest();
				}
				catch (e){
					try{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e){
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
				}
				return xmlHttp;
			}
			function findselected(){
				for(i=0;i<findnumber();i++){
					if(document.getElementById('drop').childNodes[i].className == "dropitemselected"){
						return i;
						break;
					}
				}
			}
			function findnumber(){
				y = 0;
				while(true){
					if(document.getElementById('drop').childNodes[y]){
						y++;
					}
					else{
						return y;
						break;
					}
				}
			}
			function Key_Up(e) {
				if(e.keyCode){
					code = e.keyCode;
				}
				else if (e.which){
					code = e.which;
				} 
				var keyChar = String.fromCharCode(code);
				if(keyChar == "&" || keyChar == "("){
					document.getElementById('drop').childNodes[0].focus();
					if(keyChar == "("){
						itemup();
					}
					else if(keyChar == "&"){
						itemdown();
					}
				}
				else if(keyChar == "'"){
					selected = findselected();
					document.getElementById('drop').style.display="none";
					place = document.getElementById('drop').childNodes[selected].innerHTML;
					document.getElementById('text').value=place;
				}
				else{
					if(textfocus==true){
						dataget();
					}
				}
			}
			function On_Click(e) {
				drophide()
			}
			function itemup(){
				selected = findselected();
				newselected = selected + 1;
				if(newselected < findnumber()){
					document.getElementById('drop').childNodes[newselected].style.backgroundColor="#C4EFA7";
					document.getElementById('drop').childNodes[selected].style.backgroundColor="#FFFFFF";
					document.getElementById('drop').childNodes[newselected].className = "dropitemselected";
					document.getElementById('drop').childNodes[selected].className = "dropitem";
				}			
			}
			function itemdown(){
				selected = findselected();
				newselected = selected - 1;
				if(newselected >= 0){
					document.getElementById('drop').childNodes[newselected].style.backgroundColor="#C4EFA7";
					document.getElementById('drop').childNodes[selected].style.backgroundColor="#FFFFFF";
					document.getElementById('drop').childNodes[newselected].className = "dropitemselected";
					document.getElementById('drop').childNodes[selected].className = "dropitem";
				}
			}
			if(document.addEventListener){
				document.addEventListener('keyup', Key_Up, false);
			} 
			else if (document.attachEvent){
				document.attachEvent('onkeyup', Key_Up);
			}
			if(document.addEventListener){
				document.addEventListener('click', On_Click, false);
			} 
			else if (document.attachEvent){
				document.attachEvent('onclick', On_Click);
			}
	*/		
			


