
function hideAll(){
	for(x=0;x<iterator;x++){
		new Effect.Fade(ids[x], {duration:2});
	}
}

function showAll(){
	for(x=0;x<iterator;x++){
		new Effect.Appear(ids[x], {duration:2});
	}
}

function showDesc(id){
	new Effect.Appear('d_'+id);
}

function setSelectToOption(id,value){
		  for (var idx=0;idx<document.getElementById(id).options.length;idx++) {
					 if (value==document.getElementById(id).options[idx].value) {
								document.getElementById(id).selectedIndex=idx;
								document.getElementById(id).options[idx].selected=true;
								break;
					 }
		  }      

}

/** 
 * sets link class 
*/

function setLinksActive(uri,classN){
	var a = document.getElementsByTagName ('a') ;
	for(i=0;i<a.length;i++){
		if(a[i].href == uri){
			a[i].className = classN;
		}
	}
}

function isIE()
{
return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

function setSplash(path){
	document.getElementById('splashImage').src = path;
}


function testRegister(type){
		  if( document.getElementById('email').value.length < 7){
					 alert('Please provide a working e-mail address! You will not be able to register without one!');
					 return false;
		  }
		  if( document.getElementById('passwd').value.length < 6){
					 alert('Password should be at least 6 chars long!');
					 return false;
		  }
		  if(
								document.getElementById('passwd').value == document.getElementById('passwd2').value 
			 ){
		  }else{
					 alert('"Please enter your password of choice below. Then, retype it in the field below to confirm the correct spelling.');
					 return false;
		  }
		  if(document.getElementById('name').value == ''){
		  	alert("Field 'Name' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('surname').value == ''){
		  	alert("Field 'Surname' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('city').value == ''){
		  	alert("Field 'City' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('zip').value == ''){
		  	alert("Field 'ZIP/Postal code' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  document.getElementById('registerForm').submit();
}

function testRegisterAltUpdate(){  
		  if(document.getElementById('nameAlt').value == ''){
		  	alert("Field 'Name' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  /*
		  if(document.getElementBydId('phoneAlt').value == ''){
		  	alert("Field 'Phone' is empty. Please fill in the appropiate information.");
			return false;
		  }*/
		  if(document.getElementById('surnameAlt').value == ''){
		  	alert("Field 'Surname' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('cityAlt').value == ''){
		  	alert("Field 'City' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('zipAlt').value == ''){
		  	alert("Field 'ZIP/Postal code' is empty. Please fill in the appropiate information.");
			return false;
		  }
		document.getElementById('registerFormAlt').submit();  
}

function testProfileUpdate(type){
 switch(type){
  default:
	return false;
  case "nameandcompany":
	if(document.getElementById('name').value == ''){
	 alert("Field 'Name' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('phoneNo').value == ''){
	 alert("Field 'Phone' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('surname').value == ''){
	 alert("Field 'Surname' is empty. Please fill in the appropiate information.");
	 return false;
	}
	break;
  case "billing":
	if(document.getElementById('city').value == ''){
	 alert("Field 'City' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('zip').value == ''){
	 alert("Field 'ZIP/Postal code' is empty. Please fill in the appropiate information.");
	 return false;
	}
	break;
  case "email":
    var emailRegEx = /^([a-zA-Z0-9])([a-zA-Z0-9\._-])*@(([a-zA-Z0-9\-])+(\.))+([a-zA-Z]{2,4})+$/ ;
	 if(document.getElementById('email').value.search(emailRegEx) == -1){
	 	alert("Please note that the new email address you entered is invalid. Please enter a proper email address. Thank you.");
		return false;
	 }
	 break;
  case "shipping":
	if(document.getElementById('name').value == ''){
	 alert("Field 'Name' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('phoneNo').value == ''){
	 alert("Field 'Phone' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('surname').value == ''){
	 alert("Field 'Surname' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('city').value == ''){
	 alert("Field 'City' is empty. Please fill in the appropiate information.");
	 return false;
	}
	if(document.getElementById('zip').value == ''){
	 alert("Field 'ZIP/Postal code' is empty. Please fill in the appropiate information.");
	 return false;
	}
	break;
  case "password":
	if( document.getElementById('passwd').value.length < 6){
	 alert('Password should be at least 6 chars long!');
	 return false;
	}
	if(document.getElementById('passwd').value != document.getElementById('passwd2').value){
	 alert('Please enter your password of choice below. Then, retype it in the field below to confirm the correct spelling.');
	 return false;
	}
	break;
 }
 return true;
}

function testRegisterUpdate(){
		  if( document.getElementById('passwd').value.length < 6 && document.getElementById('passwd').value.length > 0){
					 alert('Password should be at least 6 chars long!');
					 return false;
			  if(
									document.getElementById('passwd').value == document.getElementById('passwd2').value 
				 ){
			  }else{
						 alert('Please enter your password of choice below. Then, retype it in the field below to confirm the correct spelling.');
						 return false;
			  }
			}
		  if(document.getElementById('name').value == ''){
		  	alert("Field 'Name' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('phoneNo').value == ''){
		  	alert("Field 'Phone' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('surname').value == ''){
		  	alert("Field 'Surname' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('city').value == ''){
		  	alert("Field 'City' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  if(document.getElementById('zip').value == ''){
		  	alert("Field 'ZIP/Postal code' is empty. Please fill in the appropiate information.");
			return false;
		  }
		  document.getElementById('registerForm').submit();
}

function changeFedexRate(){
	form = document.getElementById('fselect');
	document.getElementById('fname').value = form.options[form.options.selectedIndex].text;
	document.getElementById('rates').submit();
}

