/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
} 
/*************************************************
* This function is used to disable the submit key unless it
* has been ticked or selected.
*************************************************/
function changeCheckbox() {
	if (document.testform.checkForm.checked == true) {
		document.testform.submitForm.disabled = false;
	} else {
		document.testform.submitForm.disabled = true;
	}
}
function changeMailoutSubmit() {
	if (document.enter_form.recipients.value == 'select') {
		document.enter_form.button3.disabled = true;
	} else {
		document.enter_form.button3.disabled = false;
	}
}
/*************************************************
* this function will disable the submit key and
* five other buttons (named button1-button5)
*************************************************/
function disableButtons() {
	document.enter_form.send.value = ' Working! ';
	document.enter_form.send.disabled = true;
	document.enter_form.button1.disabled = true;
	document.enter_form.button2.disabled = true;
	document.enter_form.button3.disabled = true;
	document.enter_form.button4.disabled = true;
	document.enter_form.button5.disabled = true;	
}
/************************************************
* this function is simular to the above, however
* this time a text value to place in the button
* is passed over and the url location is also
* passed over
************************************************/
function goAction(text,URL) {
	document.header.action.disabled = true;
	document.header.action.value = text;
	location.href=URL;
}
/*************************************************
* this function will bring up the development
* directory on the server, for putting files in
*************************************************/
function showdevdocs(devdir,devid) {
	day = new Date();
	id = day.getTime();
	developmentWin = window.open('',id,'width=800,height=600,top=2,left=1,status=no');
	developmentWin.document.write('<html><head><title>' + devid + '</title>');	
	developmentWin.document.write('<meta http-equiv="Refresh" content="0.1; url=' + devdir + devid + '">');	
	developmentWin.document.write('</head>');	
	developmentWin.document.write('<body>Opening Development Documents... Please Wait</body></html>');
	developmentWin.document.close();		
}
/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}
function overlay(curobj, subobjstr, opt_position){
	if (document.getElementById){
		var subobj=document.getElementById(subobjstr)
		subobj.style.display=(subobj.style.display!="block")? "block" : "none"
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
		subobj.style.left=xpos+"px"
		subobj.style.top=ypos+"px"
		return false
	}
else
	return true
}
function overlayclose(subobj){
	document.getElementById(subobj).style.display="none"
}
/*******************************************
* Custom JavaScript Functions by Shawn Olson
* Copyright 2006
* http://www.shawnolson.net
* this script selects all checkboxes in the form
*******************************************/
function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++){
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
			theForm[z].checked = theElement.checked;
		}
	}
}
/*************************************************
* this function makes the current field highlighted
* using focus in the CSS
*************************************************/
function inputFocus() {
   var inputs = getElementsByClassName(document, "input", "common");
   for (var i=0; i<inputs.length; i++) {
      inputs[i].onfocus = function() { this.className = 'focused' }
      inputs[i].onblur = function() { this.className = 'common' }
   } 
   var textareas = getElementsByClassName(document, "textarea", "common");
   for (var i=0; i<textareas.length; i++) {
      textareas[i].onfocus = function() { this.className = 'focused' }
      textareas[i].onblur = function() { this.className = 'common' }
   } 
   var selects = getElementsByClassName(document, "select", "common");
   for (var i=0; i<selects.length; i++) {
      selects[i].onfocus = function() { this.className = 'focused' }
      selects[i].onblur = function() { this.className = 'common' }
   } 
}
/************************************************
* this tag is used in the above insted of tagname
*  Written by Jonathan Snook, http://www.snook.ca/jonathan
*   Add-ons by Robert Nyman, http://www.robertnyman.com
************************************************/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return (arrReturnElements)
}
/*************************************************
* now to get it to work, we need to load the function
* in the doucment header
*************************************************/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
/*************************************************
* this function will bring up the callreport details
* stored in the call credit results database
*************************************************/
function showcallreport(URL) {
	var page = '/callreportResults.cfm?referenceID='+URL;
	window.open(page,"callreportWindow","width=690,height=600,top=5,left=5,scrollbars");
}
function showcallml(URL) {
	var page = '/callmlResults.cfm?referenceID='+URL;
	window.open(page,"callmlWindow","width=740,height=600,top=5,left=5,scrollbars");
}
/*************************************************
* and the web result as the customer sees it
*************************************************/
function showibresult(ID) {
	var page = 'http://admin.fccparagon.com/staff/view_instantsearch.cfm?applicantID='+ID;
	window.open(page,"callresultWindow","width=720,height=750,top=5,left=5,scrollbars,resize");
}
function showmlresult(ID) {
	var page = 'http://admin.fccparagon.com/staff/view_instantsearch.cfm?applicantID='+ID;
	window.open(page,"callmlresultWindow","width=720,height=750,top=5,left=5,scrollbars,resize");
}

