// JavaScript Document

function roll_over(img_name, img_src)
{
	document[img_name].src = img_src;
}


function popup(url,windowname,w,h)
{
	window.open(url,windowname,"resizable=no,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width="+w+",height="+h+"");
}


function popupNew(url,w,h)
{
	window.open(url,'_blank','width=840,height=650,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
}


function popupCenter(url,windowname,w,h) 
{
	leftPos = 0
	topPos = 0
	if (screen) 
	{
		leftPos = (screen.width / 2) - 350
		topPos = (screen.height / 2) - 600
	}
	window.open(url,windowname,"resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width="+w+",height="+h+",left="+leftPos+",top="+topPos+"");
}


function cal()
{
	if( document.test.father.value.length == 0 )
	{
		window.alert("Please enter your father's height!");
		return false;
	}
	if( document.test.mother.value.length == 0 )
	{
		window.alert("Please enter your mother's height!");
		return false;
	}
	
	var father = parseFloat(document.test.father.value);
	var mother = parseFloat(document.test.mother.value);
	var height = 0;
	
	if( isNaN(father))
	{
		window.alert("Please enter your father's height in number!");
		return false;
	}
	
	if( isNaN(mother))
	{
		window.alert("Please enter your mother's height in number!");
		return false;
	}
	
	if(document.test.gender[0].checked ==true)
	{
		height = ((father+mother)/2 )*1.08;
		document.test.height.value = height;
	}
	else if(document.test.gender[1].checked ==true)
	{
		height = ((father*0.96) + (mother*1.08) )/2 ;
		document.test.height.value =height.toFixed(2);
	}
	else
	{
		window.alert("Please select your gender!");
	}
}


function CheckBrochureRequestForm()
{
	var name_lgt = document.BrochureRequestForm.name.value.length;
	var email_lgt = document.BrochureRequestForm.email.value.length;
	
	if(name_lgt==0)
	{
		window.alert("Please kindly fill in Name.");
		return false
	}
	
	if(email_lgt==0)
	{
		window.alert("Please kindly fill in your email.");
		return false
	}

	if(email_lgt != 0 )
	{
		if(document.BrochureRequestForm.email.value.indexOf("@")==-1 || document.BrochureRequestForm.email.value.indexOf("@")==0 || document.BrochureRequestForm.email.value.indexOf("@")+1== document.BrochureRequestForm.email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
}


function CheckSignUpForm()
{
	var name_lgt = document.SignUpForm.name.value.length;
	var age_lgt = document.SignUpForm.age.value.length;
	var height_lgt = document.SignUpForm.height.value.length;
	var contact_lgt = document.SignUpForm.contact.value.length;
	var email_lgt = document.SignUpForm.email.value.length;
	
	if(name_lgt==0)
	{
		window.alert("Please kindly fill in Name.");
		return false
	}
	
	if(age_lgt==0)
	{
		window.alert("Please kindly fill in Age.");
		return false
	}
	
	if(height_lgt==0)
	{
		window.alert("Please kindly fill in Height.");
		return false
	}
	
	if(contact_lgt==0)
	{
		window.alert("Please kindly fill in Contact.");
		return false
	}
	
	if(email_lgt==0)
	{
		window.alert("Please kindly fill in your email.");
		return false
	}

	if(email_lgt != 0 )
	{
		if(document.SignUpForm.email.value.indexOf("@")==-1 || document.SignUpForm.email.value.indexOf("@")==0 || document.SignUpForm.email.value.indexOf("@")+1== document.SignUpForm.email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
}


function CheckStoryForm()
{
	var name_lgt = document.StoryForm.name.value.length;
	var age_lgt = document.StoryForm.age.value.length;
	var occupation_lgt = document.StoryForm.occupation.value.length;
	var email_lgt = document.StoryForm.email.value.length;
	var city_lgt = document.StoryForm.city.value.length;
	var type_lgt = document.StoryForm.type.selectedIndex;
	var message_lgt = document.StoryForm.message.value.length;
	
	if(name_lgt==0)
	{
		window.alert("Please kindly fill in Name.");
		return false
	}
	
	if(age_lgt==0)
	{
		window.alert("Please kindly fill in Age.");
		return false
	}
	
	if(occupation_lgt==0)
	{
		window.alert("Please kindly fill in Occupation.");
		return false
	}
	
	if(email_lgt==0)
	{
		window.alert("Please kindly fill in your email.");
		return false
	}

	if(email_lgt != 0 )
	{
		if(document.StoryForm.email.value.indexOf("@")==-1 || document.StoryForm.email.value.indexOf("@")==0 || document.StoryForm.email.value.indexOf("@")+1== document.StoryForm.email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
	
	if(city_lgt==0)
	{
		window.alert("Please kindly fill in City.");
		return false
	}
	
	if(type_lgt==0)
	{
		window.alert("Please kindly fill in Type.");
		return false
	}
	
	if(message_lgt==0)
	{
		window.alert("Please kindly fill in Message.");
		return false
	}
}


function CheckReturnsForm()
{
	var firstname_lgt = document.RetunsForm.firstname.value.length;
	var lastname_lgt = document.RetunsForm.lastname.value.length;
	var address_lgt = document.RetunsForm.address.value.length;
	var city_lgt = document.RetunsForm.city.value.length;
	var state_lgt = document.RetunsForm.state.value.length;
	var zipcode_lgt = document.RetunsForm.zipcode.value.length;
	var contact_lgt = document.RetunsForm.contact.value.length;
	var country_lgt = document.RetunsForm.country.selectedIndex;
	var email_lgt = document.RetunsForm.email.value.length;
	var comments_lgt = document.RetunsForm.comments.value.length;
	var paymentid_lgt = document.RetunsForm.paymentid.value.length;
	var purpose_lgt = document.RetunsForm.purpose.selectedIndex;
	var items_lgt = document.RetunsForm.items.value.length;
	var replaceitems_lgt = document.RetunsForm.replaceitems.value.length;
	var agree_lgt = document.RetunsForm.agree.checked;
	
	if(firstname_lgt==0)
	{
		window.alert("Please kindly fill in First Name.");
		return false
	}
	
	if(lastname_lgt==0)
	{
		window.alert("Please kindly fill in Last Name.");
		return false
	}
	
	if(address_lgt==0)
	{
		window.alert("Please kindly fill in Address.");
		return false
	}
	
	if(city_lgt==0)
	{
		window.alert("Please kindly fill in City.");
		return false
	}
	
	if(state_lgt==0)
	{
		window.alert("Please kindly fill in State.");
		return false
	}
	
	if(zipcode_lgt==0)
	{
		window.alert("Please kindly fill in Zip Code.");
		return false
	}
	
	if(contact_lgt==0)
	{
		window.alert("Please kindly fill in Contact.");
		return false
	}
	
	if (country_lgt==0 )
    {
        window.alert("Please select your Country.");
		return false
    }
	
	if(email_lgt==0)
	{
		window.alert("Please kindly fill in your Email Address.");
		return false
	}

	if(email_lgt != 0 )
	{
		if(document.RetunsForm.email.value.indexOf("@")==-1 || document.RetunsForm.email.value.indexOf("@")==0 || document.RetunsForm.email.value.indexOf("@")+1== document.RetunsForm.email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
	
	if(comments_lgt==0)
	{
		window.alert("Please kindly fill in Comments or instruction about your order / return.");
		return false
	}
	
	if(paymentid_lgt==0)
	{
		window.alert("Please kindly fill in Payment ID.");
		return false
	}
	
	if(purpose_lgt==0)
	{
		window.alert("Please select your PURPOSE OF RETURN.");
		return false
	}
	
	if(items_lgt==0)
	{
		window.alert("Please kindly fill in Item(s) you are trying to return.");
		return false
	}
	
	if(replaceitems_lgt==0)
	{
		window.alert("Please kindly fill in item(s) you are trying to get replace.");
		return false
	}
	
	if(agree_lgt==false)
	{
		window.alert("You have not read throught the return policy and agree with it.");
		return false
	}
}


function CheckSendToFriendForm()
{
	var recipient_lgt = document.SendToFriendForm.recipient.value.length;
	var sender_lgt = document.SendToFriendForm.sender.value.length;
	var recipient_email_lgt = document.SendToFriendForm.recipient_email.value.length;
	var sender_email_lgt = document.SendToFriendForm.sender_email.value.length;
	
	if(recipient_lgt==0)
	{
		window.alert("Please kindly fill in Recipient Name.");
		return false
	}
	
	if(sender_lgt==0)
	{
		window.alert("Please kindly fill in your Name.");
		return false
	}
	
	if(recipient_email_lgt==0)
	{
		window.alert("Please kindly fill in Recipient Email.");
		return false
	}

	if(recipient_email_lgt != 0 )
	{
		if(document.SendToFriendForm.recipient_email.value.indexOf("@")==-1 || document.SendToFriendForm.recipient_email.value.indexOf("@")==0 || document.SendToFriendForm.recipient_email.value.indexOf("@")+1== document.SendToFriendForm.recipient_email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
	
	if(sender_email_lgt==0)
	{
		window.alert("Please kindly fill in your Email.");
		return false
	}

	if(sender_email_lgt != 0 )
	{
		if(document.SendToFriendForm.sender_email.value.indexOf("@")==-1 || document.SendToFriendForm.sender_email.value.indexOf("@")==0 || document.SendToFriendForm.sender_email.value.indexOf("@")+1== document.SendToFriendForm.sender_email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
}


function CheckCheckoutForm()
{
	var name_lgt = document.CheckoutForm.name.value.length;
	var email_lgt = document.CheckoutForm.email.value.length;
	var hp_lgt = document.CheckoutForm.hp.value.length;
	var street_lgt = document.CheckoutForm.street.value.length;
	var postcode_lgt = document.CheckoutForm.postcode.value.length;
	var city_lgt = document.CheckoutForm.city.value.length;
	var state_lgt = document.CheckoutForm.state.value.length;
	var country_lgt = document.CheckoutForm.country.selectedIndex;
	
	
	if(name_lgt==0)
	{
		window.alert("Please kindly fill in your Name.");
		return false
	}
	
	if(email_lgt==0)
	{
		window.alert("Please kindly fill in your Email.");
		return false
	}

	if(email_lgt != 0 )
	{
		if(document.CheckoutForm.email.value.indexOf("@")==-1 || document.CheckoutForm.email.value.indexOf("@")==0 || document.CheckoutForm.email.value.indexOf("@")+1== document.CheckoutForm.email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;
		}
	}
	
	if(hp_lgt==0)
	{
		window.alert("Please kindly fill in your Mobile Phone No.");
		return false
	}
	
	
	if(street_lgt==0)
	{
		window.alert("Please kindly fill in your Street.");
		return false
	}
	
	if(postcode_lgt==0)
	{
		window.alert("Please kindly fill in your Postcode.");
		return false
	}
	
	if(city_lgt==0)
	{
		window.alert("Please kindly fill in your City.");
		return false
	}
	
	if(state_lgt==0)
	{
		window.alert("Please kindly fill in your State.");
		return false
	}
	
	if (country_lgt==0 )
    {
        window.alert("Please select your Country.");
		return false
    }
	return true;
}


function CheckEnquiryForm()
{
	var name_lgt = document.EnquiryForm.name.value.length;
	var contact_lgt = document.EnquiryForm.contact.value.length;
	var email_lgt = document.EnquiryForm.email.value.length;
	var enquiry_lgt = document.EnquiryForm.enquiry.value.length;
	
	if(name_lgt==0)
	{
		window.alert("Please kindly fill in your Name.");
		return false;
	}
	
	if(contact_lgt==0)
	{
		window.alert("Please kindly fill in your Contact Number.");
		return false;
	}
	
	if(email_lgt==0)
	{
		window.alert("Please kindly fill in your email.");
		return false;
	}

	if(email_lgt != 0 )
	{
		if(document.EnquiryForm.email.value.indexOf("@")==-1 || document.EnquiryForm.email.value.indexOf("@")==0 || document.EnquiryForm.email.value.indexOf("@")+1== document.EnquiryForm.email.value.length)
		{
			window.alert("Invalid email. Please kindly fill in a valid email.");
			return false;

		}
	}
	
	if(enquiry_lgt==0)
	{
		window.alert("Please describe your interest in our products.");
		return false;
	}
}


var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

