var click_count=1;
var tab_timer=null;
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		//alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}

var Req = getXmlHttpRequestObject();
	

function switch_tab(targetTab, params, obj) {
	//change id of containing div to apply correct css
	obj.parentNode.parentNode.id=targetTab;
	//get all tabs into array and make none have selected class
	array=obj.parentNode.getElementsByTagName('a');
	for (i in array){
		array[i].className='';
	}
	//make active tab select class
	obj.className='selected';
	//make ajax call to function and pass output to handler
	if (Req.readyState == 4 || Req.readyState == 0) {
		Req.open("GET", 'inc.function_call.php?func=' + targetTab + '&params=' + params + '&' + Math.random(), true);
		Req.onreadystatechange = handleSwitchTab; 
		Req.send(null);
	}
}
function handleSwitchTab() {
	if (Req.readyState == 4) {
	var ss = document.getElementById('ajax_tab')
	ss.innerHTML = '';
	ss.innerHTML = Req.responseText;
	run_sIFR("main_header_right_align");
	}
}

function switch_brand_tab(func, brandid, num, targetTab, obj) {
	//cancel tab timer
	if (tab_timer){
		clearTimeout(tab_timer);
	}
	//change background image
	document.getElementById('home_fav_brands').style.backgroundImage='url(../images/backgrounds/fav_brands_bg_'+targetTab+'.jpg)';
	// get tab divs into array and unselect them all
	array=obj.parentNode.parentNode.getElementsByTagName('div');
	for (i in array){
		array[i].className='brand_text_tab';
	}
	// select selected tab
	obj.parentNode.className='brand_text_tab_selected';
	//make ajax call to function and pass output to handler
	if (Req.readyState == 4 || Req.readyState == 0) {
		Req.open("GET", 'inc.function_call.php?func=' + func + '&params=' + brandid + "," + num + "&" + Math.random(), true);
		Req.onreadystatechange = handleSwitchBrandTab; 
		Req.send(null);
	}
}
function handleSwitchBrandTab() {
	if (Req.readyState == 4) {
	var ss = document.getElementById('ajax_brands')
	//ss.innerHTML = '';
	ss.innerHTML = Req.responseText;
	//run_sIFR("main_header_right_align");
	}
}

function cycle_tabs(){
		tab_timer=setTimeout("click_tab(" + click_count + ")", 6000);
			
}
function click_tab(i){
	document.getElementById('brand_tab_link_'+i).onclick();
	if (click_count < 4){
		click_count++;
	}else{
		click_count=1;
	}
	cycle_tabs();
}


// Single function takes calling object as "source" so it can get the value
// Then calls inc.dd_draw.php passing the source value and target div
// inc.dd_draw calls php class function to make db call and get html to put in target div.
// Note: handler function nested to use local "target" object

function fnc_dd_populate(source, target, choice){

//alert('c=');
//alert(source);
//alert(target);
//alert(choice);
//alert('s=');alert(source);alert(Req.readyState);

	if (Req.readyState == 4 || Req.readyState == 0) {
		Req.open("GET", '../includes/inc.dd_draw.php?target=' + target + '&source_value=' + source + '&selected' + choice + '&' + Math.random(), true);
		Req.onreadystatechange = function (){
									if (Req.readyState == 4) {//alert(Req.responseText);
										document.getElementById(target).innerHTML=Req.responseText;

									}
								}
		Req.send(null);
		if (target == "cat_search_filter")
		{//alert('change subcat');
		dummy = fnc_dd_populate(0, "subcat_search_filter","");
		}
		if (target == "cat_product_filter")
		{//alert('change subcat');
		dummy = fnc_dd_populate(0, "subcat_product_filter","");
		}
		if (target == "my_product_cats")
		{//alert('change subcat');
		dummy = fnc_dd_populate("", "my_product_subcats","");
		}
		if (target == "my_supplier_product_depts")
		{//alert('change subcat');
		dummy = fnc_dd_populate("", "my_supplier_product_cats","");
		}
		if (target == "my_supplier_product_cats")
		{//alert('change subcat');
		dummy = fnc_dd_populate("", "my_supplier_product_subcats","");
		}
	}
}

