function AddToWishlist(artist,part){
	if(!InWishlist(artist,part)){
		setCookie("wishlist",getCookie("wishlist")+artist+","+part+";",7);
	}
	document.getElementById('add').innerHTML="Remove from Wishlist";
	document.getElementById('add').href="javascript:RemoveFromWishlist('"+artist+"','"+part+"');";
}
function RemoveFromWishlist(artist,part){
	if(InWishlist(artist,part)){
		var search=artist+","+part+";",cookie=getCookie("wishlist");
		setCookie("wishlist",getCookie("wishlist").replace(artist+","+part+";",""),7);
	}
	document.getElementById('add').innerHTML="Add to Wishlist";
	document.getElementById('add').href="javascript:AddToWishlist('"+artist+"','"+part+"');";
}
function RemoveItem(artist,part){
	if(InWishlist(artist,part)){
		var search=artist+","+part+";",cookie=getCookie("wishlist");
		setCookie("wishlist",getCookie("wishlist").replace(artist+","+part+";",""),7);
		location.reload();
	}
}
function InWishlist(artist,part){
	var cookie=getCookie("wishlist");
	if(cookie=="")return false;
	return cookie.indexOf(artist+","+part)>=0;
}
function setCookie(c_name,value,expiredays){
	var date=new Date();
	date.setDate(date.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+date.toGMTString());
}
function getCookie(c_name){
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
function deleteCookie(c_name){
	var date=new Date();
	date.setDate(date.getDate()-1);
	document.cookie=c_name+ "=deleting;expires="+date.toGMTString();
}
function SwitchContact(contact){
	if(contact.options[contact.selectedIndex].value=="Phone"){
		document.getElementById('phone').innerHTML="Phone:*";
		document.getElementById('email').innerHTML="E-mail:";
	}
	else {
		document.getElementById('phone').innerHTML="Phone:";
		document.getElementById('email').innerHTML="E-mail:*";
	}
}
function Validate(){
	var error=false;
	document.getElementById('missing').innerHTML="Missing Required Items";
	if(document.submitform.Name.value==""){
		document.getElementById('name').style.color="#BB0000";
		error=true;
	}
	else document.getElementById('name').style.color="#000000";
	if(document.submitform.Phone.value==""&&document.getElementById('contact').options[document.getElementById('contact').selectedIndex].value=="Phone"){
		document.getElementById('phone').style.color="#BB0000";
		document.getElementById('email').style.color="#000000";
		error=true;
	}
	else if(!ValidateEmail(document.submitform.Email.value)&&document.getElementById('contact').options[document.getElementById('contact').selectedIndex].value=="Email"){
		document.getElementById('email').style.color="#BB0000";
		document.getElementById('phone').style.color="#000000";
		if(!error)document.getElementById('missing').innerHTML="Invalid Email";
		error=true;
	}
	else {
		document.getElementById('phone').style.color="#000000";
		document.getElementById('email').style.color="#000000";
	}
	if(error)document.getElementById('missing').style.visibility="visible";
	else {
		document.getElementById('missing').style.visibility="hidden";
		document.submitform.submit();
	}
}
function ValidateEmail(email){
	var at=email.indexOf("@"),dot=email.lastIndexOf(".");
	if(at<1||dot<2)return false;
	if(at>=dot)return false;
	return true;
}
