/* popup to show order */
function viewOrder(OID){
    if (OID != ""){
        URL = 'order_confirmation.php?OID=' + OID;
        window.open(URL, 'Order', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600,left = 390,top = 212');
    }        
}

/* format the phone number */
function formatPhoneNumber(isField){

    isPhone = isField.value;
    
    if (isPhone.length == 10){
        isPhone = isPhone.replace(/\D/g,'').replace(/^(\d{3})(\d{3})/,'$1-$2-');
        isField.value = isPhone;
    }else if (isPhone.length >= 12 && isPhone.length <= 16){
        isPhone = isPhone.replace('(', '');
        isPhone = isPhone.replace(')', '');
        isPhone = isPhone.replace(/\D/g,'').replace(/^(\d{3})(\d{3})/,'$1-$2-');
        isField.value = isPhone;
    }
}

function populateCellPhone(phoneFieldID, cellPhoneFieldID){
    
    document.getElementById(cellPhoneFieldID).value = document.getElementById(phoneFieldID).value;
}

/* function to submit to form */
function submitForm(formID, formFieldID, formFieldValue){
	//set the formFieldValue
	document.getElementById(formFieldID).value = formFieldValue;
	
	//submit the form
	document.getElementById(formID).submit();
}

/* Function to submit form on enter key */
function enterKeySubmit(form, e){
	var key;
	if (window.event){
	  key = window.event.keyCode;     //IE
	}else{
	  key = e.keyCode;     //firefox
	}

	if (key == 13){
		form.submit();
	}
}

function resizeIFrame(){
	try {
		parent.socket.postMessage(getDocHeight());
	}catch(err){}
}

//get the document height
function getDocHeight() {
				
	//alert(D.body.scrollHeight + "-" + D.documentElement.scrollHeight + "-");
	//alert(D.body.offsetHeight + "-" + D.documentElement.offsetHeight + "-");
	//alert(D.body.clientHeight + "-" + D.documentElement.clientHeight + "-");
	
	//check the versions
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
		return document.body.scrollHeight;
	}else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
		return document.documentElement.offsetHeight;
	}else{
		return document.documentElement.offsetHeight;
	}
} 