function fnc_brand_dd_populate(source, target, choice){

//alert('t=');alert(target);alert('s=');alert(source);alert(Req.readyState);

	if (Req.readyState == 4 || Req.readyState == 0) {
		//alert('../includes/inc.dd_brand_draw.php?source_value=' + source + '&selected' + choice + '&' + Math.random());
		Req.open("GET", '../includes/inc.dd_brand_draw.php?source_value=' + source + '&selected' + choice + '&' + Math.random(), true);
		Req.onreadystatechange = function (){
									if (Req.readyState == 4) {//alert(Req.responseText);
										document.getElementById(target).innerHTML=Req.responseText;
										if (target=="my_supplier_product_brands")	{
											fnc_dd_populate(source, "my_supplier_product_depts", "");
										}

									}
								}
		Req.send(null);
	}
}

function fnc_mc_dd_populate(source, target, choice){

//alert('t=');alert(target);alert('s=');alert(source);alert(Req.readyState);

	if (Req.readyState == 4 || Req.readyState == 0) {
		Req.open("GET", '../includes/inc.dd_mc_draw.php?target=' + target + '&source_value=' + source + '&selected' + choice + '&' + Math.random(), true);
		Req.onreadystatechange = function (){
									if (Req.readyState == 4) {
										document.getElementById(target).innerHTML=Req.responseText;
									}
								}
		Req.send(null);

		if (target == "model_search_filter")
		{//alert('change version');
		dummy = fnc_mc_dd_populate(0, "version_search_filter","");
		}
		if (target == "version_search_filter")
		{//alert('change year');
		dummy = fnc_mc_dd_populate(0, "year_search_filter","");
		}
	}
}

function fnc_dd_populate_brands_and_cats_for_supplier(source)
{
	fnc_brand_dd_populate(source, "my_supplier_product_brands", "");
	
}


