
// Takes an image name and displays it, also accepts a window size
function ZoomImage(theimage, width, height) {
	if (!width) { width=800; }
	if (!height) { height=600; }
	windowprops = "height="+height+",width="+width+",location=no, scrollbars=yes,menubars=no,toolbars=no,resizable=yes";
	msgWindow = window.open('','new',windowprops);
	msgWindow.location.href = '/view_image.php?image=' + theimage;
	if (msgWindow.opener == null) msgWindow.opener = self;
}

// displays the help dialog box, it also accepts a window size
function OpenHelp(sys,feature, width, height) {
	if (!width) { width=450; }
	if (!height) { height=200; }
	var url = 'helpfile.php?sys=' + sys + '&feature=' + feature;
	windowprops = "height="+height+",width="+width+",location=no,"
	+ "scrollbars=no,menubars=no,toolbars=no,resizable=yes,statusbar=no";
	Onclick=window.open(url, "Help", windowprops);
}


function CouponCodes(pid) {
	var url = '/apply_coupon.php';
	windowprops = "height=250,width=410,location=no,"
	+ "scrollbars=no,menubars=no,toolbars=no,resizable=yes,statusbar=no";
	msgWindow = window.open('','Coupon',windowprops);
	msgWindow.location.href = '/apply_coupon.php?start_pid=' + pid;
	if (msgWindow.opener == null) msgWindow.opener = self;

}


function verify_secretq() {
	var question1 = document.register.secretq1.value;
	var question2 = document.register.secretq2.value;
	var answer = document.register.secreta.value;

	if ((question1) && (!question2)) {
		var question = question1;
		} else if ((question1) && (question2)) {
		var question = question1;
		} else {
		var question = question2;
		}

	if ((!question1) && (!question2) || (!answer)) {

		alert("You must choose a security question and answer before proceeding.");
		return false;
	} else {

	var agree=confirm("Please Verify!\n_______________________________________________\n\nYou want your security question to be:\n"+question+"?\n\nAnd the answer to be:\n"+answer+"\n_______________________________________________\n\nIf this is correct press OK, if not press Cancel and make the changes.");
	if (agree)
		return true;
		else
		return false;
	}
	return false;
}

function flip() {
    if (document.images)
        document.images['pleasewait'].src = '/images/wait.gif';
}



function validate_checkout() {


	var cc_num = document.checkout.cc_num.value;
	var ccexp_month = document.checkout.ccexp_month.value;
	var ccexp_year = document.checkout.ccexp_year.value;
	var cnp_security = document.checkout.cnp_security.value;
	var cnp_security = document.checkout.cnp_security.value;
	var billing_address = document.checkout.billing_address.value;
	var billing_phone = document.checkout.billing_phone.value;
	var billing_city = document.checkout.billing_city.value;
	var billing_state = document.checkout.billing_state.value;
	var billing_zip = document.checkout.billing_zip.value;


	var address = document.checkout.address.value;
	var phone = document.checkout.phone.value;
	var city = document.checkout.city.value;
	var state = document.checkout.state.value;
	var zip = document.checkout.zip.value;


	if (!address) {  var num = num + 1; alert("You must provide a shipping address. Press the Change link next to Shipping Address to add a shipping address."); return false; }
	if (!phone) {  var num = num + 1; alert("You must provide a shipping address. Press the Change link next to Shipping Address to add a shipping address."); return false; }
	if (!city) {  var num = num + 1; alert("You must provide a shipping address. Press the Change link next to Shipping Address to add a shipping address."); return false; }
	if (!state) {  var num = num + 1; alert("You must provide a shipping address. Press the Change link next to Shipping Address to add a shipping address."); return false; }
	if (!zip) {  var num = num + 1; alert("You must provide a shipping address. Press the Change link next to Shipping Address to add a shipping address."); return false; }

	if (!billing_address) {  var num = num + 1; alert("You must provide a billing address. Press the Change link next to Billing Address to add a billing address."); return false; }
	if (!billing_phone) {  var num = num + 1; alert("You must provide a billing address. Press the Change link next to Billing Address to add a billing address."); return false; }
	if (!billing_city) {  var num = num + 1; alert("You must provide a billing address. Press the Change link next to Billing Address to add a billing address."); return false; }
	if (!billing_state) {  var num = num + 1; alert("You must provide a billing address. Press the Change link next to Billing Address to add a billing address."); return false; }
	if (!billing_zip) {  var num = num + 1; alert("You must provide a billing address. Press the Change link next to Billing Address to add a billing address."); return false; }

if (document.checkout.use_file.value != '1') {

	if (!cc_num) { var num = num + 1; alert("You must provide a valid credit card number.\nExample: 4208700000000000"); return false;   }
	if (!ccexp_month) { var num = num + 1; alert("You must provide a valid credit card expiration month.\nExample: 01");  return false; }
	if (!ccexp_year) {  var num = num + 1; alert("You must provide a valid credit card expiration year.\nExample: 2005"); return false; }
	if (!cnp_security) {  var num = num + 1; alert("You must provide your security code. This can be found on the back of your credit card usually on the right side of the signature strip.\nExample: 516"); return false; }
}

	if (num) {
		alert("You must provide a valid credit card number and expiration date.");
		return false;
	} else {
		flip();
		//document.images['pleasewait'].src = '/images/wait.gif';
	 //return true;
	}
}


