
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) { //v3.0
  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); 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];}
}

function reportMultiple(){
	var options_string = "";
	var the_select = window.document.form_1.payments_accepted;
	for (loop=0; loop < the_select.options.length; loop++)
	{
		if (the_select.options[loop].selected == true)
		{
		 options_string += the_select.options[loop].text + " ";
		}
	}
	$payments_accepted = options_string;
	alert("you selected: " + options_string);
	
}
function validatearticle(f) {
	if(!notifyUser(f.f_title, 'title')) return false;
	if(!notifyUser(f.f_short_description, 'short description')) return false;
	if(!notifyUser(f.f_long_description, 'long description')) return false;
}
function validateCard(f) {
	if(!notifyUser(f.cc_num, 'credit card number')) return false;
	if(!notifyUser(f.cc_exp_month, 'expiry month')) return false;
	if(!notifyUser(f.cc_exp_year, 'expiry year')) return false;
	if(!notifyUser(f.cc_name, 'name on credit card')) return false;
}

function validateCustomer(f){
	if(!notifyUser(f.f_first_name, 'first name')) return false;
	if(!notifyUser(f.f_last_name, 'last name')) return false;
	if(!notifyUser(f.f_day_phone, 'daytime phone number')) return false;
	if(!notifyUser(f.f_email, 'email')) return false;
	if(!notifyUser(f.f_bill_address_line1, 'billing address')) return false;
	if(!notifyUser(f.f_bill_address_line2, 'billing address')) return false;
}

function validateCheckout(f){
	if(!notifyUserSelect(f.f_freight_zone_id, 'Freight Zone')) return false;
	if(!notifyUser(f.f_first_name, 'first name')) return false;
	if(!notifyUser(f.f_last_name, 'last name')) return false;
	if(!notifyUser(f.f_day_phone, 'daytime phone number')) return false;
	if(!notifyUser(f.f_email, 'email')) return false;
	if(!notifyUser(f.f_bill_address_line1, 'billing address')) return false;
	if(!notifyUser(f.f_bill_address_line2, 'billing address')) return false;

}
function validate(f){
	if(!notifyUser(f.category_id, 'category')) return false;
	if(!notifyUser(f.product_name, 'product_name')) return false;
	if(!notifyUser(f.short_description, 'short_description')) return false;
	if(!notifyUser(f.price, 'price')) return false;
}
function validateAnimal(f){
	if(!notifyUser(f.fspecies, 'Species')) return false;
	if(!notifyUser(f.fname, 'name of your Animal')) return false;
	if(!notifyUser(f.fgender, 'gender')) return false;
	if(!notifyUser(f.fage, 'age for your animal')) return false;
	if(!notifyUser(f.fdescription, 'description of health problem')) return false;
	if(!notifyUser(f.ftreatments_tried, 'description of treatments already tried for your animal')) return false;
	if(!notifyUser(f.fprevious_history, 'previous health history')) return false;
	if(!notifyUser(f.fcurrent_medications, 'description of current medications')) return false;
}


function notifyChecked(ctl,msg) {
	if(ctl.checked == false)	{
	    alert('Please accept our ' + msg + '.');
        status='Please select a ' + msg + '.';
        document.MM_returnValue = true;
	    //ctl.select();
	    return false;
    }
    return true;
}

function notifyUserSelect(ctl, msg){
	if(ctl.value == 'X')	{
	    alert('Please select a ' + msg + '.');
        status='Please select a ' + msg + '.';
        document.MM_returnValue = true;
	    //ctl.select();
	    return false;
    }
    return true;
}

function notifyUser(ctl, msg){
	if(ctl.value == '')	{
	    alert('Please enter a valid ' + msg + '.');
        status='Please enter a valid ' + msg + '.';
        document.MM_returnValue = true;
	    ctl.select();
	    return false;
    }
    return true;
}


function currency() 
{popup = window.open("currency.htm","POPUP", "status=no,toolbar=no,location=no,scrollbars=yes,width=600,height=400");
}	
function borrow() 
{popup = window.open("borrow.htm","POPUP", "status=no,toolbar=no,location=no,scrollbars=yes,width=600,height=400");
} 
function paymethod() 
{popup = window.open("paymethod.htm","POPUP", "status=no,toolbar=no,location=no,scrollbars=yes,width=600,height=400");
}				
var MAXDESCLENGTH = 8;
function checkPword(theField) {
	if (theField.value.length<MAXDESCLENGTH)
		alert("Sorry, this password must be "+MAXDESCLENGTH+" characters or more.  Please re-enter.");
	else if (document.theForm.f_password_v.value != document.theForm.f_password.value) 
			if(document.theForm.f_password_v.value != "")
			alert("The password differs from the password validation.  Please re-enter.");
}

var reEmail = /^.+\@.+\..+$/
function isEmail(ctl)
{   
    if(!reEmail.test(ctl.value) || ctl.value == '')
    {
        alert('Please enter a valid email address. \n\nFor example: someone@somewhere.com\n or someone@somewhere.co.nz');
        status='Please enter a valid email address.';
        document.MM_returnValue = true;
        ctl.select();
        return false;
    }
    return true;
}

var reDate = new RegExp("[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]");
function isDate(ctl)
{   
    if(!reDate.test(ctl.value) )
    {
        alert('Please enter a valid date. \n\nUse format: DD/MM/YYYY or 23/11/2003');
        status='Please enter a valid date.';
        document.MM_returnValue = true;
        ctl.select();
        return false;
    }
    return true;
}
function printWindow(){
browserVersion = parseInt(navigator.appVersion)
if (browserVersion >= 4) window.print()
}

function checkComplete(f) {
  if (f.adate.value == '')
	  if (f.aname.value == '')
		   if (f.atype.value == '') 
			    if (f.adescription.value == '')
	alert("Nothing entered!!. Press the Back button to return to Customer Details");
	return false;
}

function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function confirmDelete(URL) {
	if ( confirm("Are you sure you want to delete this record ?") ) {
		document.location=URL;
	}
}
function jumper(selectList) {
	urlAppend = selectList.options[selectList.selectedIndex].value;
	//selectList.form.reset();
	document.location = urlAppend;
}
function deciCorr(value) {
	if (value<=0.99) {
		newDoll = '0';
	} else {
		newDoll = parseInt(value);
	}
	newCents = parseInt((value+.0008 - newDoll)* 100);
	if (eval(newCents) <= 9) newCents='0'+newCents;
	newString = newDoll + '.' + newCents;
	return (newString);
}


