		function validatelogin(hbx, hbxtxt1, hbxtxt2, hbxrpath) {
		
			if (document.forms["loginform"].username.value == ""){
				alert("Please enter a valid username.");
				document.forms["loginform"].username.focus();
				return;
			}
			if (document.forms["loginform"].pw.value == ""){
				alert("Please enter a valid password.");
				document.forms["loginform"].pw.focus();
				return;
			}
			if (document.forms["loginform"].username.value.length > 9) {
				alert("\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.");
				document.forms["loginform"].username.focus();
				return;
			}
			if (document.forms["loginform"].pw.value.length > 9) {
				alert("\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.");
				document.forms["loginform"].pw.focus();
				return;
			}
			if (hbx=="Y") {
				hbxtxt= hbxtxt1 + document.forms["loginform"].username.value + hbxtxt2;
				hbx_setVCon(hbxtxt);
				if (hbxrpath!="") {
					hbx_setVCon(hbxrpath);
				}
			}
			document.forms['loginform'].submit();
		}
	
		function validatereqaccess(hbx) {
			
			// 1- magazinefree only for VPO!
			if (location.href.indexOf('mcvpo') > 0){
				if (document.forms["reqaccessform"].magazinefree.value.length > 50) {
					var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
					pos1 = str.indexOf('\'');
					pos2 = str.lastIndexOf('\'');
					str=str.replace(str.substring(pos1, pos2+1),document.getElementById('magazinefreelabel').innerHTML);
					str=str.replace('9','50');
					alert(str);
					document.forms["reqaccessform"].title.focus();
					return;
				}
				if (document.forms["reqaccessform"].magazinefree.value == "") {
					alert("Please fill in all required fields (marked with *).");
					document.forms["reqaccessform"].magazinefree.focus();
					return;
				}
			}
			
			//2- title field
			if (document.forms["reqaccessform"].title.value.length > 7) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('titlelabel').innerHTML);
				str=str.replace('9','7');
				alert(str);
				document.forms["reqaccessform"].title.focus();
				return;
			}
		
			//3-surname		
			if (document.forms["reqaccessform"].surname.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].surname.focus();
				return;
			}
			if (document.forms["reqaccessform"].surname.value.length > 40) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('surnamelabel').innerHTML);
				str=str.replace('9','40');
				alert(str);
				document.forms["reqaccessform"].surname.focus();
				return;
			}
			
			
			//4-firstname
			if (document.forms["reqaccessform"].firstname.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].firstname.focus();
				return;
			}
			if (document.forms["reqaccessform"].firstname.value.length > 40) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('firstnamelabel').innerHTML);
				str=str.replace('9','40');
				alert(str);
				document.forms["reqaccessform"].firstname.focus();
				return;
			}
			
			//5-email
			if (document.forms["reqaccessform"].email.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].email.focus();
				return;
			}
			if (document.forms["reqaccessform"].email.value.length > 129) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('emaillabel').innerHTML);
				str=str.replace('9','129');
				alert(str);
				document.forms["reqaccessform"].email.focus();
				return;
			}
			
			//6-phone
			if (document.forms["reqaccessform"].phone.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].phone.focus();
				return;
			}
			if (document.forms["reqaccessform"].phone.value.length > 20) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('phonelabel').innerHTML);
				str=str.replace('9','20');
				alert(str);
				document.forms["reqaccessform"].phone.focus();
				return;
			}
						
			
			//7-gsm
			if (document.forms["reqaccessform"].gsm.value.length > 20) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('gsmlabel').innerHTML);
				str=str.replace('9','20');
				alert(str);
				document.forms["reqaccessform"].gsm.focus();
				return;
			}
			//8-fax
			if (document.forms["reqaccessform"].fax.value.length > 20) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('faxlabel').innerHTML);
				str=str.replace('9','20');
				alert(str);
				document.forms["reqaccessform"].fax.focus();
				return;
			}
			
			//9-address
			if (document.forms["reqaccessform"].address.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].address.focus();
				return;
			}
			if (document.forms["reqaccessform"].address.value.length > 100) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('addresslabel').innerHTML);
				str=str.replace('9','100');
				alert(str);
				document.forms["reqaccessform"].address.focus();
				return;
			}
			
			//10-postcode
			if (document.forms["reqaccessform"].postcode.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].postcode.focus();
				return;
			}
			if (document.forms["reqaccessform"].postcode.value.length > 10) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('postcodelabel').innerHTML);
				str=str.replace('9','10');
				alert(str);
				document.forms["reqaccessform"].postcode.focus();
				return;
			}
			
			//11-city
			if (document.forms["reqaccessform"].city.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].city.focus();
				return;
			}
			if (document.forms["reqaccessform"].city.value.length > 40) {
				var str="\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.";
				pos1 = str.indexOf('\'');
				pos2 = str.lastIndexOf('\'');
				str=str.replace(str.substring(pos1, pos2+1),document.getElementById('citylabel').innerHTML);
				str=str.replace('9','40');
				alert(str);
				document.forms["reqaccessform"].city.focus();
				return;
			}
			
			//others
			
			if (document.forms["reqaccessform"].country.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].country.focus();
				return;
			}
			if (document.forms["reqaccessform"].preflanguage.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].preflanguage.focus();
				return;
			}
			if (document.forms["reqaccessform"].prefusername.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].prefusername.focus();
				return;
			}
			if (document.forms["reqaccessform"].pw.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].pw.focus();
				return;
			}
			if (document.forms["reqaccessform"].confirmpw.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["reqaccessform"].confirmpw.focus();
				return;
			}
			if (document.forms["reqaccessform"].pw.value != document.forms["reqaccessform"].confirmpw.value) {
				alert("Confirmed Password is not identical to Password.");
				document.forms["reqaccessform"].confirmpw.focus();
				return;
			}
			emailval = document.forms["reqaccessform"].email.value;
			if (!isEmail(emailval)){
				alert("Some of the details you entered are incorrect. Please try again.");
				document.forms["reqaccessform"].email.focus();
				return;
			}
			
			if (document.forms["reqaccessform"].prefusername.value.length > 9) {
				alert("\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.");
				document.forms["reqaccessform"].prefusername.focus();
				return;
			}
			if (document.forms["reqaccessform"].pw.value.length > 9) {
				alert("\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.");
				document.forms["reqaccessform"].pw.focus();
				return;
			}
			if (hbx=="Y") {
				hbx_setVCon('ACCESS/' + hbx_isoctry + '/' + document.forms["reqaccessform"].prefusername.value + '/REQUEST'); 
			}
			
			document.forms['reqaccessform'].submit();
		}
	
		function validatepwreminder() {
			if (document.forms["pwreminderform"].surname.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["pwreminderform"].surname.focus();
				return;
			}
			if (document.forms["pwreminderform"].firstname.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["pwreminderform"].firstname.focus();
				return;
			}
			if (document.forms["pwreminderform"].email.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["pwreminderform"].email.focus();
				return;
			}
			if (document.forms["pwreminderform"].country.value == "") {
				alert("Please fill in all required fields (marked with *).");
				document.forms["pwreminderform"].country.focus();
				return;
			}
			emailval = document.forms["pwreminderform"].email.value;
			if (!isEmail(emailval)){
				alert("Some of the details you entered are incorrect. Please try again.");
				document.forms["pwreminderform"].email.focus();
				return;
			}
			document.forms['pwreminderform'].submit();
		}


		function startupdmyimg(action,imgid,maintype,modelname,allimgs) {
			if (parent.myimg) {
				myimgframe = parent.myimg;
			}
			else {
				myimgframe = document.myimg;
			}
			if (action == 'A') { //add
				if (imgid != "") {
					if (myimgframe) {
						if (myimgframe.sMI) {
							sallmyimgs = myimgframe.sMI; 
							aallmyimgs = sallmyimgs.split(",");
							for(i=0; i < aallmyimgs.length; i++) {
								if (aallmyimgs[i] == "107" + "-" + imgid) {  
									alert("Image was already added to \'My Images\'.");
									action="";
									break;
								}
							}
						}
					}
				}
			}
			// remove
			if (action == 'R') {
				if (!myimgframe) {
					action = "";
					alert("There are no images added to My Images.");  
				}
				else {
					if (!myimgframe.sMI) {
						action = "";
						alert("There are no images added to My Images.");
					}
					else {
						if (myimgframe.sMI == "") {
							action = "";
							alert("There are no images added to My Images."); 
						}
						else {
							if ( (allimgs == "N") && (imgid != "")) {
								imgfound = false;
								if (myimgframe.sMI) {
									sallmyimgs = myimgframe.sMI; 
									aallmyimgs = sallmyimgs.split(","); 
									for(i=0; aallmyimgs.length; i++) {
										amyimgid = aallmyimgs[i].split("***");
										if (amyimgid[0] == "107" + "-" + imgid) {
											imgfound = true;
											break;
										}
									}
									if (!imgfound) {
										action = "";
										alert("Image not in \'My Images\'."); 
									}
								}
							}		
						} 
					}
				}
			}
			path = "/eu/en/addtomyimages.jsp";
			if (action !="") {
				path = path + "?&action=" + action + "&imgid=" + "107" + "-" + imgid + "&maintype=" + maintype + "&modelname=" + modelname + "&allimgs=" + allimgs;
			}
			myimgframe.document.location.href=path;
		}

		function validateupdate() {
			if (document.forms["myprofile"].pw.value == "") {
					alert("Please enter a valid password.");
					document.forms["myprofile"].pw.focus();
					return;
			}
			if (document.forms["myprofile"].newpw.value != "") {
				if (document.forms["myprofile"].newconfpw.value == "") {
					alert("Confirmed Password is not identical to Password.");
					document.forms["myprofile"].newconfpw.focus();
					return;
				}
				if (document.forms["myprofile"].newconfpw.value != document.forms["myprofile"].newpw.value) {
					alert("Confirmed Password is not identical to Password.");
					document.forms["myprofile"].newconfpw.focus();
					return;
				}
			}
			if (document.forms["myprofile"].username.value.length > 9) {
				alert("\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.");
				document.forms["myprofile"].username.focus();
				return;
			}
			if (document.forms["myprofile"].pw.value.length > 9) {
				alert("\'Preferred User Name\' and \'Password\' cannot be longer than 9 characters.");
				document.forms["myprofile"].pw.focus();
				return;
			}
			document.forms['myprofile'].saction.value="U";
			document.forms['myprofile'].submit();		
		}
		
		
		
		function validatemail() {
			if (document.forms["email"].yourname.value == "") {
					alert("Please make sure to enter a valid value in all fields indicated with *.");
					document.forms["email"].yourname.focus();
					return;
			}
			emailval= document.forms["email"].youremail.value
			if (!isEmail(emailval)){
				alert("Please make sure to enter a valid value in all fields indicated with *.");
				document.forms["email"].youremail.focus();
				return;
			}
			emailval= document.forms["email"].recipe.value
			if (!isEmail(emailval)){
					alert("Please make sure to enter a valid value in all fields indicated with *.");
					document.forms["email"].recipe.focus();
					return;
			}
			//replace return by <br> tag
			document.forms['email'].msg2.value = document.forms['email'].msg.value.replace(/\n/g,"<BR>");
			document.forms['email'].submit();		
		}
		function startLoading() {
			//document.all["loadingTD"].style.visibility = "visible";
			document.getElementById('loadingTD').style.display="block"; 
		}

		function stopLoading() {
//			parent.document.all["loadingTD"].style.visibility = "hidden";
			parent.document.getElementById('loadingTD').style.display="none";	
		}

		function SetCookie(cookieName,cookieValue) {
		 var today = new Date();
		 var expire = new Date();
		 expire.setTime(today.getTime() + 3600000*24*365);
		 document.cookie = cookieName+"="+escape(cookieValue) + ";path=/"
						 + ";expires="+expire.toGMTString();
		}
		function getCookie(NameOfCookie){
			if (document.cookie.length > 0) { 
				begin = document.cookie.indexOf(NameOfCookie+"="); 
				if (begin != -1) { 
					begin += NameOfCookie.length+1; 
					end = document.cookie.indexOf(";", begin);
					if (end == -1) end = document.cookie.length;
					return unescape(document.cookie.substring(begin, end)); 
				} 
			}
			return null;
		}

		function isEmail(e) {
			if(e.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
				return true;
			} 
			else {
				return false;
			}
		}
		
		
		function loadIframe(iframeName, url) {
 	 		var test ="document.getElementById('"+iframeName+"').src= url;"
			eval(test);
		}
		
		
		function GoToMyImages(){
			window.location='/eu/en/myimg.jsp?z='+Math.random();
		}

		function openURL(Lang)
		{
		//eg Lang='/fr'
			var url = window.location.href;
			url = url.replace("login.jsp", "home.jsp")
			var pos1 = url.indexOf(".com/") +4; //because '/' in sLang
			var lenLang=Lang.length
			var newurl = url.substring(0,pos1) + Lang + url.substring(pos1 + lenLang,url.length);
//			top.location.href = newurl;
			setTimeout("window.location.href ='"+newurl+"';",1000);
		}
		
		
		


