var startTime = new Date();
var endTime = new Date();
var redBorderSetField = '';
var highlightedDiv = '';
//------------------------------------------------------------------------------------------------------------------------------------
function WriteEmailLink(username, domainName, linkClass){
	var at = "@";
	document.write("<a href='mailto:"+username+""+at+""+domainName+"' class=\"" + linkClass + "\">"+username+""+at+""+domainName+"</a>");
}
//------------------------------------------------------------------------------------------------------------------------------------
function open_link(link,linkname,x,y) {
	window.open(link, linkname, 'width='+x+',height='+y+',toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,screenX=100,screenY=100,top=100,left=100')
}
//------------------------------------------------------------------------------------------------------------------------------------
function open_link_pos(link,linkname,x,y,px,py) {
//	alert(link+'|'+linkname+'|'+x+'|'+y+'|'+px+'|'+py);
	window.open(link, linkname, 'width='+x+',height='+y+',toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0,screenX='+px+',screenY='+py+',left='+px+',top='+py)
}
//------------------------------------------------------------------------------------------------------------------------------------
function bookmark(url, description){
	netscape="FireFox User's hit CTRL+D to add DanskAutoRent.com to your bookmarks."
	if (navigator.appName=='Microsoft Internet Explorer'){
	window.external.AddFavorite(url, description);
	}else if (navigator.appName=='Netscape'){
	alert(netscape);
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function fill_flight(){
	if (document.getElementById("NoFlight").checked){
	document.getElementById("arrival_flight").value="Not arriving by plane.";
	}else {
	document.getElementById("arrival_flight").value="";
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function leadZero(s){
	var st = new String(s);
	if (st.length==1){
		return "0"+s;
	}
	return s;
}
//------------------------------------------------------------------------------------------------------------------------------------
function getTimeObject(year, mon,day,hour,min){
	
	return new Date(year,mon-1,day,hour,min,0);
}
//------------------------------------------------------------------------------------------------------------------------------------
function getYear(t){
	var y = t.getYear();
	if (y<1900) y += 1900;
	return y;
}
//------------------------------------------------------------------------------------------------------------------------------------
function getMonLen(t){
	var d = new Date(getYear(t),t.getMonth()+1,0);
	return d.getDate();
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkCarClass(go){
	var f = document.f;
	car_class = document.getElementById('car_class');
	//alert(car_class.value);
	//if (f.car_class.value==0){
	if (!f.car_class.value){
		//if (go==1){
		//	document.location.href="#car_select";
		//}
		//setRedBorder('CAR_RESULTS');
		alert('Please select a Car!');
		return false;
	}else{
		return true;
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function no_submit(e){
	if (e.keyCode == 13){
		return false;
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function numbersonly(myfield, e, dec){
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
	   return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	// decimal point jump
	else if (dec && (keychar == ".")){
	   myfield.form.elements[dec].focus();
	   return false;
	}else
	   return false;
}
//------------------------------------------------------------------------------------------------------------------------------------
//--- Global variable for slideshow on index.tpl page --------------------------------------------------------------------------------
//----BEGIN SLIDESHOW FUNCTIONS-------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------
NewImg = new Array (
	"http://dev.danskautorent.com/images/ad_C30.gif",
	"http://dev.danskautorent.com/images/ad_outlander.PNG",
	"http://dev.danskautorent.com/images/ad_avensis.png",
	"http://dev.danskautorent.com/images/ad_fiesta.png",
	"http://dev.danskautorent.com/images/ad_s60.png"
);
NewLink = new Array (
	"http://dev.danskautorent.com/book.php?from_quick_quote=1&car_class=52&s_level=&sval=0",
	"http://dev.danskautorent.com/book.php?from_quick_quote=1&car_class=37&s_level=&sval=1099",
	"http://dev.danskautorent.com/book.php?from_quick_quote=1&car_class=29&s_level=&sval=1839",
	"http://dev.danskautorent.com/book.php?from_quick_quote=1&car_class=24&s_level=&sval=0",
	"http://dev.danskautorent.com/book.php?from_quick_quote=1&car_class=36&s_level=&sval=354"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 5000;
var lock = false;
var run;
//------------------------------------------------------------------------------------------------------------------------------------
function chgImg(direction) {
	if (document.images) {
		ImgNum = ImgNum + direction;
	if (ImgNum > ImgLength) {
		ImgNum = 0;
	}
	if (ImgNum < 0) {
		ImgNum = ImgLength;
	}
	document.slideshow.src = NewImg[ImgNum];
	document.getElementById("slideshowlink").href = NewLink[ImgNum];
   }
}
//------------------------------------------------------------------------------------------------------------------------------------
function auto() {
	if (lock == true) {
		lock = false;
		window.clearInterval(run);
	}else if (lock == false) {
		lock = true;
		run = setInterval("chgImg(1)", delay);
   }
}
//------------------------------------------------------------------------------------------------------------------------------------
//----END SLIDESHOW FUNCTIONS---------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------------------------
//----BEGIN - Car Selector Scroller --------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------
function TextScroll(scrollname, div_name, up_name, down_name) {
    this.div_name = div_name;
    this.name = scrollname;
    this.up_name = up_name;
    this.dn_name = down_name;

	this.scrollCursor = 0;
    this.speed = 5;
    this.timeoutID = 0;
    this.div_obj = null;

	{
	if (document.getElementById) {
		div_obj = document.getElementById(this.div_name);
		if (div_obj) {
			this.div_obj = div_obj;
			this.div_obj.style.overflow = 'auto';
		}
		div_up_obj = document.getElementById(this.up_name);
		div_dn_obj = document.getElementById(this.dn_name);
			if (div_up_obj && div_dn_obj){
				div_up_obj.onmouseover = function() { eval(scrollname + '.scrollUp();') };
				div_up_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };
				
				div_dn_obj.onmouseover = function() { eval(scrollname + '.scrollDown();') };
				div_dn_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };
			}
		}
    }

	this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

	this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.div_obj.scrollLeft - this.speed) < 0 ? 0 : this.div_obj.scrollLeft - this.speed;
            this.div_obj.scrollLeft = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + '.scrollUp()', 5);
        }
    }

	this.scrollDown = function() {
		if (this.div_obj) {
			this.scrollCursor = this.div_obj.scrollLeft + this.speed;
			this.div_obj.scrollLeft = this.scrollCursor;
			if (this.div_obj.scrollLeft == this.scrollCursor) {
				this.timeoutID = setTimeout(this.name + '.scrollDown()', 5);
			} else {
				this.scrollCursor = this.div_obj.scrollLeft;
			}
		}
	}

	this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollLeft = 0;
            this.scrollCursor = 0;
        }
    }
}
//------------------------------------------------------------------------------------------------------------------------------------
//----END - Car Selector Scroller ----------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------------------------
//--- Added by Dao G. Yang January 4, 2007 (Service Level Project)
//------------------------------------------------------------------------------------------------------------------------------------
function checkServiceLevel(go){
	var f = document.f;
	if (f.pick_loc.value==1 || f.pick_loc.value==''){
		document.getElementById('optional_text').innerHTML = "Required Credit Card Information";
	}else{
		document.getElementById('optional_text').innerHTML = "Optional Credit Card Information";
	}	
	if (f.pick_loc.value==1){
		if (f.SS2){
			if (f.SS1){
				if (!f.SS1.checked && !f.SS2.checked){
					if (go==1){
						document.location.href="#service_select";
					}
					setRedBorder('SS1');
					setRedBorder('SS2');
					alert('Please select a Service Level!');
					return false;
				}
				if (f.SS1.checked && f.SS2.checked){
					alert('Please select only one service level.');
					return false;
				}
			}
		}else{
			check_avail();
		}
	}else if (f.pick_loc.value!=1 && f.SS1){
		if (f.SS1.checked){
			//alert('Premium Personal Service is not available outside Kastrup! Please select Express Self Service.');
			f.SS1.checked = false;
			f.SS2.checked = true;
		}
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function check_ss_level(field){
	val = document.getElementById(field).checked;	
	if (val==true && field=='SS1'){
		document.getElementById('SS1').checked = false;
		document.getElementById('SS2').checked = true;
	}else if (val==true && field=='SS2'){
		document.getElementById('SS2').checked = false;
		document.getElementById('SS1').checked = true;
	}else if (val==false && field=='SS1'){
		document.getElementById('SS2').checked = false;
		document.getElementById('SS1').checked = true;
	}else if (val==false && field=='SS2'){
		document.getElementById('SS1').checked = false;
		document.getElementById('SS2').checked = true;
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function show_Steps(){
	if (!document.getElementById('num_4')){
		document.getElementById('num_5').innerHTML = '<IMG src="images/num_4.gif" alt="">';
		document.getElementById('num_6').innerHTML = '<IMG src="images/num_5.gif" alt="">';
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function show_comments(){
	current = document.getElementById('comments_wrapper').style.display;
	if (current == "inline"){
		document.getElementById('comments_wrapper').style.display = "none";
	}else{
		document.getElementById('comments_wrapper').style.display = "inline";
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function quote_switch(div,switchit){
	if (switchit==1){ 		//SWITCH IT ON
		document.getElementById('xtra_info_'+div).style.display="none";
		document.getElementById('xtra2_info_'+div).style.display="inline";
	}else{					//SWITCH IT OFF
		document.getElementById('xtra2_info_'+div).style.display="none";
		document.getElementById('xtra_info_'+div).style.display="inline";
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function select_Car_Class(car_class,type){
	var f = document.f;

	qsval = getQueryVariable('sval');
	var sval = document.getElementById('CAR_RESULTS1').scrollLeft;
	document.f.action = "http://dev.danskautorent.com/index.php?sval="+sval;
	
	if (type==0){
		if (document.getElementById('car_class').value != car_class){
			prev_sel = document.getElementById('car_class').value;
			if (prev_sel!=null && prev_sel!=''){
				document.getElementById('xtra2_span_info_'+prev_sel).style.color="#7A7A7A";
				document.getElementById('xtra2_span_info_'+prev_sel).style.fontWeight='bold';
				document.getElementById('the_select_'+prev_sel).innerHTML = "<strong>Click to Select</strong>";
				document.getElementById(prev_sel).style.background="#FFFFFF";
				document.getElementById(prev_sel).style.border="1px solid #FFFFFF";
				document.getElementById('name_'+prev_sel).style.color="#7A7A7A";
				//document.getElementById('msg_below_'+prev_sel).style.display="none";
				if (document.getElementById('xtra2_info_'+prev_sel).style.display=="none"){
					quote_switch(prev_sel,0); //Switch It OFF
					document.getElementById('xtra_span_info_'+prev_sel).style.color="#718FD4";
				}else{
					quote_switch(prev_sel,1); //Switch It ON
					document.getElementById('xtra_span_info_'+prev_sel).style.color="#718FD4";
				}
			}
			document.getElementById('car_class').value = car_class;
			document.getElementById(car_class).style.background="#CCDBFF";
			document.getElementById(car_class).style.border="1px solid #BD0000";
			document.getElementById('the_select_'+car_class).innerHTML = "<span style='color:#BD0000;font-weight:bold;'>Selected</span>";
			document.getElementById('name_'+car_class).style.color="#BD0000";
			document.getElementById('xtra_span_info_'+car_class).style.color="#BD0000";
			document.getElementById('xtra2_span_info_'+car_class).style.color="#BD0000";
			check_qq_avail();
		}else{
			prev_sel = document.getElementById('car_class').value;
			if (document.getElementById('xtra2_info_'+prev_sel).style.display=="none"){
				document.getElementById('xtra2_span_info_'+car_class).style.color="#7A7A7A";
				document.getElementById('xtra2_span_info_'+car_class).style.fontWeight='bold';
				document.getElementById(document.getElementById('car_class').value).style.border="1px solid #FFFFFF";
				document.getElementById(document.getElementById('car_class').value).style.background="#FFFFFF";
				document.getElementById(document.getElementById('car_class').value).style.color="#7A7A7A";
				document.getElementById('name_'+car_class).style.color="#7A7A7A";
				document.getElementById('xtra_span_info_'+car_class).style.color="#718FD4";
				document.getElementById('car_class').value = '';
				document.getElementById('the_select_'+car_class).innerHTML = "<strong>Click to Select</strong>";
			}
			check_qq_avail();
		}
	}else{
		if (document.getElementById('CAR_RESULTS1').scrollLeft != qsval){
			document.getElementById('CAR_RESULTS1').scrollLeft=qsval;
		}
		if (document.getElementById('the_select_'+car_class)){
			if (document.getElementById('mesg')){
				Quote_Summary(document.getElementById('mesg').value,car_class);
				document.getElementById('msg_below_'+car_class).innerHTML=document.getElementById('mesg').value;
				//document.getElementById('msg_below_'+car_class).style.display="inline";
			}
			document.getElementById(car_class).style.border="1px solid #BD0000";
			document.getElementById('name_'+car_class).style.color="#BD0000";
			document.getElementById('xtra_span_info_'+car_class).style.color="#BD0000";
			document.getElementById('the_select_'+car_class).innerHTML = "<span style='color:#BD0000;font-weight:bold;'>Selected</span>";
		}
	}
	
	
}
//------------------------------------------------------------------------------------------------------------------------------------
function select_Car_Class2(car_class,type){
	var f = document.f;

	qsval = getQueryVariable('sval');

	if (type==0){
		if (document.getElementById('car_class').value != car_class){
			prev_sel = document.getElementById('car_class').value;
			if (prev_sel!=null && prev_sel!=''){
				document.getElementById('xtra2_span_info_'+prev_sel).style.color="#7A7A7A";
				document.getElementById('xtra2_span_info_'+prev_sel).style.fontWeight='bold';
				document.getElementById('the_select_'+prev_sel).innerHTML = "<strong>Click to Select</strong>";
				document.getElementById(prev_sel).style.background="#FFFFFF";
				document.getElementById(prev_sel).style.border="1px solid #FFFFFF";
				document.getElementById('name_'+prev_sel).style.color="#7A7A7A";
				//document.getElementById('msg_below_'+prev_sel).style.display="none";
				
				if (document.getElementById('xtra2_info_'+prev_sel).style.display=="none"){
					quote_switch(prev_sel,0); //Switch It OFF
					document.getElementById('xtra_span_info_'+prev_sel).style.color="#718FD4";
				}else{
					quote_switch(prev_sel,1); //Switch It ON
					document.getElementById('xtra_span_info_'+prev_sel).style.color="#718FD4";
				}
			}
			document.getElementById('car_class').value = car_class;
			document.getElementById(car_class).style.background="#CCDBFF";
			document.getElementById(car_class).style.border="1px solid #BD0000";
			document.getElementById('the_select_'+car_class).innerHTML = "<span style='color:#BD0000;font-weight:bold;'>Selected</span>";
			document.getElementById('name_'+car_class).style.color="#BD0000";
			document.getElementById('xtra_span_info_'+car_class).style.color="#BD0000";
			document.getElementById('xtra2_span_info_'+car_class).style.color="#BD0000";
		}else{
			prev_sel = document.getElementById('car_class').value;
			if (document.getElementById('xtra2_info_'+prev_sel).style.display=="none"){
				document.getElementById('xtra2_span_info_'+car_class).style.color="#7A7A7A";
				document.getElementById('xtra2_span_info_'+car_class).style.fontWeight='bold';
				document.getElementById(document.getElementById('car_class').value).style.border="1px solid #FFFFFF";
				document.getElementById(document.getElementById('car_class').value).style.background="#FFFFFF";
				document.getElementById(document.getElementById('car_class').value).style.color="#7A7A7A";
				document.getElementById('name_'+car_class).style.color="#7A7A7A";
				document.getElementById('xtra_span_info_'+car_class).style.color="#718FD4";
				document.getElementById('car_class').value = '';
				document.getElementById('the_select_'+car_class).innerHTML = "<strong>Click to Select</strong>";
			}
		}
	}else{
		if (document.getElementById('CAR_RESULTS2').scrollLeft != qsval){
			document.getElementById('CAR_RESULTS2').scrollLeft=qsval;
		}
		if (document.getElementById('the_select_'+car_class)){
			if (document.getElementById('mesg')){
				Quote_Summary(document.getElementById('mesg').value,car_class);
				document.getElementById('msg_below_'+car_class).innerHTML=document.getElementById('mesg').value;
				//document.getElementById('msg_below_'+car_class).style.display="inline";
			}
			document.getElementById(car_class).style.border="1px solid #BD0000";
			document.getElementById('name_'+car_class).style.color="#BD0000";
			document.getElementById('xtra_span_info_'+car_class).style.color="#BD0000";
			document.getElementById('the_select_'+car_class).innerHTML = "<span style='color:#BD0000;font-weight:bold;'>Selected</span>";
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function what_month(val){
	month="";
	val = parseInt(val);
	switch (val){
		case 1:	month = "Jan"; break;
		case 2:	month = "Feb"; break;
		case 3: month = "Mar"; break;
		case 4: month = "Apr"; break;
		case 5: month = "May"; break;
		case 6: month = "Jun"; break;
		case 7: month = "Jul"; break;
		case 8: month = "Aug"; break;
		case 9: month = "Sep"; break;
		case 10: month = "Oct"; break;
		case 11: month = "Nov"; break;
		case 12: month = "Dec"; break;
	}
	return month;
}
//------------------------------------------------------------------------------------------------------------------------------------
function what_location(val){
	loc_name="";
	val = parseInt(val);
	switch (val){
		case 1:	loc_name = "Copenhagen Kastrup Airport (CPH)"; break;
		case 13: loc_name = "Esbjerg Airport (EBJ)"; break;
		case 15: loc_name = "Billund Airport (BLL)"; break;
		case 41: loc_name = "Copenhagen City Desk, Ved Vesterport 3"; break;
		case 63: loc_name = "Århus City Chr. X vej 203 (Toyota)"; break;
		case 34: loc_name = "Karup Airport (KRP) + 100kr"; break;
		case 35: loc_name = "Sønderborg Airport (SGD) + 100kr"; break;
		case 37: loc_name = "Århus Tirstrup Airport (AAR) + 100kr"; break;
		case 38: loc_name = "Rønne Airport (RNN) + 100kr"; break;
	}
	return loc_name;
}
//------------------------------------------------------------------------------------------------------------------------------------
function writePdate(){
	monval = document.getElementById("pick_time_mon").value;
	monval = what_month(monval);
	dval = document.getElementById("pick_time_day").value;
	yval = document.getElementById("pick_time_year").value;
	hval = document.getElementById("pick_time_hour").value;
	minval = document.getElementById("pick_time_min").value;
	
	if (dval.length < 2){
		dval = "0"+dval;
	}
	if (hval.length < 2){
		hval = "0"+hval;
	}
	if (minval.length < 2){
		minval = "0"+minval;
	}
	date = monval+". "+dval+", "+yval+" "+hval+":"+minval;
	document.getElementById("pdate").innerHTML = date;
}
//------------------------------------------------------------------------------------------------------------------------------------
function writeDdate(){
	monval = document.getElementById("drop_time_mon").value;
	monval = what_month(monval);
	dval = document.getElementById("drop_time_day").value;
	yval = document.getElementById("drop_time_year").value;
	hval = document.getElementById("drop_time_hour").value;
	minval = document.getElementById("drop_time_min").value;
	
	if (dval.length < 2){
		dval = "0"+dval;
	}
	if (hval.length < 2){
		hval = "0"+hval;
	}
	if (minval.length < 2){
		minval = "0"+minval;
	}
	date = monval+". "+dval+", "+yval+" "+hval+":"+minval;
	document.getElementById("ddate").innerHTML = date;
}
//------------------------------------------------------------------------------------------------------------------------------------
function euro_trim(stringToTrim) {
	return stringToTrim.replace(/\(.*\)/i,"");
}
//------------------------------------------------------------------------------------------------------------------------------------
function width_trim(stringToTrim) {
	return stringToTrim.replace(/style="WIDTH: 170px"|style="width: 170px;"/i,"style='WIDTH: 150px'");
}
//------------------------------------------------------------------------------------------------------------------------------------
function price_trim(stringToTrim) {
	return stringToTrim.replace(/Price:/i,"");
}
//------------------------------------------------------------------------------------------------------------------------------------
function break_trim(stringToTrim) {
	return stringToTrim.replace(/<br\/>|<br>/i,"");
}
//------------------------------------------------------------------------------------------------------------------------------------
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
//------------------------------------------------------------------------------------------------------------------------------------
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
//------------------------------------------------------------------------------------------------------------------------------------
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
//------------------------------------------------------------------------------------------------------------------------------------
function change_background(car_class){
	if (document.getElementById('car_class').value && (document.getElementById('car_class').value == car_class)){
		document.getElementById(car_class).style.background="#CCDBFF";
	}else{
		document.getElementById(car_class).style.background="#FFFFFF";
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function Quote_Summary(cost,car_class){
	quote_switch(car_class,1); //Switch It ON
	document.getElementById('xtra2_info_'+car_class).style.color = "#BD0000";
	document.getElementById('xtra2_span_info_'+car_class).style.color = "#BD0000";
	document.getElementById('xtra_span_info_'+car_class).style.color = "#BD0000";
	for(j=0;j<100;j++){
		if (document.getElementById('xtra_info_'+j) && document.getElementById('xtra2_info_'+j)){
			quote_switch(j,1); //Switch It ON
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkDateDiff(){
	var f = document.f;

	if (parseInt(f.pick_time_year.value)>f.drop_time_year.value){
		return false;
	} else if (parseInt(f.pick_time_year.value)==f.drop_time_year.value){
		if (parseInt(f.pick_time_mon.value)>f.drop_time_mon.value){
			return false;
		} else if (parseInt(f.pick_time_mon.value)==f.drop_time_mon.value){
			if (parseInt(f.pick_time_day.value)>f.drop_time_day.value){
				return false;
			} else if (parseInt(f.pick_time_day.value)==f.drop_time_day.value){
				if (parseInt(f.pick_time_hour.value)>f.drop_time_hour.value){
					return false;
				} else if (parseInt(f.pick_time_hour.value)==f.drop_time_hour.value && parseInt(f.pick_time_min.value)>f.drop_time_min.value){
					return false;
				}
			}
		}
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkDate(year, mon, day, hour, min){
	if (book_start_time[0]>year){
		return false;
	} else if (book_start_time[0]==year){
		if (book_start_time[1]>mon){
			return false;
		} else if (book_start_time[1]==mon){
			if (book_start_time[2]>day){
				return false;
			} else if (book_start_time[2]==day){
				if (book_start_time[3]>hour){
					return false;
				} else if (book_start_time[3]==hour && book_start_time[4]>min){
					return false;
				}
			}
		}
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkDate_Today(year, mon, day, hour, min){
	if (book_start_time[0]==year && book_start_time[1]==mon && book_start_time[2]==day && book_start_time[3]==hour){
		return true
	}else
		return false;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkDateDay(type){
	var f = document.f;
	var t, mon, mObj, day;
	if (type == 'pick_time'){
		t = getTimeObject(f.pick_time_year.value, f.pick_time_mon.value,f.pick_time_day.value,f.pick_time_hour.value,f.pick_time_min.value);
		mon = f.pick_time_mon.value-1;
		mObj = f.pick_time_mon;
		day = f.pick_time_day;
		monLen = getMonLen(getTimeObject(f.pick_time_year.value, f.pick_time_mon.value,1,0,0));
	} else {
		t = getTimeObject(f.drop_time_year.value, f.drop_time_mon.value,f.drop_time_day.value,f.drop_time_hour.value,f.drop_time_min.value);
		mon = f.drop_time_mon.value-1;
		mObj = f.drop_time_mon;
		day = f.drop_time_day;
		monLen = getMonLen(getTimeObject(f.drop_time_year.value, f.drop_time_mon.value,1,0,0));
	}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//				Added per Michael's Request to adjust for Opening hours on weekdays and weekends for Copenhagen City Desk
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	if (type == 'pick_time'){ // Copenhagen City Desk Time Restraints...//Added per Michael's Request by Dao G. Yang (11/1/2006)
		if (f.pick_loc.value==41){
			mon = f.pick_time_mon.value-1;
			year = f.pick_time_year.value;
			dayofweek = new Date();
			dayofweek.setDate(f.pick_time_day.value);
			dayofweek.setMonth(mon);
			dayofweek.setFullYear(f.pick_time_year.value);
			weekday = dayofweek.getDay();
			if (weekday>0 && weekday<6){
				if (f.pick_time_hour.value<7 || f.pick_time_hour.value>20){ //Weekdays
					alert("Pick-up Time: Copenhagen City Desk hours are between 07:00 and 20:00");
					return true;
				}
			}
			if (weekday==0 || weekday ==6){// Weekends
				if (f.pick_time_hour.value<8 || f.pick_time_hour.value>18){
					alert("Pick-up Time: Copenhagen City Desk hours are between 08:00 and 18:00 on weekends");
					return true;
				}
			}
		}
	} 

	if (type == 'pick_time'){ // Billund Airport Desk Time Restraints...
		if (f.pick_loc.value==15){
			var location_wait = document.getElementById("location_wait");
			mon = f.pick_time_mon.value-1;
			year = f.pick_time_year.value;
			dayofweek = new Date();
			dayofweek.setDate(f.pick_time_day.value);
			dayofweek.setMonth(mon);
			dayofweek.setFullYear(f.pick_time_year.value);
			weekday = dayofweek.getDay();
			
			if (mon==2 && f.pick_time_day.value==30 && year==2008){
				weekday=0;
			}
			if (mon==2 && f.pick_time_day.value==31 && year==2008){
				weekday=1;
			}

			if (weekday>0 && weekday<6){//Weekdays
				//alert("Inside Weekday");
				if ((f.pick_time_hour.value==7 && f.pick_time_min.value<30) || (f.pick_time_hour.value<7) || (f.pick_time_hour.value>=22)){
					alert("Pick-up Time: Billund Airport hours are between 07:30 and 22:00. If you continue your booking with the curent pick-up time selected, we will place your booking on hold until we contact you for further information.");
					location_wait.value = 'Y';
					return true;
				}
			}
			if (weekday==6){// Saturday 
				if (f.pick_time_hour.value<9 || f.pick_time_hour.value>=14){
					alert("Pick-up Time: Billund Airport hours are between 09:00 and 13:00 on Saturdays. If you continue your booking with the curent pick-up time selected, we will place your booking on hold until we contact you for further information.");
					location_wait.value = 'Y';
					return true;
				}
			}
			if (weekday==0){// Sunday
				if ((f.pick_time_hour.value==15 && f.pick_time_min.value<30) || (f.pick_time_hour.value<15) || (f.pick_time_hour.value==21 && f.pick_time_min.value>30) || (f.pick_time_hour.value>21)){
					alert("Pick-Up Time: Billund Airport hours are between 15:30 and 21:30 on Sundays. If you continue your booking with the curent pick-up time selected, we will place your booking on hold until we contact you for further information.");
					location_wait.value = 'Y';
					return true;
				}
			}
		}
	} 
/*	if (type == 'drop_time'){
		if (f.drop_loc.value==41){
			mon = f.drop_time_mon.value-1;
			year = f.drop_time_year.value;
			dayofweek = new Date();
			dayofweek.setDate(f.drop_time_day.value);
			dayofweek.setMonth(mon);
			dayofweek.setFullYear(f.drop_time_year.value);
			weekday = dayofweek.getDay();
			if (weekday>0 && weekday<6){
				if (f.drop_time_hour.value<7 || f.drop_time_hour.value>20){
					alert("Drop-off Time: Copenhagen City Desk hours are between 7AM and 20PM");
				}
			}
			if (weekday==0 || weekday ==6){
				if (f.drop_time_hour.value<8 || f.drop_time_hour.value>18){
					alert("Drop-off Time: Copenhagen City Desk hours are between 8AM and 18PM on weekends");				
				}
			}
		}
	}*/ 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
	if (mon != t.getMonth()){
		alert("The "+((type=="pick_time")? "arrival" : "depature")+" date is not a valid date! There is no day "+ day.value +" in "+mObj.options[mObj.selectedIndex].text + ". Changing to "+monLen+".");
		day.options[monLen-1].selected=true;
//		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function getInvalidDateMsg(){
	alert("You can't make a booking less than 6 hours before rental start. \n(current time in Denmark is "+leadZero(today_time[2])+"/"+leadZero(today_time[1])+"/"+today_time[0]+ "  "+leadZero(today_time[3])+":"+leadZero(today_time[4])+")");
}
function getInvalidDateMsg2(){
	alert("Please enter your Arrival and Departure Information.");
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkRentDates(){
	var f = document.f;
	if (!checkDateDay('pick_time')) return false;
	if (!checkDateDay('drop_time')) return false;

	if (!checkDateDiff()){
		alert("Departure time can't precede Arrival time!");
		return false;
	}
	//alert(f.pick_time_year.value+"|"+f.pick_time_mon.value+"|"+f.pick_time_day.value+"|"+f.pick_time_hour.value+"|"+f.pick_time_min.value);
	//alert(checkDate(f.pick_time_year.value, f.pick_time_mon.value,f.pick_time_day.value,f.pick_time_hour.value,f.pick_time_min.value));
	
	if (!checkDate(f.pick_time_year.value, f.pick_time_mon.value,f.pick_time_day.value,f.pick_time_hour.value,f.pick_time_min.value) || !checkDate(f.drop_time_year.value, f.drop_time_mon.value,f.drop_time_day.value,f.drop_time_hour.value,f.drop_time_min.value)){
		document.getElementById(document.getElementById('car_class').value).style.border="1px solid #FFFFFF";
		document.getElementById(document.getElementById('car_class').value).style.background="#FFFFFF";
		document.getElementById(document.getElementById('car_class').value).style.color="#7A7A7A";
		document.getElementById('xtra_span_info_'+document.getElementById('car_class').value).style.color="#718FD4";			
		document.getElementById('name_'+document.getElementById('car_class').value).style.color="#7A7A7A";
		document.getElementById('the_select_'+document.getElementById('car_class').value).innerHTML = "<strong>Click to Select</strong>";		
		document.getElementById('car_class').value = '';
		getInvalidDateMsg();
		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkExpDate(year, mon){
	if (today_time[0]>year){
		return false;
	} else if (today_time[0]==year){
		if (today_time[1]>mon){
			return false;
		}
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkAllDates(){
	var f = document.f;

	if (!checkRentDates()){
		return false;
	}

	if (f.offer_id){
		if (f.offer_id.checked && !checkSpecialOffer()){
			return false;
		}
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
// -1 kui start > end
// 0 kui start = end
// 1 kui start < end
function compareTimes(start, end){

	if (parseInt(start[0])>parseInt(end[0])){
		return -1;
	} else if (parseInt(start[0])==parseInt(end[0])){
		if (parseInt(start[1])>parseInt(end[1])){
			return -1;
		} else if (parseInt(start[1])==parseInt(end[1])){
			if (parseInt(start[2])>parseInt(end[2])){
				return -1;
			} else if (parseInt(start[2])==parseInt(end[2])){
				if (parseInt(start[3])>parseInt(end[3])){
					return -1;
				} else if (parseInt(start[3])==parseInt(end[3])){
					if (parseInt(start[4])>parseInt(end[4])){
						return -1;
					} else if (parseInt(start[4])==parseInt(end[4])){
						return 0;
					}
				}
			}
		}
	}
	return 1;
}
//------------------------------------------------------------------------------------------------------------------------------------
function updatename(){
var f = document.f; //Declaration of f as document.f
f.elements.name.value=f.elements.fname.value + ' ' + f.elements.lname.value;
}
//------------------------------------------------------------------------------------------------------------------------------------
function eb_updatename(){
var f = document.f; //Declaration of f as document.f
document.getElementById("name").value=document.getElementById("fname").value + ' ' + document.getElementById("lname").value;
}
//------------------------------------------------------------------------------------------------------------------------------------
function splitname(name){
var f = document.f;
if (name.indexOf(" ")>0){
var holder=name.split(" ");
f.elements.fname.value=holder[0];
f.elements.lname.value=holder[1];
}else{
f.elements.fname.value=name;
f.elements.fname.value=name;
}
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkSpecialOffer(){
	var f = document.f;
	var start = new Array(f.pick_time_year.value, f.pick_time_mon.value, f.pick_time_day.value, f.pick_time_hour.value, f.pick_time_min.value);
	var end = new Array(f.drop_time_year.value, f.drop_time_mon.value, f.drop_time_day.value, f.drop_time_hour.value, f.drop_time_min.value);
	if (compareTimes(sp_start,start)<0 || compareTimes(end, sp_end)<0){
		alert("If You want to get Special Offer arrival and depature times must be between Special Offer times. ("+leadZero(sp_start[2])+"/"+leadZero(sp_start[1])+"/"+sp_start[0]+" "+leadZero(sp_start[3])+":"+leadZero(sp_start[4])+" - "+leadZero(sp_end[2])+"/"+leadZero(sp_end[1])+"/"+sp_end[0]+" "+leadZero(sp_end[3])+":"+leadZero(sp_end[4])+")");
		return false;
	}
	if (f.pick_loc.value != kastrup_id || f.drop_loc.value != kastrup_id){
		alert("Special offers are available only in Kastrup.");
		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkCustomerInfo(){
	var f = document.f;
	var fields = new Array('fname','lname','address','city','state','postal','country','email','phone');
	var boxes = new Array('First Name', 'Last Name', 'Address', 'City', 'State/Province', 'Zip/Postal', 'Country', 'E-mail Address', 'Phone');

	for(var i=0; i<fields.length; i++){
		if (!f.elements[fields[i]].value || f.elements[fields[i]].value.length < 2)
		{
			document.location.href="#cust_info";
			setRedBorder(fields[i]);
			highlight_div('help_4');
			alert('Please fill the "'+boxes[i]+'" box! The "'+boxes[i]+'" Field must be at least 2 characters long.');
			return false;
		}else if ( (fields[i]=='fname' || fields[i]=='lname' )&& f.elements[fields[i]].value.indexOf(' ') > -1)
		{
			document.location.href="#cust_info";
			setRedBorder(fields[i]);
			highlight_div('help_4');
			alert('Please fill the "'+boxes[i]+'" box! The "'+boxes[i]+'" Field must be at least 2 characters long and contain no spaces.');
			return false;
		}
	}
	
	if (f.date_of_birth_day.value == "0")
	{
		document.location.href="#cust_info";
		setRedBorder("date_of_birth_day");
		highlight_div('help_4');
		alert('Please fill date of birth!');
		return false;
	}
	else if (f.date_of_birth_mon.value == "0")
	{
		document.location.href="#cust_info";
		setRedBorder("date_of_birth_mon");
		highlight_div('help_4');
		alert('Please fill date of birth!');
		return false;
	}
	else if (f.date_of_birth_year.value == "0")
	{
		document.location.href="#cust_info";
		setRedBorder("date_of_birth_year");
		highlight_div('help_4');
		alert('Please fill date of birth!');
		return false;
	}

	if (f.license.value == "")
	{
		document.location.href="#cust_info";
		setRedBorder("license");
		highlight_div('help_4');
		alert('Please fill the "License #" box!');
		return false;
	}
	
	if (f.license_exp_year.value == "" && f.license_exp_mon.value == "" && !f.NoExp.checked)
	{
		document.location.href="#cust_info";
		setRedBorder("license_exp_year");
		highlight_div('help_4');
		alert('Please select a License Expiration date or select the "No Expiration" box!');
		return false;
	}

	if (f.pass.value == "")
	{
		document.location.href="#cust_info";
		setRedBorder("pass");
		highlight_div('help_4');
		alert('Please fill the "Passport #" box. If not available now, write "N/A" and submit it later');
		return false;
	}

	s = new String(f.country.value);
	if (s.toLowerCase().indexOf('denmark') != -1 || s.toLowerCase().indexOf('danmark') !=-1 || s.toLowerCase().toString() == 'dk')	{
		document.location.href="#cust_info";
		highlight_div('help_6');
		alert('Your address must be outside Denmark.');
		return false;
	}
	var s = new String(f.email.value);
	if (s.indexOf('@') == -1 || s.lastIndexOf('.') < s.indexOf('@') || s.length == s.lastIndexOf('.')+1){
		document.location.href="#cust_info";
		setRedBorder('email');
		highlight_div('help_4');
		alert('Please give a valid e-mail address.');
		return false;
	}
	//if (f.denmark_phone.value == ""){
	//	setRedBorder("denmark_phone");
	//	highlight_div('help_6');
	//	alert('Please fill the "Phone no. in Denmark" box if available or write N/A');
	//	return false;
	//}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkCommentBox(){
	var f = document.f;
	var s = new String(f.comments.value);
//	var a = s.split("\n");

	if (s.length>200){
		alert("Text in comment box is too big! (max. 200 characters allowed. You have "+s.length+")");
		return false;
	}

//	if (a.length>4){
//		alert("There are too many line breaks ('enter' presses) in comment box (max. 3 allowed)");
//		return 0;
//	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
// for rent.php
function check_archive(){
	var f = document.f;

	if (!checkCustomerInfo()) {return false;}

	f.submit_type.value=3;
	f.submit();
}
//------------------------------------------------------------------------------------------------------------------------------------
function getFormEl(f, name){
	var e = f.elements;
	for (var i=0; i<e.length; i++){
		if (e[i].name == name)
			return e[i];
	}
}

Date.prototype.add = function (sInterval, iNum){
  var dTemp = this;
  if (!sInterval || iNum == 0) return dTemp;
  switch (sInterval.toLowerCase()){
    case "ms":
      dTemp.setMilliseconds(dTemp.getMilliseconds() + iNum);
      break;
    case "s":
      dTemp.setSeconds(dTemp.getSeconds() + iNum);
      break;
    case "mi":
      dTemp.setMinutes(dTemp.getMinutes() + iNum);
      break;
    case "h":
      dTemp.setHours(dTemp.getHours() + iNum);
      break;
    case "d":
      dTemp.setDate(dTemp.getDate() + iNum);
      break;
    case "mo":
      dTemp.setMonth(dTemp.getMonth() + iNum);
      break;
    case "y":
      dTemp.setFullYear(dTemp.getFullYear() + iNum);
      break;
  }
  return dTemp;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkExtras(){
	var f = document.f;
	
	var snow_tires = document.getElementById("extras["+snow_tires_id+"]");
	var snow_tires_wait = document.getElementById("snow_tires_wait");
	if (snow_tires != null)
	{
		if (snow_tires.checked)
		{
			var today = new Date();
			var tomorrow = today.add("d", 2); //+3days
			var booking = new Date()
			booking.setFullYear(f.pick_time_year.value,f.pick_time_mon.value,f.pick_time_day.value);
			booking.setHours(f.pick_time_hour.value,f.pick_time_min.value,0);
			
			if (booking.getFullYear() >= tomorrow.getFullYear()){
				if (booking.getMonth() >= tomorrow.getMonth()){
					if(booking.getDate() >= tomorrow.getDate()){
						var dif =  booking.getDate() - tomorrow.getDate();
							if (dif<1){ 
							if(booking.getHours() >= tomorrow.getHours()){
								alert("!! Note: If you book Snow/Winter Tires less than 48 hours before your pick-up time, your booking will be put on a waiting list for Snow/Winter Tires.");
								snow_tires_wait.value = 'Y';
								return true;
							}
						}
					}
				}
			}
	}else return true;
	}

	var gps = document.getElementById("extras["+gps_id+"]");
	if (gps != null)
	{
		if (gps.checked){
			/*
			if ((f.pick_loc.value != kastrup_id && f.pick_loc.value != 41 && f.pick_loc.value != 15 && f.pick_loc.value != 13) || (f.drop_loc.value != kastrup_id && f.drop_loc.value != 41 && f.drop_loc.value != 15 && f.drop_loc.value != 13)){
			alert('GPS is only available in Kastrup (CPH), Copenhagen City Desk, Billund (BLL) and Esbjerg (EBJ).');
			return false;
			}
			*/
		}
	}

/*	if (!hertz[f.car_class.value]){
		if (f.offer_similar.value==''){
			return true;
		} else if (f.old_car_class.value != f.car_class.value) {
			return true;
		}
	}
*/
//	var pg = getFormEl(f, "extras["+park_and_go_id+"]");
//	if (parseInt(pg.value)){
//		alert("'Park & Go' is not available when booking a car from our partner's fleet.");
//		return false;
//	}
//	if (rb.checked){
/*	if (parseInt(rb.value)){
		if (!dansk_loc[f.pick_loc.value] || !dansk_loc[f.drop_loc.value]){
			alert("Roof box is not available outside Kastrup and København City.");
			return false;
		}
	}
*/
/*	var rb = getFormEl(f, "extras["+roof_box_id+"]");
	if (parseInt(rb.value)){
		if (parseInt(f.pick_loc.value) != kastrup_id || parseInt(f.drop_loc.value) != kastrup_id){
			alert("Roof box is not available outside Kastrup.");
			return false;
		}
	}
*/
	if (!check_roofbox())
	{
		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkFlightAndTime(){
	var f = document.f;
	if (document.getElementById("EB").value!="yes"){if (!parseInt(f.bid.value) || flight_and_time_check) return true;} // new book
	var start = new Array(f.pick_time_year.value, f.pick_time_mon.value, f.pick_time_day.value, f.pick_time_hour.value, f.pick_time_min.value);
	var start_current = new Array(f.current_pick_time_year.value, f.current_pick_time_mon.value, f.current_pick_time_day.value, f.current_pick_time_hour.value, f.current_pick_time_min.value);
	var end = new Array(f.drop_time_year.value, f.drop_time_mon.value, f.drop_time_day.value, f.drop_time_hour.value, f.drop_time_min.value);
	var end_current = new Array(f.current_drop_time_year.value, f.current_drop_time_mon.value, f.current_drop_time_day.value, f.current_drop_time_hour.value, f.current_drop_time_min.value);
	var msg = '';
	if ((compareTimes(start,start_current)!=0 && f.arrival_flight.value==f.current_arrival_flight.value)){
		msg += "You have changed arrival time, but not arrival flight #.\n";
	} else if ((compareTimes(start,start_current)==0 && f.arrival_flight.value!=f.current_arrival_flight.value)){
		msg += "You have changed arrival flight #, but not arrival time.\n";
	}
	
//	if ((compareTimes(end,end_current)!=0 && f.depature_flight.value==f.current_depature_flight.value)){
//		msg += "You have changed depature time, but not depature flight #.\n";
//	} else if ((compareTimes(end,end_current)==0 && f.depature_flight.value!=f.current_depature_flight.value)){
//		msg += "You have changed depature flight #, but not depature time.\n";
//	}
	if (msg){
		flight_and_time_check = true;
		alert(msg + "Please double-check the data !");
		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function setRedBorder(field){
	var fl = document.getElementById(field);
	fl.style.borderWidth='1px';
	fl.style.borderColor='#FF0000';
	redBorderSetField = field;
	fl.focus();
}
//------------------------------------------------------------------------------------------------------------------------------------
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  //return false;
}
//------------------------------------------------------------------------------------------------------------------------------------
function logmein(){
	nl = getQueryVariable('loginname');
	dwsp = getQueryVariable('password');
	if (nl && dwsp){
		//if (navigator.appName=='Microsoft Internet Explorer'){
			//document.getElementById("loginname").value = nl; 
			//document.getElementById("password").value = dwsp; 
			//document.forms["login"].submit();
		//}else if (navigator.appName=='Netscape'){
			document.forms["login"]["loginname"].value = nl;
			document.forms["login"]["password"].value = dwsp;
			document.forms["login"].submit();
		//}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------//------------------------------------------------------------------------------------------------------------------------------------
//The main function to call other functions to check information on the Book.php page
function check_book_info() {
	var f = document.f;
	
	if (redBorderSetField!=''){
		var fl = document.getElementById(redBorderSetField);
		fl.style.borderWidth='1px';
		fl.style.borderColor='#000000';
	}

	unhighlight_div(highlightedDiv);
	
	//alert(document.getElementById("EB").value);
	if (document.getElementById("EB").value!="yes"){
		if (!f.arrival_flight.value && !f.NoFlight.checked){
			if (!f.comments.value){
					setRedBorder('arrival_flight');
				document.location.href="#delivery_info";
				highlight_div('help_1');
				alert("Flight # missing. If you're not arriving by plane, please indicate.");
				return false;
			}
			if (f.NoFlight.checked){
				f.arrival_flight.value == "No Flight";
			}
		}
	}
	if (document.getElementById("EB").value!="yes"){
		if (!checkFlightAndTime()) return false;
	}
	if (!checkAllDates()){return false;}
	if (!checkCarClass(1)){return false;}
	if (document.getElementById("EB").value!="yes"){
		if (!checkCustomerInfo()) {return false;}
		if (!checkExtras()) {return false;}
		if (!checkCommentBox()) {return false;}
	//------------------------------------------------------------------------------------------------------------------------------------
	//--- Added by Dao G. Yang January 4, 2007 (Service Level Project)
	//------------------------------------------------------------------------------------------------------------------------------------
		if (!checkServiceLevel(1)){return false;}
		if (f.pick_loc.value==1 && checkCarClass(0)){
			if (f.SS2){
				if (f.SS2.checked){
					if (f.c_card.value==0){
						alert("You must enter your credit card information if you choose Express Self Service.")
						return false;
					}
					if (!f.CardType.value){
						alert("Please enter a card type.")
						return false;
					}
					if (!f.ExpMon.value){
						alert("Please enter an expiration month for your Credit Card.")
						return false;
					}
					if (f.ExpYear.value==0){
						alert("Please enter an expiration year for your Credit Card.")
						return false;
					}				
				}
			}
		}else{
			if (!f.c_card.value==0){
				if (!f.CardType.value){
					alert("Please enter a card type.")
					return false;
				}
				if (!f.ExpMon.value){
					alert("Please enter an expiration month.")
					return false;
				}
				if (f.ExpYear.value==0){
					alert("Please enter an expiration year.")
					return false;
				}							
			}
			return true;
		}
	//------------------------------------------------------------------------------------------------------------------------------------
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
//Call from book.tpl to check the rent info on the page
function rent() {
	var f = document.f;
	if (document.getElementById("EB").value!="yes")
		updatename();
	else
		eb_updatename();

	if (!check_book_info())
		return false;
	f.submit_type.value=2;
	f.submit();
	document.getElementById('but_bookcomplete').style.display='none';
	show_ticker();
}
//------------------------------------------------------------------------------------------------------------------------------------
function checkbutton(){
	var f = document.f;
	rent();
}
//------------------------------------------------------------------------------------------------------------------------------------
function loc_check(){
	var f = document.f;
	if (f.pick_loc.value==63 || f.pick_loc.value==34 || f.pick_loc.value==35 || f.pick_loc.value==37 || f.pick_loc.value==38){
		alert("This vehicle may not be available in the period you have chosen. We will confirm availability within 24 hours.");
		return true;
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function eb_checkbutton(){
	var f = document.f;
	f.action="http://dev.danskautorent.com/eb_book.php?bid="+document.getElementById("bid").value+"&ac="+document.getElementById("ac").value;

	if (f.pick_loc.value==1){
		mon = f.pick_time_mon.value-1;
		year = f.pick_time_year.value;
		dayofweek = new Date();
		dayofweek.setDate(f.pick_time_day.value);
		dayofweek.setMonth(mon);
		dayofweek.setFullYear(f.pick_time_year.value);
		weekday = dayofweek.getDay();
		if (weekday>=0 && weekday<6){	//Weekdays
			if ((f.pick_time_hour.value<7) || (f.pick_time_hour.value==23 && f.pick_time_min.value>30)){
				alert("Pick-Up Time: Express Booking at Kastrup Airport hours are between 7:00 and 23:30 on Sunday through Friday. To continue your booking with the hours you have chosen, please complete the form after clicking \'OK\'.");
				select_Car_Class(document.getElementById('car_class').value,0); 
				quick_quote_book_now();
				return true;
			}
		}
	}

	if (!f.fname.value){
		alert("Please enter your first name.");
		setRedBorder("fname");
		return false;
	}else if (!f.lname.value){
		alert("Please enter your last name.");
		setRedBorder("lname");
		return false;
	}else if (!f.email.value){
		alert("Please enter your email address.");
		setRedBorder("email");
		return false;
	}
	if (f.email.value){
		var myregexp = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i;
		result = myregexp.test(f.email.value);
		if (result == false){
			alert("Please enter a correct email address.");
			setRedBorder("email");
			return false;
		}
	}
	rent();
}
//------------------------------------------------------------------------------------------------------------------------------------
function add_waiting_list() {
	var f = document.f;

	if (!check_book_info())
		return false;
	f.submit_type.value=4;
	f.submit();
	show_ticker();
}
//------------------------------------------------------------------------------------------------------------------------------------
function check_calc_info(){
	var f = document.f;

	if (redBorderSetField!=''){
		var fl = document.getElementById(redBorderSetField);
		fl.style.borderWidth='1px';
		fl.style.borderColor='#000000';
	}

	unhighlight_div(highlightedDiv);

	if (!checkRentDates()){
		return false;
	}

	if (f.offer_id){
		if (f.offer_id.checked && !checkSpecialOffer()){
			return false;
		}
	}
	if (!checkCarClass(0)){
		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function check_qq_avail(){
	var f = document.f;
	
	var sval = document.getElementById('CAR_RESULTS1').scrollLeft;

	if (!document.getElementById('bid').value){
		if (getQueryVariable("city")){
			f.action="http://dev.danskautorent.com/index.php?sval="+sval+"&city="+getQueryVariable("city");
		}else{
			f.action="http://dev.danskautorent.com/index.php?sval="+sval;
		}
	}else{
		f.action="http://dev.danskautorent.com/eb_book.php?bid="+document.getElementById('bid').value+"&ac="+document.getElementById('ac').value+"&car_class="+document.getElementById('car_class').value+"&name="+document.getElementById('fname').value+"|"+document.getElementById('lname').value+"&email="+document.getElementById('email').value+"&sval="+sval;
		f.car_class.value = document.getElementById('car_class').value;
	}

	if (!f.car_class.value){
		f.car_class.value=24;
	}
	
	if (!check_calc_info()){
		return false;
	}
	f.submit_type.value=1;
	document.f.submit();
}
//------------------------------------------------------------------------------------------------------------------------------------
function retain_s_level(){
	if (getQueryVariable('s_level')){
		s_level = getQueryVariable('s_level');
		if (s_level != ''){
			if (s_level == 'SS1'){
				document.getElementById('SS1').checked = true;
				document.getElementById('SS2').checked = false;
			}else if (s_level == 'SS2'){
				document.getElementById('SS1').checked = false;
				document.getElementById('SS2').checked = true;
			}
	
		}
	}	
}
//------------------------------------------------------------------------------------------------------------------------------------
function retain_car_class(){
	if (getQueryVariable('car_class')){
		car_class = getQueryVariable('car_class');
		select_Car_Class2(car_class,1);
		//document.getElementById(car_class).scrollIntoView(true);
		document.getElementById('BODY').scrollIntoView(true);
		document.getElementById('car_class').value = car_class;
		document.getElementById('car_class').style.background='red';
		change_background(document.getElementById('car_class').value);
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function check_avail(){
	var f = document.f;
		
	if (!check_calc_info()){
		return false;
	}
	
	if (document.getElementById("EB").value!="yes"){
		if (!checkExtras()) {return false;}
	}
	var variable = getQueryVariable("ac");
	var car_class = document.getElementById('car_class').value;
	
	if (f.SS1 && f.SS2){
		if (f.SS1.checked == true){
			s_level = 'SS1';
		}else if (f.SS2.checked == true){
			s_level = 'SS2';
		}else{
			s_level='';
		}
	}else{
		s_level='';
	}

	var qsval = getQueryVariable('sval');
	if (document.getElementById('CAR_RESULTS1')){
		var sval = document.getElementById('CAR_RESULTS1').scrollLeft;
	}else{
		var sval = document.getElementById('CAR_RESULTS2').scrollLeft;
	}
	if (sval){
		f.action = f.action+"&sval="+sval;
	}

	if (variable){
		f.action='http://dev.danskautorent.com/book.php?from_quick_quote=0&ac='+variable+'&car_class='+car_class+'&s_level='+s_level+'&sval='+sval;
	}else{
		f.action='http://dev.danskautorent.com/book.php?from_quick_quote=0'+'&car_class='+car_class+'&s_level='+s_level+'&sval='+sval;
	}

	f.submit_type.value=1;
	document.f.submit();
//	show_ticker();
}
//------------------------------------------------------------------------------------------------------------------------------------
function quick_quote_book_now(){
	var f = document.f;
	//alert(check_calc_info());
	//alert(document.getElementById('car_class').value);
	var car_class = document.getElementById('car_class').value;
	if (!check_calc_info()){
		return false;
	}

	f.submit_type.value=1;
	var sval = document.getElementById('CAR_RESULTS1').scrollLeft;
	if (document.getElementById("bid")){
		f.action="http://dev.danskautorent.com/book.php?bid="+document.getElementById("bid").value+"&ac="+document.getElementById("ac").value+"&car_class="+car_class;
	}else{
		f.action='http://dev.danskautorent.com/book.php?from_quick_quote=1&car_class='+car_class;
	}
	if (sval){
		f.action = f.action+"&sval="+sval;
	}
	document.f.submit();
}
//--- Added by Dao G. Yang --- November 8, 2006---------------------------------------------------------------------------------------
function cars_prices_book_now(car_type,sval){
	var f = document.f;
	f.car_type.value = car_type;
	f.submit_type_from_cars_prices.value=1;
	f.action='http://dev.danskautorent.com/book.php?from_cars_prices=1&car_class='+car_type+'&sval='+sval;
	document.f.submit();
}
//------------------------------------------------------------------------------------------------------------------------------------
function selectOption(sel, opt){
	for (var i=0; i<sel.options.length; i++){
		if (sel.options[i].value==opt){
			sel.options[i].selected=true;
			break;
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function dateselect(yr, mon, field){
	y = yr[yr.selectedIndex].value;
	m = mon[mon.selectedIndex].value;
  	window.open('dateselect.php?mon_year='+y+m+'&field='+field,'dateselect', 'width=200,height=200,toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=0,copyhistory=0,screenX=350,screenY=300,top=300,left=350'); 
}
//------------------------------------------------------------------------------------------------------------------------------------
function takeDate(yr,m,d,field){
	ds = eval('document.f.'+field+'_day');
	ms = eval('document.f.'+field+'_mon');
	ys = eval('document.f.'+field+'_year');

	for(i=0; i<ds.length; i++){
		if (ds[i].value==d){
			ds[i].selected=true;
			break;
		}
	}

	for(i=0; i<ms.length; i++){
		if (ms[i].value==m){
			ms[i].selected=true;
			break;
		}
	}

	for(i=0; i<ys.length; i++){
		if (ys[i].text==yr){
			ys[i].selected=true;
			break;
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function change_additional_drivers_sel(){
	var f = document.f;
	
	f.submit_type.value=10;
	car_class = document.getElementById("car_class").value;
	f.action=f.action+'&car_class='+car_class+'#additional_drivers_pos';
	document.f.submit();
}
//------------------------------------------------------------------------------------------------------------------------------------
function promoshow_sel(){//Added per Michael's Request to show Promo Code Select on edit_clients.php
	var f = document.f;
	f.submit_type.value=20;
	f.action=f.action+'#promoshow_pos';
	document.f.submit();
}

var ticker_preload = new Image();
ticker_preload.src="img/ticker3.gif";
//------------------------------------------------------------------------------------------------------------------------------------
function show_ticker(){
	var ticker_img = document.getElementById("ticker_img");
	ticker_img.src=ticker_preload.src;
	var ticker = document.getElementById("ticker");
	if (typeof(document.body.clientWidth)!='undefined')
		ticker.style.left=parseInt(parseInt(document.body.clientWidth)/2)-35;
	if (typeof(document.body.scrollTop)!='undefined' && typeof(document.body.clientHeight)!='undefined')
		ticker.style.top=parseInt(document.body.scrollTop)+parseInt(document.body.clientHeight)-200;
	ticker.style.display='block';
}
//------------------------------------------------------------------------------------------------------------------------------------
function show_live_help_icon(imgname, ddp_x, ddp_y, imgwidth, imgheight) {
	var text;
	var text = "<table width='100%' height='100%' border='0' bgcolor='#023B70' cellspacing='1' cellpadding='1'>";
	text += "<tr><td align='left' valign='top' bgcolor='white'>";
//--- dev Links ---------------------------------------------------------------------------------------------------------------------
	text += "<a href=\"\" onClick=\"javascript: window.open('http://dev.danskautorent.com/onlinehelp.php', 'onlinehelp','width=330,height=500,toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0'); return false;\"><img src='img/"+imgname+"' alt='' border='' width="+imgwidth+" height="+imgheight+"></a>";
//--- Live Links ---------------------------------------------------------------------------------------------------------------------
//	text += "<a href=\"\" onClick=\"javascript: window.open('http://dev.danskautorent.com/onlinehelp.php', 'onlinehelp','width=330,height=500,toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0'); return false;\"><img src='img/"+imgname+"' alt='' border='' width="+imgwidth+" height="+imgheight+"></a>";
	text += "</td></tr></table>";

	ddp_show_layer(text, ddp_x, ddp_y, imgwidth+4, imgheight+4);
}
//------------------------------------------------------------------------------------------------------------------------------------
function check_roofbox(){
	var roofbox = document.getElementById("extras["+roof_box_id+"]");
	if (roofbox == null)
	{
		return true;
	}
	if (roofbox.value == "" || parseInt(roofbox.value) == 0)
	{
		return true;
	}

	if (parseInt(roofbox.value)){
		if (parseInt(f.pick_loc.value) != kastrup_id || parseInt(f.drop_loc.value) != kastrup_id){
			unhighlight_div();
			highlight_div('help_2');
			alert("Roof box is not available outside Kastrup.");
			return false;
		}
	}
	if (parseInt(document.f.car_class.value) != roof_box_car_class_id )
	{
		unhighlight_div();
		highlight_div('help_2');
		alert("Roof box is available only with Opel Zafira.");
		return false;
	}
	return true;
}
//------------------------------------------------------------------------------------------------------------------------------------
function highlight_div(div_id){
	var myDiv = document.getElementById(div_id);
	if (myDiv != null)
	{
//		myDiv.style.fontWeight = 'bold';
//		myDiv.style.color = 'red';
		myDiv.innerHTML = '<img src="img/helpfaqred.jpg" width="68" height="21" alt="Help/FAQ" Title="Help/FAQ" border="0">';
		highlightedDiv = div_id;
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function unhighlight_div(){
	if (highlightedDiv != '')
	{
		var myDiv = document.getElementById(highlightedDiv);
		if (myDiv != null)
		{
//			myDiv.style.fontWeight = 'normal';
//			myDiv.style.color = 'black';
			myDiv.innerHTML = '<img src="img/helpfaq.jpg" width="68" height="21" alt="Help/FAQ" Title="Help/FAQ" border="0">';
		}
	}
}
//------------------------------------------------------------------------------------------------------------------------------------
function showDiv(myDiv){
	myDiv.style.display = "";
}
//------------------------------------------------------------------------------------------------------------------------------------
function hideDiv(myDiv){
	myDiv.style.display = "none";
}

//=====================================================================================================================================
//=====================================================================================================================================
// Credit Card Check - BEGIN
//=====================================================================================================================================
//=====================================================================================================================================

<!-- Begin
var Cards = new makeArray(5);

Cards[0] = new CardType("MasterCard", "51,52,53,54,55", "16");
var MasterCard = Cards[0];

Cards[1] = new CardType("VisaCard", "4", "13,16");
var VisaCard = Cards[1];

Cards[2] = new CardType("AmExCard", "34,37", "15");
var AmExCard = Cards[2];

Cards[3] = new CardType("Dankort", "5019", "16");
var Dankort = Cards[3];

var LuhnCheckSum = Cards[4] = new CardType();

/*************************************************************************\
CheckCardNumber(form)
function called when users click the "check" button.
\*************************************************************************/
function CheckCardNumber() {
var f = document.f
var tmpyear;
	if (f.c_card.value.length == 0) {
		//alert("Please enter a Card Number.");
		f.c_card.focus();
		return;
	}
	if (f.ExpYear.value.length == 0) {
		//alert("Please enter the Expiration Year.");
		f.ExpYear.focus();
		return;
	}
	if (f.ExpYear.value < 21)
		tmpyear = "20" + f.ExpYear.value;
	else {
		alert("The Expiration Year is not valid.");
		return;
	}
	tmpmonth = f.ExpMon.options[f.ExpMon.selectedIndex].value;
	//alert("tmpmonth: "+tmpmonth);
	// The following line doesn't work in IE3, you need to change it
	// to something like "(new CardType())...".
	// if (!CardType().isExpiryDate(tmpyear, tmpmonth)) {
	if (!(new CardType()).isExpiryDate(tmpyear, tmpmonth)) {
		alert("This card has already expired.");
	return;
	}
	card = f.CardType.options[f.CardType.selectedIndex].value;
	//alert(card);
	//alert(card + ".checkCardNumber(\"" + f.c_card.value + "\", " + tmpyear + ", " + tmpmonth + ");");
	var retval = eval(card + ".checkCardNumber(\"" + f.c_card.value + "\", " + tmpyear + ", " + tmpmonth + ");");
	//alert(retval);
	cardname = "";
	if (retval)
		// comment this out if used on an order form
		//alert("This card number appears to be valid.");
	//else {
	// The cardnumber has the valid luhn checksum, but we want to know which
	// cardtype it belongs to.
		for (var n = 0; n < Cards.size; n++) {
			if (Cards[n].checkCardNumber(f.c_card.value, tmpyear, tmpmonth)) {
				cardname = Cards[n].getCardType();
				break;
		   }
		}
		if (cardname.length > 0) {
			//alert(cardname.length);
			//alert("This looks like a " + cardname + " number, not a " + card + " number.");
			return true;
		}else{
			//alert(cardname.length);
			alert("This card number is not valid.");
			return false;
		}
	//}
}
/*************************************************************************\
Object CardType([String cardtype, String rules, String len, int year, 
                                        int month])
cardtype    : type of card, eg: MasterCard, Visa, etc.
rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
len         : valid length of cardnumber, eg: "16,19", "13,16".
year        : year of expiry date.
month       : month of expiry date.
eg:
var VisaCard = new CardType("Visa", "4", "16");
var AmExCard = new CardType("AmEx", "34,37", "15");
\*************************************************************************/
function CardType() {
	var n;
	var argv = CardType.arguments;
	var argc = CardType.arguments.length;
	
	this.objname = "object CardType";
	
	var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
	var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
	var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";
	
	this.setCardNumber = setCardNumber;  // set CardNumber method.
	this.setCardType = setCardType;  // setCardType method.
	this.setLen = setLen;  // setLen method.
	this.setRules = setRules;  // setRules method.
	this.setExpiryDate = setExpiryDate;  // setExpiryDate method.
	
	this.setCardType(tmpcardtype);
	this.setLen(tmplen);
	this.setRules(tmprules);
	if (argc > 4)
	this.setExpiryDate(argv[3], argv[4]);
	
	this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
	this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
	this.getCardType = getCardType;  // getCardType method.
	this.isCardNumber = isCardNumber;  // isCardNumber method.
	this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
	this.luhnCheck = luhnCheck;// luhnCheck method.
	return this;
}

/*************************************************************************\
boolean checkCardNumber([String cardnumber, int year, int month])
return true if cardnumber pass the luhncheck and the expiry date is
valid, else return false.
\*************************************************************************/
function checkCardNumber() {
	//alert("checkCardNumber: "+checkCardNumber);
	var argv = checkCardNumber.arguments;
	//alert("argv: "+argv);
	var argc = checkCardNumber.arguments.length;
	//alert("argc: "+argc);
	var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
	//alert("cardnumber: "+cardnumber);
	var year = (argc > 1) ? argv[1] : this.year;
	//alert("year: "+year);
	var month = (argc > 2) ? argv[2] : this.month;
	//alert("month: "+month);
	
	this.setCardNumber(cardnumber);
	this.setExpiryDate(year, month);
	
	//alert("Is this a card number: "+this.isCardNumber());
	
	if (!this.isCardNumber()){return false;}
	if (!this.isExpiryDate()){return false;}
	
	return true;
}
/*************************************************************************\
String getCardType()
return the cardtype.
\*************************************************************************/
function getCardType() {
	//alert(this.cardtype);
	return this.cardtype;
}
/*************************************************************************\
String getExpiryDate()
return the expiry date.
\*************************************************************************/
function getExpiryDate() {
	return this.month + "/" + this.year;
}
/*************************************************************************\
boolean isCardNumber([String cardnumber])
return true if cardnumber pass the luhncheck and the rules, else return
false.
\*************************************************************************/
function isCardNumber() {
	var argv = isCardNumber.arguments;
	//alert("argv: "+argv);
	var argc = isCardNumber.arguments.length;
	//alert("argc: "+argc);
	var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
	//alert("cardnumber: "+cardnumber);
	//alert("luhnCheck is: "+this.luhnCheck())
	if (!this.luhnCheck())
		return false;
	
	for (var n = 0; n < this.len.size; n++)
		if (cardnumber.toString().length == this.len[n]) {
			for (var m = 0; m < this.rules.size; m++) {
				var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
				if (headdigit == this.rules[m])
				return true;
			}
			return false;
		}
	return false;
}

/*************************************************************************\
boolean isExpiryDate([int year, int month])
return true if the date is a valid expiry date,
else return false.
\*************************************************************************/
function isExpiryDate() {
	var argv = isExpiryDate.arguments;
	var argc = isExpiryDate.arguments.length;
	
	year = argc > 0 ? argv[0] : this.year;
	month = argc > 1 ? argv[1] : this.month;
	
	if (!isNum(year+""))
		return false;
	if (!isNum(month+""))
		return false;
	today = new Date();
	expiry = new Date(year, month);
	if (today.getTime() > expiry.getTime())
		return false;
	else
		return true;
}

/*************************************************************************\
boolean isNum(String argvalue)
return true if argvalue contains only numeric characters,
else return false.
\*************************************************************************/
function isNum(argvalue) {
	argvalue = argvalue.toString();
	
	if (argvalue.length == 0)
		return false;
	
	for (var n = 0; n < argvalue.length; n++)
		if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
			return false;
	return true;
}

/*************************************************************************\
boolean luhnCheck([String CardNumber])
return true if CardNumber pass the luhn check else return false.
\*************************************************************************/
function luhnCheck() {
	var argv = luhnCheck.arguments;
	var argc = luhnCheck.arguments.length;
	
	var CardNumber = argc > 0 ? argv[0] : this.cardnumber;
	
		if (! isNum(CardNumber)) {
		return false;
		  }
	
	var no_digit = CardNumber.length;
	var oddoeven = no_digit & 1;
	var sum = 0;
	
		for (var count = 0; count < no_digit; count++) {
			var digit = parseInt(CardNumber.charAt(count));
				if (!((count & 1) ^ oddoeven)) {
					digit *= 2;
					if (digit > 9)
						digit -= 9;
				}
			sum += digit;
		}
	if (sum % 10 == 0)
		return true;
	else
		return false;
}

/*************************************************************************\
ArrayObject makeArray(int size)
return the array object in the size specified.
\*************************************************************************/
function makeArray(size) {
	this.size = size;
	return this;
}

/*************************************************************************\
CardType setCardNumber(cardnumber)
return the CardType object.
\*************************************************************************/
function setCardNumber(cardnumber) {
	this.cardnumber = cardnumber;
	return this;
}

/*************************************************************************\
CardType setCardType(cardtype)
return the CardType object.
\*************************************************************************/
function setCardType(cardtype) {
	this.cardtype = cardtype;
	return this;
}

/*************************************************************************\
CardType setExpiryDate(year, month)
return the CardType object.
\*************************************************************************/
function setExpiryDate(year, month) {
	this.year = year;
	this.month = month;
	return this;
}

/*************************************************************************\
CardType setLen(len)
return the CardType object.
\*************************************************************************/
function setLen(len) {
	// Create the len array.
	if (len.length == 0 || len == null)
	len = "13,14,15,16,19";
	
	var tmplen = len;
	n = 1;
	while (tmplen.indexOf(",") != -1) {
	tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
	n++;
	}
	this.len = new makeArray(n);
	n = 0;
	while (len.indexOf(",") != -1) {
	var tmpstr = len.substring(0, len.indexOf(","));
	this.len[n] = tmpstr;
	len = len.substring(len.indexOf(",") + 1, len.length);
	n++;
	}
	this.len[n] = len;
	return this;
}

/*************************************************************************\
CardType setRules()
return the CardType object.
\*************************************************************************/
function setRules(rules) {
// Create the rules array.
	if (rules.length == 0 || rules == null)
	rules = "0,1,2,3,4,5,6,7,8,9";
	  
	var tmprules = rules;
	n = 1;
		while (tmprules.indexOf(",") != -1) {
		tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
		n++;
		}
	this.rules = new makeArray(n);
	n = 0;
		while (rules.indexOf(",") != -1) {
		var tmpstr = rules.substring(0, rules.indexOf(","));
		this.rules[n] = tmpstr;
		rules = rules.substring(rules.indexOf(",") + 1, rules.length);
		n++;
		}
	this.rules[n] = rules;
	return this;
}

//=====================================================================================================================================
//=====================================================================================================================================
// Credit Card Check - END
//=====================================================================================================================================
//=====================================================================================================================================
