﻿function tos(){window.open('tos.htm','tos','width=600,height=400,toolbar=no,resizable=yes,location=no,scrollbars=yes,menubar=yes');}

function legal(){window.open('legal.htm','tos','width=600,height=400,toolbar=no,resizable=yes,location=no,scrollbars=yes,menubar=yes');}

function privacy(){window.open('privacy.htm','tos','width=600,height=400,toolbar=no,resizable=yes,location=no,scrollbars=yes,menubar=yes');}

function isn_privacy(){window.open('isn_privacy.htm','tos','width=600,height=400,toolbar=no,resizable=yes,location=no,scrollbars=yes,menubar=yes');}

function cvv2(){window.open('cvv2.htm','tos','width=440,height=250,toolbar=no,resizable=yes,location=no,scrollbars=yes,menubar=yes');}

function fpwd(){
    if(document.getElementById("luid").value == ''){
        alert('Please enter your e-mail address into the e-mail field\nand then click on the "Forgot Password" link again.');
    }else{
        window.open('fpwd.aspx?ea=' + document.getElementById("luid").value, '_top');   
    }  
}

function fpwd_wsr(oid){
    if(document.getElementById("luid").value == ''){
        alert('Please enter your e-mail address into the e-mail field\nand then click on the "Forgot Password" link again.');
    }else{
        window.open('wsr_fpwd.aspx?wsroid=' + oid + '&ea=' + document.getElementById("luid").value, '_self');   
    }  
}

function checksignup(){
    if(document.getElementById("fname").value == '' || document.getElementById("lname").value == '' || document.getElementById("email").value == '' || document.getElementById("pwd").value == '' || document.getElementById("postalcode").value == '' || document.getElementById("confirm").value == ''){
            alert('Please fill out all fields marked with a red asterisks');
       }else{
            document.getElementById("frmSignup").submit();
       }
}

function login(){
    if(document.getElementById("luid").value == '' || document.getElementById("lpwd").value == ''){
        alert('Your e-mail address and password is required.');
    } else {
        document.getElementById("frmLogin").submit();
    } 
}

function proc(){
    if(document.getElementById('agree').checked){
        document.getElementById('procbutton').disabled = true; 
        document.getElementById('frmproc').submit(); 
    }else{
        alert('You must agree to the Terms of Service by clicking on the checkbox');
    }  
}


function calc_total(){
    if(isNaN(document.getElementById('itemquant').value) || document.getElementById('itemquant').value == ''){
        alert('This field requires a numeric value.');
        document.getElementById("qty").value = '1';
        document.getElementById("itemquant").value = '1';
        document.getElementById("iqtot").value = '$8.00';
    }else if(document.getElementById("itemquant").value > 10){
        alert('Quantities of greater than 10 requires special pricing \nPlease contact us at members@inquirestyle.com');
        document.getElementById("qty").value = '1';
        document.getElementById("itemquant").value = '1';
        document.getElementById("iqtot").value = '$8.00';
    }else{ 
        document.getElementById("iqtot").value = parseFloat(document.getElementById("itemquant").value) * 8;
        formatCurrency(document.getElementById("iqtot"), 1); 
    } 
}

function formatCurrency(thefield, showsign) {
	if (formatCurrency.arguments.length == 1) showsign = 1;
	thefield.value = thefield.value.toString().replace(/\$|\,/g,'');
	if(isNaN(thefield.value)) thefield.value = "0";
	sign = (thefield.value == (thefield.value = Math.abs(thefield.value)));
	thefield.value = Math.round(thefield.value*100);
	cents = thefield.value%100;
	thefield.value = Math.floor(thefield.value/100).toString();
	
	if(cents<10){
//	    cents = "00" + cents;
//	}else if(cents<100){
	    cents = "0" + cents;
	} 

	for (var i = 0; i < Math.floor((thefield.value.length-(1+i))/3); i++)
	    thefield.value = thefield.value.substring(0,thefield.value.length-(4*i+3))+ ',' + thefield.value.substring(thefield.value.length-(4*i+3));

	if (showsign == 1){
	    thefield.value = (((sign)?'':'-') + '$' + thefield.value + '.' + cents);
	}else{
	    thefield.value = (((sign)?'':'-') + thefield.value + '.' + cents);
    }
}

function NoEdit(fld, flddesc){
	fld.style.border = "solid 1px #F1F4FA";
	fld.style.backgroundColor = "#F1F4FA";
	fld.blur();
	//alert('The "' + flddesc + '" field cannot be edited');
}

function openrep(url){
    var h = screen.availHeight - 150; 
    var w = screen.availWidth - 100; 
    window.open(url,'orderform','location=no,toolbar=no,menubar=yes,resizable=yes,status=no,width=' + w + ',height=' + h + ',top=50,left=50');
}