function change_address(type,ordernum) {
	var w = 1000, h = 640;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var popW = 570, popH = 470;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	var url = '/change_address.php';
	windowprops = "height=470,width=570,location=no,"
	+ "scrollbars=no,menubars=no,toolbars=no,resizable=yes,statusbar=no,top="+topPos+",left="+leftPos;
	msgWindow = window.open('','ChAddress',windowprops);
	msgWindow.location.href = '/change_address.php?type=' + type + '&order_num=' + ordernum;
	if (msgWindow.opener == null) msgWindow.opener = self;

}


function check_val(val) {
	if (val != 'Use the card info provided below.') {
		hideshow_NewCard('hide');
		document.checkout.use_file.value = 1;
	} else {
		hideshow_NewCard('');
		document.checkout.use_file.value = '';
	}
}


function hideshow_NewCard(hide) {
  if (document.layers)
    document.cardContainer.visibility = hide ? 'hide' : 'show';
  else {
    var g = document.all ? document.all.cardContainer :
              document.getElementById('cardContainer');
    g.style.visibility = hide ? 'hidden' : 'visible';
  }
}



// displays the help dialog box, it also accepts a window size
function FastRIP_Support(width, height) {
	if (!width) { width=450; }
	if (!height) { height=500; }
	var url = 'http://fastfilms.com/fastrip/users/tech_feedback.php';
	windowprops = "height="+height+",width="+width+",location=no,"
	+ "scrollbars=yes,menubars=no,toolbars=no,resizable=yes,statusbar=no";
	Onclick=window.open(url, "FastRIP_Support", windowprops);
}


// displays the help dialog box, it also accepts a window size
function White_Ink(width, height) {
	if (!width) { width=640; }
	if (!height) { height=600; }
	var url = '/products/tjetfamily/white_faq.html';
	windowprops = "height="+height+",width="+width+",location=no,"
	+ "scrollbars=yes,menubars=no,toolbars=no,resizable=yes,statusbar=no";
	Onclick=window.open(url, "White_FAQ", windowprops);
}

// Opens a popup with the answer to a question from the T-Jet Central FAQ
function TJCFAQ(id, width, height) {
	if (!width) { width=700; }
	if (!height) { height=340; }
	windowprops = "height="+height+",width="+width+",location=no, scrollbars=yes,menubars=no,toolbars=no,resizable=yes";
	msgWindow = window.open('','new',windowprops);
	msgWindow.location.href = '/tjc_faq.php?id=' + id;
	if (msgWindow.opener == null) msgWindow.opener = self;
}

// Opens a popup with the answer to a question from the T-Jet Central FAQ
function Additional_TJ_Warranty(id, width, height) {
	if (!width) { width=700; }
	if (!height) { height=340; }
	windowprops = "height="+height+",width="+width+",location=no, scrollbars=yes,menubars=no,toolbars=no,resizable=yes";
	msgWindow = window.open('','new',windowprops);
	msgWindow.location.href = '/warranty_info.php?pid=' + id;
	if (msgWindow.opener == null) msgWindow.opener = self;
}