

function getValue(varname)
{
  // First, we load the URL into a variable
  var url = window.location.href;

  // Next, split the url by the ?
  var qparts = url.split("?");

  // Check that there is a querystring, return "" if not
  if (qparts.length == 0)
  {
    return "";
  }

  // Then find the querystring, everything after the ?
  var query = qparts[1];

  // Split the query string into variables (separates by &s)
  var vars = query.split("&");

  // Initialize the value with "" as default
  var value = "";

  // Iterate through vars, checking each one for varname
  for (i=0;i<vars.length;i++)
  {
    // Split the variable by =, which splits name and value
    var parts = vars[i].split("=");
    
    // Check if the correct variable
    if (parts[0] == varname)
    {
      // Load value into variable
      value = parts[1];

      // End the loop
      break;
    }
  }
  
  // Convert escape code
  value = unescape(value);

  // Convert "+"s to " "s
  value.replace(/\+/g," ");

  // Return the value
  return value;
}


	
	
	if(document.layers) {ver = "ns4"}
	if(!document.all && document.getElementById){ver = "ns6"}
	if(document.all) {ver = "ie"}

	function show2(id) {
		if (ver == "ie")
		{
			document.all[id].style.display = "block";
			document.all[id].style.visibility = "visible";
		}
		else if (ver == "ns4")
		{
			document.layers[id].display = "block";
			document.layers[id].visibility = "show";
		}
		else //(ver == "ns6")
		{
			document.getElementById(id).style.display="block";
			document.getElementById(id).style.visibility="visible";
		}
		var str=id;
		str.replace(/content_/,"#top");
		location.hash= str;
	}

	function hide2(id) {
		if (ver == "ie")
		{
			document.all[id].style.visibility = "hidden";
			document.all[id].style.display = "none";
		}
		else if (ver == "ns4")
		{
			document.layers[id].visibility = "hide";
			document.layers[id].style.display = "none";
		}
		else //(ver == "ns6")
		{
			document.getElementById(id).style.display="none";
			document.getElementById(id).style.visibility="hidden";
		}
	}



	/* script for form / ordering online**/

	var inputdisabled = false;

	function init(myform) {


	    //check_login(myform,myform.m_dummy.value);
	}

	function openWindow(myLink,windowName) {
	    if(! window.focus)
	        return;

	    myLink.target=windowName;
	    var myWin=window.open(myLink,windowName,"scrollbars=yes,resizable=yes,width=500,height=400");
	    myWin.focus();
	}







	function isDigit (c)
	{
	   var strAllowed = "1234567890";
	   return (strAllowed.indexOf (c) != -1);
	}



	function check_login(aform,strLogin) {

/*
		var letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	    // is the second character a digit or a letter ?
		if(letters.indexOf(strLogin.charAt(1)) == -1) {
	                // a digit : it's a phone number
			aform.m_alias.value = strLogin;
			aform.m_login.value = "";
		} else {
	                // a letter : it's a login name
			aform.m_login.value = strLogin;
			aform.m_alias.value = "";
		}

*/

		return;
	}


	function loginOK(myform) {

//		if ((myform.m_login.value.length > 0 || myform.m_alias.value.length > 0) && myform.m_password.value.length > 0) {
//			return true;
			
//		}
//		else {	
			return false;
//		}
	
	}
	
	function codename(myform) {
	
	if(myform.registercode_check.checked)
	{
	myform.m_salescondition_id_1.disabled=false;
	}
	
	else
	{
	myform.m_salescondition_id_1.disabled=true;
	}
}

	function registrationOK(myform) {

		var ok = true;

	//	myform.m_cus_gsm.value
		ok &= myform.m_cus_email.value.length > 0;
	//	myform.m_sex_id.value
	//	myform.m_lang_id.value
		ok &= myform.m_cus_fname.value.length > 0;
		ok &= myform.m_cus_lname.value.length > 0;
		ok &= myform.m_cus_organizationname1.value.length > 0;
		ok &= myform.m_cus_streetname_delivery.value.length > 0;
		ok &= myform.m_cus_housenbr_delivery.value.length > 0;
	//	myform.m_cus_boxnbr_delivery.value

	//	myform.m_cou_id_delivery.value
		ok &= myform.m_cus_postcodetxt_delivery.value.length > 0;
		ok &= myform.m_cus_citytxt_delivery.value.length > 0;
	//	myform.m_post_id_delivery.value
	//	ok &= myform.m_cus_telday.value.length > 0;

	/*
		myform.m_day.value
		myform.m_month.value
		myform.m_year.value
	*/
		
		return ok;
	}

	function clear_all(myform) {

//	    myform.m_login.value="";
//	    myform.m_dummy.value="";
//	    myform.m_alias.value="";
//	    myform.m_password.value=""; 
	    myform.m_cus_email.value="";
	    myform.confirm_email.value="";
	    myform.m_cus_fname.value="";

	}



	function checkFields(myform, lang) {
	
		    //check_login(myform,myform.m_dummy.value);
	
			if (/*!loginOK(myform)  &&*/  !registrationOK(myform)) {
				if (lang == 'DUT') {
				    alert("Gelieve het registratie formulier of logingegevens volledig in te vullen.");
				}
				else if (lang == 'FRE') {
				    alert("Veuillez remplir votre profil ou identifiant.");
				}
				else {
				    alert("Please complete the login form or registration form.");
				}
				
				return false;
			}

			if (myform.m_cus_telday.value.length > 0) {

			    // check if it contains at least 9 digits
			    var reformatted="";
			    for (var i=0; i < myform.m_cus_telday.value.length; i++) {
				var c = myform.m_cus_telday.value.charAt(i);
				if (isDigit(c)) {
				    reformatted += c;
				}		
			    }
			    if (reformatted.length < 9) {
				if (lang == 'DUT') {
				    alert("Het formaat van het telefoonnummer is onjuist.");
				}
				else if (lang == 'FRE') {
				    alert("Le numéro de téléphone est incorrect.");
				}
				else {
				    alert("The format of the telephone number is not correct.");
				}
				return false;
			    }
			}
	

	
	// ***!
	/*
			if (myform.m_deliverymethod.value == "0") {
						alert("Choose delivery method");
						return false;
			}
	*/
	
	/*	    if (myform.val_sales_cond.checked == false) {
				alert("Please, agree to the Terms and Conditions");
				return false;
			}
	*/
			
			if(myform.m_cus_email.value != myform.confirm_email.value){
				if (lang == 'DUT') {
				    alert("Het emailadres is niet correct geconfirmeerd.");
				}
				else if (lang == 'FRE') {
				    alert("Votre adresse email n'est pas confirme correctement");
				}
				else {
				    alert("Your email address is not confirmed correctly, test");
				}
				return false;
			}
		
	

			return true;
	
		}
	

function getBaseURL() {
    var url = document.location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));


    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl;
    }
    else {
        // Root Url for domain name
        return baseURL;
    }

}

function submitting(myform, lang) {
	/*
	if (!checkFields(myform, lang)) {
		return;
	}
	*/
	document.body.style.cursor = "wait";
	var http_url;
	var base_url = getBaseURL();

	http_url = base_url +  "/optioncomplete";
	myform.action = http_url;
	myform.submit();		       
	document.body.style.cursor = "default";	
	return;
}

function submitscreenhttp_pw_forgot(myform, lang) {
	document.body.style.cursor = "wait";
	var http_url = "http://sales.teleticketservice.com/artexis-sales?showforgotpwd=yes&skin=ART&url=http://www.flandersexpo.be&engid=35&lang=" + lang;
	// ***!
	myform.action = http_url;
	myform.submit();
	return;
}

function clear_login(myform){
	//myform.m_dummy.value="";
	//myform.m_password.value="";
	//check_login(myform,myform.m_dummy.value);
}
		