/*************************************************
* this function will bring up the email details
* of a reference reply stord in the reply database
*************************************************/
function showemailreply(URL) {
	var page = '/referencereply.cfm?replyID='+URL;
	window.open(page,"ReferenceReplyWindow","width=690,height=600,top=5,left=5,scrollbars");
}

/*************************************************
* this function will bring up the details stored
* in mortgage applications (like a view form)
*************************************************/
function showMortgageFigures(URL) {
	var page = '/mortgage_figures.cfm?'+URL;
	window.open(page,"mortgageWindow","width=900,height=600,top=5,left=5,scrollbars");
}
/*************************************************
* this function will bring up the details from the
* postcode anywhere API in the address iframe
*************************************************/
function getAddress(Field,Postcode,Frame) {
	if(Frame == null) var Frame = 'addressFrame'; 
	var page = '/addressfinder.cfm?fieldID='+Field+'&postcodeID='+Postcode;
	addressWindow=open(page,Frame,"");
	if (addressWindow.opener == null) addressWindow.opener = self;
}
/*************************************************
* this function will bring up summary details of 
* customers in the customer iframe
*************************************************/
function getCustomer(type,customer,frame) {
	var page = '/customer_summary.cfm?type='+type+'&customerID='+customer;
	customerWindow=open(page,frame,"");
	if (customerWindow.opener == null) customerWindow.opener = self;
}
/*************************************************
* this function will bring up a new window and
* will display what has been passed over
*************************************************/
function showreport(URL) {
	var page = '/report.cfm?'+URL;
	window.open(page,"reportWindow","width=690,height=600,top=5,left=5,scrollbars");
}
function printreport(URL) {
	var page = '/print.cfm?'+URL;
	window.open(page,"printWindow","width=690,height=600,top=5,left=5,scrollbars");
}
function printschedule(URL) {
	var page = '/print.cfm?'+URL;
	window.open(page,"printWindow","width=690,height=600,top=5,left=5,scrollbars");
}
function printreference(URL) {
	var page = '/print.cfm?'+URL;
	window.open(page,"printrefWindow","width=690,height=600,top=5,left=5,scrollbars");
}
/*************************************************
* this function will bring up the details stored
* in reference applications (like an application fom)
*************************************************/
function showreference(URL) {
	var page = '/referenceapplication.cfm?referenceID='+URL;
	window.open(page,"referenceWindow","width=690,height=600,top=5,left=5,scrollbars");
}
/*************************************************
* this function will bring up the payment details
* from insurance payments - and will also allow 
* navigation between other payments for the policy
*************************************************/
function showinsurancepayment(PAY) {
	var page = '/report.cfm?action=view_payment&title=Payment History&paymentID='+PAY;
	window.open(page,"paymentWindow","width=400,height=560,top=5,left=5");
	
}
/*************************************************
* this function will bring up a new property popup
* window with PAGE being the cfm page loaded
*************************************************/
function popcontent(PAGE,TITLE,PAGEPARAM) {
	var page = '/property.cfm?action='+PAGE+'&title='+TITLE+'&popcontent=true&'+PAGEPARAM;
	window.open(page,"ReportpopWindow","width=1010,height=650,top=2,left=1,scrollbars=0,resizable=0,status=no");
}
/*************************************************
* this function will bring up the details stored
* in reference applications (like an application fom)
*************************************************/
function popevent(ID) {
	var page = '/event_details.cfm?eventID='+ID;
	window.open(page,"eventWindow","width=740,height=300,top=5,left=5,scrollbars,resize");

}
/*************************************************
* this opens up stats in a wallboard titled
* enviroment.
*************************************************/
function wallfigures(WB) {
	var wall1 = '/report.cfm?action=report_events&popcontent=true&title=Event Report'+WB
	window.open(wall1,"wall1","width=820,height=300,top=342,left=10");
	var wall2 = '/report.cfm?action=report_dailyfigures&popcontent=true&title=Daily Figures'+WB
	window.open(wall2,"wall2","width=820,height=300,top=0,left=10");
}
/*************************************************
* this clears any pre-loding divs on a page. The 
* pre load screen must have the id of prepage
*************************************************/
function loadImages() {
if (document.getElementById) {  // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) {  // Netscape 4
document.hidepage.visibility = 'hidden';
}
else {  // IE 4
document.all.hidepage.style.visibility = 'hidden';
      }
   }
}