function run_sIFR(replace)
{
	if(typeof sIFR == "function")
	{
		switch (replace)
		{		

			
			case "main_header_left_align" :
				sIFR.replaceElement(named({sSelector:".prod_header, .checkout_sec_header, .cs_header, .compat_header, .home_header, .myaccount_page_header, .prod_properties_header, .myaccount_page_header, .search_header", 
				sFlashSrc:"/includes/swf/verona.swf", sColor:"#000000", sLinkColor:"#000000", sBgColor:"#FFFFFF", 
				sHoverColor:"#FFF", nPaddingTop:20, nPaddingBottom:0, 
				sFlashVars:"textalign=left&offsetTop=0&offsetBottom=0"}));
			break;
			
			case "sub_header_cs" :
					sIFR.replaceElement(named({sSelector:".cs_subheader, .search_subheader, .myaccount_page_subheader", sFlashSrc:"/includes/swf/modena.swf", 
					sColor:"#77B900", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#FFF", 
					nPaddingTop:20, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
			break;
			
			case "sub_header_left_align" :
					sIFR.replaceElement(named({sSelector:".contact_content_header, .contact_content_text, .phone_text, .contact_content_no, .myaccount_page_subheader, .forgot_pass_txt, .co_column_orderid, .co_column_date, .co_column_total, .co_column_status, .prod_column_qty, .prod_column_code, .prod_column_items, .prod_column_total, .prod_column_status, .rtn_column_desc, .rtn_column_no, .rtn_column_qty, .rtn_column_reason", 
					sFlashSrc:"/includes/swf/modena.swf", sColor:"#000000", sLinkColor:"#e11f55", 
					sBgColor:"#FFFFFF", sHoverColor:"#000000", nPaddingTop:20, nPaddingBottom:0, 
					sFlashVars:"textalign=left&offsetTop=0"}));
			break;
			
			case "sub_header_left_align_magenta" :
					sIFR.replaceElement(named({sSelector:".search_subheader_zero", 
					sFlashSrc:"/includes/swf/modena.swf", sColor:"#E01E53", sLinkColor:"#e11f55", 
					sBgColor:"#FFFFFF", sHoverColor:"#000000", nPaddingTop:20, nPaddingBottom:0, 
					sFlashVars:"textalign=left&offsetTop=0"}));
			break;
			
			case "sub_header_bgcolour" :
					sIFR.replaceElement(named({sSelector:"", sFlashSrc:"/includes/swf/modena.swf", 
					sColor:"#FFFFFF", sLinkColor:"#000000",  sBgColor:"#79BA04", nPaddingTop:20, nPaddingBottom:0, 
					sFlashVars:"textalign=right&offsetTop=0"}));
			break;
			
			default:
		}
	}
}

var origcont;
function staf(prod_id){
	var sender_email = document.getElementById('sender_email').value;
	var friend_email = document.getElementById('friend_email').value;
	
	if (!origcont){
		document.getElementById('sender_email').value='';
		document.getElementById('friend_email').value='';
		origcont=document.getElementById('staf_box').innerHTML;
	}
	if (Req.readyState == 4 || Req.readyState == 0) {
		Req.open("GET", '/staf.php?prod_id=' + prod_id + '&sender_email=' + sender_email + '&friend_email=' + friend_email + '&' + Math.random(), true);
		Req.onreadystatechange = handleStaf; 
		Req.send(null);
	}
}

function handleStaf(){
	if (Req.readyState == 4) {
		var div = document.getElementById('staf_box')
		var str = Req.responseText;
		div.innerHTML = str + origcont;
	}
}

function show_req_payment(){
	method=document.getElementById('payment_method').value;
		document.getElementById('card_no_ast').style.visibility="visible";
		document.getElementById('sec_no_ast').style.visibility="visible";
		document.getElementById('name_ast').style.visibility="visible";
		document.getElementById('expiry_ast').style.visibility="visible";
	switch (method){
		case "VISA" :
			document.getElementById('valid_ast').style.visibility="visible";
			document.getElementById('iss_ast').style.visibility="hidden";
			break;
		case "DELTA" :
			document.getElementById('valid_ast').style.visibility="visible";
			document.getElementById('iss_ast').style.visibility="hidden";
			break;
		case "UKE" :
			document.getElementById('valid_ast').style.visibility="visible";
			document.getElementById('iss_ast').style.visibility="hidden";
			break;
		case "MC" :
			document.getElementById('valid_ast').style.visibility="visible";
			document.getElementById('iss_ast').style.visibility="hidden";
			break;
		case "SOLO" :
			document.getElementById('valid_ast').style.visibility="hidden";
			document.getElementById('iss_ast').style.visibility="visible";
			break;
		case "MAESTRO" :
			document.getElementById('valid_ast').style.visibility="hidden";
			document.getElementById('iss_ast').style.visibility="visible";
			break;
		default:
	}
}
 
//-----------------------Form validation functions start
function validatePassword (pw, options) {
	// default options (allows any password)
	var o = {
		lower:    0,
		upper:    0,
		alpha:    0, /* lower + upper */
		numeric:  0,
		special:  0,
		length:   [0, Infinity],
		custom:   [ /* regexes and/or functions */ ],
		badWords: [],
		badSequenceLength: 0,
		noQwertySequences: false,
		noSequential:      false
	};

	for (var property in options)
		o[property] = options[property];

	var	re = {
			lower:   /[a-z]/g,
			upper:   /[A-Z]/g,
			alpha:   /[A-Z]/gi,
			numeric: /[0-9]/g,
			special: /[\W_]/g
		},
		rule, i;

	// enforce min/max length
	if (pw.length < o.length[0] || pw.length > o.length[1])
		return false;

	// enforce lower/upper/alpha/numeric/special rules
	for (rule in re) {
		if ((pw.match(re[rule]) || []).length < o[rule])
			return false;
	}

	// enforce word ban (case insensitive)
	for (i = 0; i < o.badWords.length; i++) {
		if (pw.toLowerCase().indexOf(o.badWords[i].toLowerCase()) > -1)
			return false;
	}

	// enforce the no sequential, identical characters rule
	if (o.noSequential && /([\S\s])\1/.test(pw))
		return false;

	// enforce alphanumeric/qwerty sequence ban rules
	if (o.badSequenceLength) {
		var	lower   = "abcdefghijklmnopqrstuvwxyz",
			upper   = lower.toUpperCase(),
			numbers = "0123456789",
			qwerty  = "qwertyuiopasdfghjklzxcvbnm",
			start   = o.badSequenceLength - 1,
			seq     = "_" + pw.slice(0, start);
		for (i = start; i < pw.length; i++) {
			seq = seq.slice(1) + pw.charAt(i);
			if (
				lower.indexOf(seq)   > -1 ||
				upper.indexOf(seq)   > -1 ||
				numbers.indexOf(seq) > -1 ||
				(o.noQwertySequences && qwerty.indexOf(seq) > -1)
			) {
				return false;
			}
		}
	}

	// enforce custom regex/function rules
	for (i = 0; i < o.custom.length; i++) {
		rule = o.custom[i];
		if (rule instanceof RegExp) {
			if (!rule.test(pw))
				return false;
		} else if (rule instanceof Function) {
			if (!rule(pw))
				return false;
		}
	}

	// great success!
	return true;
}


function fnc_field_must_have_values(pp_field_name,pp_value)
{ 
	if (pp_value == "")	{
		return "\n\n" + pp_field_name + " cannot be empty. ";
	} else {
		return "";
	}
}

function fnc_field_not_just_numbers(pp_field_name,pp_value)
{ 
	if (pp_value > "" && pp_value.search(/^\d{1,}$/)>-1) 	
	{
		return "\n\n" + pp_field_name + " cannot be just numbers. ";
	} else {
		return "";
	}
}

function fnc_field_only_be_numbers(pp_field_name,pp_value)
{ 
	if (pp_value > "" && pp_value.search(/^\d{1,}$/)==-1) 	
	{
		return "\n\n" + pp_field_name + " must be just numbers. ";
	} else {
		return "";
	}
}

function fnc_field_is_lat_long_number(pp_field_name,pp_value)
{ 
	if (pp_value > "" && pp_value.search(/^\s*(\+|-)?((\d+(\.\d{4})?))\s*$/)==-1) 	
	{
		return "\n\n" + pp_field_name + " must be a number with 4 decimals and at least one digit before the decimal point. ";
	} else {
		return "";
	}
}

function fnc_field_must_have_chars(pp_field_name,pp_value)
{ 
	if (pp_value > "" && pp_value.search(/[a-z]{1,}/)==-1) 	{
		return "\n\n" + pp_field_name + " must have alpha characters (a-z). ";
	} else {
		return "";
	}
}

function fnc_field_must_be_login(pp_field_name,pp_value)
{ 
	if (pp_value > "" && pp_value.length<8) 	{
		return "\n\n" + pp_field_name + " must have at least 8 characters. ";
	} else {
		return "";
	}
}

function fnc_field_must_be_password(pp_field_name,pp_value)
{ 	var min_chars="8";
	var min_lower="1";
	var min_upper="1";
	var min_numeric="1";
	var min_special="1";
	var bad_seq_length="4";
	var banned_words="\"password\", \"index\", \"product\"";
	var ban_qwerty_sequences="true";
	var ban_sequential="true";

	if (pp_value > "" && !(validatePassword(pp_value, {length:[min_chars, Infinity],lower: min_lower,upper: min_upper,numeric: min_numeric,special: min_special,badWords: [banned_words],badSequenceLength: bad_seq_length,noQwertySequences: ban_qwerty_sequences,noSequential: ban_sequential}))) 	{
		var validate_message = "\n\n" + pp_field_name + " is not valid format.\n\n It must be at least " + min_chars + " characters long, must have at least "+min_lower+" lowercase character, must have at least "+min_upper+" uppercase character, must have at least "+ min_numeric +" numeric character, must have at least "+min_special+" special character (other than a–z, A–Z, and 0–9), cannot include an alphanumeric sequence "+bad_seq_length+" or more characters in length (e.g. '1234')";
		if (ban_qwerty_sequences=="true")	{
			validate_message = validate_message + ", cannot have qwerty character sequences (e.g. 'qwerty' or 'asdf') with a sequence length of "+ bad_seq_length;
		}
		if (ban_sequential=="true")	{
			validate_message = validate_message + ",cannot have sequential, identical characters (e.g. 'aa' or '!!'), cannot include the words "+banned_words+" ";
		}
		return validate_message;
	} else {
		return "";
	}
}

function fnc_field_must_have_email(pp_field_name,pp_value)
{ 
	if (pp_value > "") 	{
		var at="@"
		var dot="."
		var lat=pp_value.indexOf(at)
		var lstr=pp_value.length
		var ldot=pp_value.indexOf(dot)
		if (pp_value.indexOf(at)==-1){
		   return "\n\n" + pp_field_name + " must have valid email address. ";
		}

		if (pp_value.indexOf(at)==-1 || pp_value.indexOf(at)==0 || pp_value.indexOf(at)==lstr){
		   return "\n\n" + pp_field_name + " must have valid email address. ";
		}

		if (pp_value.indexOf(dot)==-1 || pp_value.indexOf(dot)==0 || pp_value.indexOf(dot)==lstr){
		    return "\n\n" + pp_field_name + " must have valid email address. ";
		}

		 if (pp_value.indexOf(at,(lat+1))!=-1){
		    return "\n\n" + pp_field_name + " must have valid email address. ";
		 }

		 if (pp_value.substring(lat-1,lat)==dot || pp_value.substring(lat+1,lat+2)==dot){
		    return "\n\n" + pp_field_name + " must have valid email address. ";
		 }

		 if (pp_value.indexOf(dot,(lat+2))==-1){
		    return "\n\n" + pp_field_name + " must have valid email address. ";
		 }
		
		 if (pp_value.indexOf(" ")!=-1){
		    return "\n\n" + pp_field_name + " must have valid email address. ";
		 }
	}

	return "";					

}

function fnc_field_is_web_address(pp_field_name,pp_value)
{ 	if (pp_value > "" && pp_value.search('^(http|https):\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+\.[A-Za-z0-9]') == -1) {
		return "\n\n" + pp_field_name + " is not a valid web address. ";
	} else {
		return "";
	}
}

function fnc_field_is_local_file(pp_field_name,pp_value)
{ 	if (pp_value > "" && pp_value.search('^[A-Za-z]:\\[A-Za-z0-9]+\.[A-Za-z0-9]') == -1) {
		return "\n\n" + pp_field_name + " is not a valid file path and name. ";
	} else {
		return "";
	}
}

function fnc_field_must_be_date(pp_field_name,pp_value)
{
 	if (pp_value > "" && pp_value.search('^[2][0][0-9][0-9]\-[0-1][0-9]\-[0-3][0-9]') == -1) {
		return "\n\n" + pp_field_name + " is not a valid date format (YYYY-MM-DD). ";
	} else {
		return "";
	}
}

function fnc_field_must_be_decimal_2(pp_field_name,pp_value)
{ 	if (pp_value > "" && pp_value.search('^[0-9]+\.[0-9][0-9]') == -1) {
		return "\n\n" + pp_field_name + " is not a decimal (2dp). ";
	} else {
		return "";
	}
}

function fnc_one_field_must_have_value(pp_field_name,pp_value1,pp_value2)
{	if (pp_value1 == "" && pp_value2 == "")	{
		return "\n\n One of " + pp_field_name + " must contain a value. ";
	} else {
		return "";
	}
		
}

function fnc_all_4_dds_must_have_value(pp_field_name,pp_value1,pp_value2,pp_value3,pp_value4)
{	if (pp_value1 == "" || pp_value2 == "" || pp_value3 == "" || pp_value4 == "")	{
		return "\n\n All of the " + pp_field_name + " fields must be selected.";
	} else {
		return "";
	}
}





function fnc_check_title(pp_value)
{ 	var field_name="Title";
	var valid="";
	valid = valid + fnc_field_not_just_numbers(field_name,pp_value);	
		
	return valid;
}
function fnc_check_first_name(pp_value)
{ 	var field_name="First Name";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_not_just_numbers(field_name,pp_value);	
	valid = valid + fnc_field_must_have_chars(field_name,pp_value);	
		
	return valid;
}
function fnc_check_last_name(pp_value)
{ 	var field_name="Last Name";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_not_just_numbers(field_name,pp_value);	
	valid = valid + fnc_field_must_have_chars(field_name,pp_value);	
		
	return valid;
}

function fnc_check_email(pp_value)
{ 	var field_name="Email";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_have_email(field_name,pp_value);	
		
	return valid;
}


function fnc_check_phone_number(pp_value)
{ 	var field_name="Telephone Number";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_only_be_numbers(field_name,pp_value);	
		
	return valid;
}

function fnc_check_fax_number(pp_value)
{ 	var field_name="Fax Number";
	var valid="";
	valid = valid + fnc_field_only_be_numbers(field_name,pp_value);	
		
	return valid;
}


function fnc_check_business_name(pp_value)
{ 	var field_name="Business Name/Organisation";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_address_1(pp_value)
{ 	var field_name="Address Line 1";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_address_other(pp_value)
{ 	var field_name="Ensure Every Address Line";
	var valid="";
		
	return valid;
}

function fnc_check_postcode_zip(pp_value)
{ 	var field_name="Postcode/Zip";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_website(pp_value)
{ 	var field_name="Website";
	var valid="";
	valid = valid + fnc_field_is_web_address(field_name,pp_value);	
		
	return valid;
}

function fnc_check_link_url(pp_value)
{ 	var field_name="Your link page URL";
	var valid="";
	valid = valid + fnc_field_is_web_address(field_name,pp_value);	
		
	return valid;
}

function fnc_check_latitude(pp_value)
{ 	var field_name="Latitude";
	var valid="";
	valid = valid + fnc_field_is_lat_long_number(field_name,pp_value);	
		
	return valid;
}

function fnc_check_longitude(pp_value)
{ 	var field_name="Longitude";
	var valid="";
	valid = valid + fnc_field_is_lat_long_number(field_name,pp_value);	
		
	return valid;
}

function fnc_check_login(pp_value)
{ 	var field_name="Login";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_be_login(field_name,pp_value);	
		
	return valid;
}

function fnc_check_password(pp_value)
{ 	var field_name="Password";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_be_password(field_name,pp_value);	
		
	return valid;
}

function fnc_check_sequence(pp_value)
{ 	var field_name="Sequence";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_only_be_numbers(field_name,pp_value);	
		
	return valid;
}

function fnc_check_lines_before(pp_value)
{ 	var field_name="Lines Before";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_only_be_numbers(field_name,pp_value);	
		
	return valid;
}

function fnc_check_desc(pp_value)
{ 	var field_name="Description";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_have_chars(field_name,pp_value);	
		
	return valid;
}


function fnc_check_lines_after(pp_value)
{ 	var field_name="Lines After";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_only_be_numbers(field_name,pp_value);	
		
	return valid;
}

function fnc_check_image_name(pp_value)
{ 	var field_name="Image Name";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_image_file_location(pp_value)
{ 	var field_name="Image File Location";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	//valid = valid + fnc_field_is_local_file(field_name,pp_value);	
		
	return valid;
}

function fnc_check_sort_order(pp_value)
{ 	var field_name="Sort Order";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_only_be_numbers(field_name,pp_value);	
		
	return valid;
}

function fnc_check_asset_type(pp_value)
{ 	var field_name="Asset Type";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_asset_name(pp_value)
{ 	var field_name="Asset Name";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_asset_url(pp_value)
{ 	var field_name="Asset URL";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_is_web_address(field_name,pp_value);	
		
	return valid;
}

function fnc_check_asset_file_location(pp_value)
{ 	var field_name="Asset File Location";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	//valid = valid + fnc_field_is_local_file(field_name,pp_value);	
		
	return valid;
}

function fnc_check_country(pp_value)
{ 	var field_name="Country/Market";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_from_date(pp_value)
{	var field_name="From Date";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_be_date(field_name,pp_value);	
		
	return valid;
}

function fnc_check_to_date(pp_value)
{	var field_name="To Date";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_be_date(field_name,pp_value);	
		
	return valid;
}

function fnc_check_srp(pp_value)
{ 	var field_name="SRP";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_be_decimal_2(field_name,pp_value);	
		
	return valid;
}

function fnc_check_price_plan(pp_value)
{ 	var field_name="Price Plan";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_price_inc_or_exc(pp_value1,pp_value2)
{ 	var field_name="Price ex tax or Price inc tax";
	var valid="";
	valid = valid + fnc_one_field_must_have_value(field_name,pp_value1,pp_value2);	
		
	return valid;
}
function fnc_check_price_exc(pp_value)
{ 	var field_name="Price ex tax";
	var valid="";
	if (pp_value > "")	{
		valid = valid + fnc_field_must_be_decimal_2(field_name,pp_value);
	}
		
	return valid;
}

function fnc_check_tax(pp_value)
{ 	var field_name="Tax rate";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
	valid = valid + fnc_field_must_be_decimal_2(field_name,pp_value);	
		
	return valid;
}

function fnc_check_price_inc(pp_value)
{ 	var field_name="Price inc tax";
	var valid="";
	if (pp_value > "")	{
		valid = valid + fnc_field_must_be_decimal_2(field_name,pp_value);
	}
		
	return valid;
}

function fnc_check_bike_selected(pp_value1,pp_value2,pp_value3,pp_value4)
{	var field_name="Make/Model/Version/Year";
	var valid="";
	valid = valid + fnc_all_4_dds_must_have_value(field_name,pp_value1,pp_value2,pp_value3,pp_value4);	
		
	return valid;
}

function fnc_check_property(pp_value)
{ 	var field_name="Property";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}

function fnc_check_value(pp_value)
{ 	var field_name="Value";
	var valid="";
	valid = valid + fnc_field_must_have_values(field_name,pp_value);	
		
	return valid;
}


//-----------------------Form validation functions end


// voucher functions start

function check_voucher() {
	var voucher_code = document.getElementById('voucher_code1').value + document.getElementById('voucher_code2').value + document.getElementById('voucher_code3').value + document.getElementById('voucher_code4').value
	if (Req.readyState == 4 || Req.readyState == 0) {
		Req.open("GET", '../includes/check_code.php?voucher_code=' + voucher_code + "&" + Math.random(), true);
		Req.onreadystatechange = handleVoucherCode; 
		Req.send(null);
	}
}

function nextbox(fldobj, nbox) { 
if (fldobj.value.length==fldobj.maxLength) {
fldobj.form.elements[nbox].focus();
}
} 

function handleVoucherCode() {
	if (Req.readyState == 4) {
		if (Req.responseText==''){
			window.location = "basket.php"
		}
	var ss = document.getElementById('voucher_details')
	ss.innerHTML = '';
	ss.innerHTML = Req.responseText;
	}
}

function showPhone(src)
{
	var img = document.getElementById("phone_display");
	//var select = document.getElementById("mod_select");
	img.src = src;
	img.style.display = '';
	
	img.onmouseout = function()
	{
		alert("out");
		img.style.display = 'none';
	}
}
