// JavaScript Document


function showHide(msgID) 
{     
    var dv = document.getElementById(msgID); 
    dv.style.display = dv.style.display == "none" ? "block" : "none"; 
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}


function popupEvent(day, month, year, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	win = window.open("calendar/popup.php?day=" + day + "&month=" + month + "&year=" + year + "","Calendar","scrollbars=yes, status=yes, location=no, toolbar=no, menubar=no, directories=no, resizable=yes, width=" + w + ", height=" + h + ", top=" + wint + ", left=" + winl + "");
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}
function popupEventSingle(idnum, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	win = window.open("calendar/popup.php?event=" + idnum + "","Calendar","scrollbars=yes, status=yes, location=no, toolbar=no, menubar=no, directories=no, resizable=yes, width=" + w + ", height=" + h + ", top=" + wint + ", left=" + winl + "");
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}








function goURL(location) {
		<!--
		window.location = location+'index.php';
		//-->
		}


function showdiv(msgID) 
{     
    var dv = document.getElementById(msgID); 
    dv.style.display = dv.style.display = "block"; 
} 
function hidediv(msgID) 
{     
    var dv = document.getElementById(msgID); 
    dv.style.display = dv.style.display = "none"; 
} 


function hideAll(letter,maxnum) {
var ccount = 1;

while(ccount < maxnum){
	hidediv('a'+ccount);
	ccount++;
	}
	

}





<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->




function editlinks(idnum,wwidth,hheight) { //v2.0
	if(!wwidth){ wwidth=500; }
	if(!hheight){ hheight=600; }
	 MM_openBrWindow('includes/process_links.php?updatelinkid='+idnum,'report','scrollbars=yes,resizable=yes,width='+wwidth+',height='+hheight+'' );
}
function replaceDivContents(docid,message) {
	alert("Docid:"+docid+" Message:"+message);
	document.getElementById(docid).innerHTML = unescape(message);
}








<!--
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_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_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];}
}
//-->
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit http://www.dynamicdrive.com
/*
var message=""; 
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false") */
// --> 





////////////////////////////////////////////////////////////////////////////////////////////  AJAX  CODE //
// JavaScript Document

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
      if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
      } else if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
      }

    return ro;
}

var http = createRequestObject();

function sndReq(path,process,variables,type) {
   
   //var target = document.getElementById(target).value;
    //var action = action;
	if ((variables.length) > 2){
	http.open('get', path+'includes/js/ajax/'+process+'?'+variables);
 		//alert(variables);
    if(type == "js") { 
		http.onreadystatechange = handleResponseJS;
	}else{
		http.onreadystatechange = handleResponse;
		}
	
    http.send(null);
	}
	
}




function sndReqForm(path,FormName,ProcessName,type) {
	//	alert(FormName+'  '+ProcessName+'  '+type);
	//alert(document.getElementById(FormName).elements.length);
	var message = "";	
	var rownum = 0;
	var fieldname = "";
	var fieldval = "";
	var filelink = "";
	for(i=0; i<document.getElementById(FormName).elements.length; i++)
				{
				fieldname = document.getElementById(FormName).elements[i].name;
				fieldval = document.getElementById(FormName).elements[i].value;
				if (rownum > 0) { message = message + "&"; }
				fieldval = fieldval.replace(/&/g, "--amp;") ;
				fieldval = fieldval.replace(/'/g, "--singlequote") ;
				fieldval = fieldval.replace(/"/g, "--doublequote") ;
				fieldval = fieldval.replace(/#/g, "--lbsign") ;
				//fieldval = fieldval.replace(/\|/g, "124;") ;
			
				message = message + fieldname  + "=" + fieldval ;
				rownum++;
				}
  filelink = path+'includes/js/ajax/'+ProcessName+'?'+message;
  
 // alert(filelink);
  

	http.open('get', path+'includes/js/ajax/'+ProcessName+'?'+message);
     if(type == "js") { 
		http.onreadystatechange = handleResponseJS;
	}else{
		http.onreadystatechange = handleResponse;
		}
    http.send(null);
//alert(filelink);
//alert(message);

}






function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
         // alert(update[0]+':'+update[1]);
        	document.getElementById(update[0]).innerHTML = update[1];
			if(update[2]){ eval(update[3]);}
			//if(update[2]){ document.getElementById(update[2]).innerHTML = update[3]; }
			
        }
    }
}

function handleResponseJS() {

    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();
  //alert('hey');
        if(response.indexOf('|' != -1)) {
         
		    update = response.split('|');
           // alert(update[1]);//document.getElementById(update[0]).innerHTML = update[1];
			eval(update[1]);
        }
    }
}


function echorand(value) {
	alert(value);
	}
	
	
	
function getTrimOptions(destination) {
	
	for (var i=0; i < document.form1.ctype.length; i++)  {
			   if (document.form1.ctype[i].checked) {
				  var ctype = document.form1.ctype[i].value;  }  }
	for (var i=0; i < document.form1.PaperType.length; i++)  {
			   if (document.form1.PaperType[i].checked) {
				  var PaperType = document.form1.PaperType[i].value;  }  }
	for (var i=0; i < document.form1.CoverType.length; i++)  {
			   if (document.form1.CoverType[i].checked) {
				  var CoverType = document.form1.CoverType[i].value;  }  }
			
	sndReq('includes/price_calculator/getTrimOptions.php','ctype='+ctype+'&PaperType='+PaperType+'&CoverType='+CoverType);
	
	//getMinMax();
	
	}
	

function getMinMax(boject) {
	len = document.form1.trimsedlect.length
	for (i = 0; i < len; i++) {
		if (document.form1.trimsedlect[i].selected) {
			var output = document.form1.trimsedlect[i].value
			sndReq('includes/price_calculator/getMinMax.php','id='+output); 
		} 
		}

	//alert(output);	
	
	
}
////////////////////////////////////////////////////////////////////////////////////////////  AJAX  CODE //












function getquestions(ids) {
	var idlist = ids;
	for(i in idlist)
				{
		 document.write('<script type="text/javascript" src="http://solomonexamprep.com/temp/ajaxtest2.php?qid=' + idlist[i] + '" ><\/script>'); /**/
				}
		}




function copyToClipboard(s) {
    if (window.clipboardData && clipboardData.setData) {
        clipboardData.setData('text', s);
    }
}









function submitFormOnEnter(formname, path, process) {
if (window.event.keyCode == 13)
{
	sndReqForm(path, formname, process);
//document.formname.submit();
}
} 








	window.defaultStatus="Calendar Script";

