var popupWindow= null;

function open_window(url,name,width,height,scrolling,top,resizable) {
                popupWindow1 = window.open(url,name,"scrollbars="+scrolling+",top="+top+",location=0,directories=0,status=0,resizable="+resizable+",width="+width+",height="+height+"");
                popupWindow1.location.href = url;
                popupWindow1.focus()
                if (popupWindow1.opener==null) {
                                popupWindow1.opener = this;
                }
}
function change_contents(new_contents) {
	var referrer = location.search.substring(1);
//if return to thumbnails, new_contents will be in the form 'blank?#id'
//permitting us to substitute the referrer for 'blank'
	var reg_exp = /blank/g;
	if(reg_exp.test(new_contents)) {
		new_contents = new_contents.replace(reg_exp,referrer);
	}
//if not a return to thumbnails, new_contents will just pass on the original referrer
// 040730 I cannot remember why this case is relevant and it appends a ? to the target
// which frustrates the anchor
//	else {
// 	new_contents = new_contents +"?"+referrer;
//	}

	self.location=new_contents;
}

function ChooseLot1()
{
	var choice; 
	switch (document.form1.lot1[document.form1.lot1.selectedIndex].text) {
		case "001":		{choice='..\\GRV\\imgs\\mac001.htm?../all.htm';break;}
		case "002":		{choice='..\\GRV\\imgs\\mac002.htm?../all.htm';break;}
	   case "003":    {choice='..\\GRV\\imgs\\mac003.htm?../all.htm';break;}
	   case "004":		{choice='..\\GRV\\imgs\\mac004.htm?../all.htm';break;}
		case "005":    {choice='..\\GRV\\imgs\\mac005.htm?../all.htm';break;}
		case "006":    {choice='..\\GRV\\imgs\\mac006.htm?../all.htm';break;}
		case "007":		{choice='..\\GRV\\imgs\\mac007.htm?../all.htm';break;}
		case "008":    {choice='..\\GRV\\imgs\\mac008.htm?../all.htm';break;}
		case "009":    {choice='..\\GRV\\imgs\\mac009.htm?../all.htm';break;}
		case "010":    {choice='..\\GRV\\imgs\\mac010.htm?../all.htm';break;}
		case "011":    {choice='..\\GRV\\imgs\\mac011.htm?../all.htm';break;}
		case "012":		{choice='..\\GRV\\imgs\\mac012.htm?../all.htm';break;}
	   case "013":    {choice='..\\GRV\\imgs\\mac013.htm?../all.htm';break;}
		case "014":    {choice='..\\GRV\\imgs\\mac014.htm?../all.htm';break;}
		case "015":    {choice='..\\GRV\\imgs\\mac015.htm?../all.htm';break;}
		case "016":    {choice='..\\GRV\\imgs\\mac016.htm?../all.htm';break;}
		case "017":    {choice='..\\GRV\\imgs\\mac017.htm?../all.htm';break;}
		case "018":    {choice='..\\GRV\\imgs\\mac018.htm?../all.htm';break;}
		case "019":    {choice='..\\GRV\\imgs\\mac019.htm?../all.htm';break;}
		case "020":    {choice='..\\GRV\\imgs\\mac020.htm?../all.htm';break;}
		case "021":    {choice='..\\GRV\\imgs\\mac021.htm?../all.htm';break;}
		case "022":		{choice='..\\GRV\\imgs\\mac022.htm?../all.htm';break;}
	   case "023":    {choice='..\\GRV\\imgs\\mac023.htm?../all.htm';break;}
		case "024":    {choice='..\\GRV\\imgs\\mac024.htm?../all.htm';break;}
		case "025":    {choice='..\\GRV\\imgs\\mac025.htm?../all.htm';break;}
		case "026":		{choice='..\\GRV\\imgs\\mac026.htm?../all.htm';break;}
		case "027":		{choice='..\\GRV\\imgs\\mac027.htm?../all.htm';break;}
		case "028":		{choice='..\\GRV\\imgs\\mac028.htm?../all.htm';break;}
		case "029":		{choice='..\\GRV\\imgs\\mac029.htm?../all.htm';break;}
		case "030":		{choice='..\\GRV\\imgs\\mac030.htm?../all.htm';break;}
		case "030a":	{choice='..\\GRV\\imgs\\mac030a.htm?../all.htm';break;}
	   case "030b":   {choice='..\\GRV\\imgs\\mac030b.htm?../all.htm';break;}
	   case "030c":	{choice='..\\GRV\\imgs\\mac030c.htm?../all.htm';break;}
		case "031":    {choice='..\\GRV\\imgs\\mac031.htm?../all.htm';break;}
		case "032":    {choice='..\\GRV\\imgs\\mac032.htm?../all.htm';break;}
		case "033":		{choice='..\\GRV\\imgs\\mac033.htm?../all.htm';break;}
		case "034":    {choice='..\\GRV\\imgs\\mac034.htm?../all.htm';break;}
		case "034a":   {choice='..\\GRV\\imgs\\mac034a.htm?../all.htm';break;}
		case "034b":   {choice='..\\GRV\\imgs\\mac034b.htm?../all.htm';break;}
		case "034c":   {choice='..\\GRV\\imgs\\mac034c.htm?../all.htm';break;}
		case "035":		{choice='..\\GRV\\imgs\\mac035.htm?../all.htm';break;}
	   case "036":    {choice='..\\GRV\\imgs\\mac036.htm?../all.htm';break;}
		case "038":    {choice='..\\GRV\\imgs\\mac038.htm?../all.htm';break;}
		case "039":    {choice='..\\GRV\\imgs\\mac039.htm?../all.htm';break;}
		case "039a":   {choice='..\\GRV\\imgs\\mac039a.htm?../all.htm';break;}
		case "040":    {choice='..\\GRV\\imgs\\mac040.htm?../all.htm';break;}
		case "041":    {choice='..\\GRV\\imgs\\mac041.htm?../all.htm';break;}
		case "042":    {choice='..\\GRV\\imgs\\mac042.htm?../all.htm';break;}
		case "043":    {choice='..\\GRV\\imgs\\mac043.htm?../all.htm';break;}
	}
	self.location = choice;
  
}
function ChooseLot2()
{
	var choice; 
	switch (document.form2.lot2[document.form2.lot2.selectedIndex].text) {
		case "044":		{choice='..\\GRV\\imgs\\mac044.htm?../rough.htm';break;}
		case "045":    {choice='..\\GRV\\imgs\\mac045.htm?../rough.htm';break;}
		case "046":		{choice='..\\GRV\\imgs\\mac046.htm?../rough.htm';break;}
		case "047":    {choice='..\\GRV\\imgs\\mac047.htm?../rough.htm';break;}
	   case "048":    {choice='..\\GRV\\imgs\\mac048.htm?../rough.htm';break;}
		case "049":    {choice='..\\GRV\\imgs\\mac049.htm?../rough.htm';break;}
		case "050":    {choice='..\\GRV\\imgs\\mac050.htm?../rough.htm';break;}
		case "051":		{choice='..\\GRV\\imgs\\mac051.htm?../rough.htm';break;}
		case "052":    {choice='..\\GRV\\imgs\\mac052.htm?../rough.htm';break;}
	   case "053":    {choice='..\\GRV\\imgs\\mac053.htm?../rough.htm';break;}
		case "054":    {choice='..\\GRV\\imgs\\mac054.htm?../rough.htm';break;}
		case "055":    {choice='..\\GRV\\imgs\\mac055.htm?../rough.htm';break;}
		case "056":		{choice='..\\GRV\\imgs\\mac056.htm?../rough.htm';break;}
		case "057":    {choice='..\\GRV\\imgs\\mac057.htm?../rough.htm';break;}
	   case "058":    {choice='..\\GRV\\imgs\\mac058.htm?../rough.htm';break;}
		case "059":    {choice='..\\GRV\\imgs\\mac059.htm?../rough.htm';break;}
		case "060":    {choice='..\\GRV\\imgs\\mac060.htm?../rough.htm';break;}
		case "061":		{choice='..\\GRV\\imgs\\mac061.htm?../rough.htm';break;}
		case "062":    {choice='..\\GRV\\imgs\\mac062.htm?../rough.htm';break;}
		case "063":		{choice='..\\GRV\\imgs\\mac063.htm?../rough.htm';break;}
		case "064":    {choice='..\\GRV\\imgs\\mac064.htm?../rough.htm';break;}
	   case "065":    {choice='..\\GRV\\imgs\\mac065.htm?../rough.htm';break;}
		case "066":    {choice='..\\GRV\\imgs\\mac066.htm?../rough.htm';break;}
		case "067":    {choice='..\\GRV\\imgs\\mac067.htm?../rough.htm';break;}
		case "068":		{choice='..\\GRV\\imgs\\mac068.htm?../rough.htm';break;}
		case "069":    {choice='..\\GRV\\imgs\\mac069.htm?../rough.htm';break;}
	   case "070":    {choice='..\\GRV\\imgs\\mac070.htm?../rough.htm';break;}
		case "071":    {choice='..\\GRV\\imgs\\mac071.htm?../rough.htm';break;}
		case "072":    {choice='..\\GRV\\imgs\\mac072.htm?../rough.htm';break;}
	}
	self.location = choice;
  
}
function validate(current_form) {
	var i_yr  = current_form.expyr.value;
	var i_mo = current_form.expmo.value;
	var missing_fields = new Array();
	var total_missing=0;
	var err_msg="";
	
	document.forms[0].name_on_card.mandatory = true; 
	document.forms[0].card_billing_address.mandatory = true; 
	document.forms[0].card_billing_city.mandatory = true; 
	document.forms[0].card_billing_postcode.mandatory = true; 
	document.forms[0].card_billing_country.mandatory = true; 
	document.forms[0].card_number.mandatory = true; 
	document.forms[0].card_verification_code.mandatory = true;
	
	if( card_not_expired(i_yr,i_mo) ){
		current_form.card_expiry_date.value = i_mo + i_yr.substr(2,2);
	}
	else {
		err_msg = "card expiry is already past\n";
	}
	for( i=0; i < current_form.length; i ++ ) {
		if((current_form[i].type == "text") &&
			(current_form[i].mandatory)) {
			if(its_empty(current_form[i].value)){
				missing_fields[total_missing] = current_form[i];
				total_missing++;
			}
		}
	}
	if(total_missing > 0 || err_msg != "" ) {
		err_msg = "Please correct these data:\n" + err_msg;
		for(i = 0; i < missing_fields.length; i++) {
			err_msg += missing_fields[i].name + "\n";
		}
		alert(err_msg);
		missing_fields[0].focus();
	}
	else {
		var confo_msg = "Is this what you mean to submit?\n";
		confo_msg += "______________________________\n";
		confo_msg += "amount:" + current_form.x_currency_code.value + " " + current_form.x_amount.value + "\n";
		confo_msg += "name on card:" + current_form.name_on_card.value + "\n";
		confo_msg += "billing address:" + current_form.card_billing_address.value + "\n";
		confo_msg += "billing city:" + current_form.card_billing_city.value + "\n";
		confo_msg += "billing postcode:" + current_form.card_billing_postcode.value + "\n";
		confo_msg += "billing country:" + current_form.card_billing_country.value + "\n";
		confo_msg += "card type:" + current_form.card_type.value + "\n";
		confo_msg += "card number:" + current_form.card_number.value + "\n";
		confo_msg += "card verification code:" + current_form.card_verification_code.value + "\n";
		confo_msg += "card expiry date:" + current_form.card_expiry_date.value + "\n";
		var submit_ok = confirm(confo_msg);
		if( submit_ok ) {
			current_form.submit();
		}
	}
	
}
function card_not_expired(yr,mo) {
   var i_date  = yr*100 + mo*1;
   now = new Date();
   t_date = now.getMonth() + now.getYear()*100;
   if(t_date > i_date ) {
   	return false;
   }
   else {
   	return true;
   }
}
function its_empty(string_value) {
	if( string_value == "" || string_value == null ) {
		return true;
	}
	else {
		return false;
	}
}
