function dohide(){
	var h= document.getElementById('choose');
	h.style.visibility="hidden";
	var h= document.getElementById('guest');
	h.style.visibility="hidden";
	var l= document.getElementById('letter');
	l.style.visibility="hidden";
}
function showecards(){
	var h= document.getElementById('choose');
	h.style.visibility="visible";
}
function showtahnkyou(){
	var h= document.getElementById('letter');
	h.style.visibility="visible";
}
function showguestbook(){
	var h= document.getElementById('guest');
	h.style.visibility="visible";
}
function launchMyWindow(site, w, h){
//alert('site = ' + site + ' w = ' + w + ' h = ' + h);
window.open(site,'','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=' + w + ', height=' + h + ', left=50, top=50');
}

function validateecard(){
	var root = document.ecard;
	var id = root.hid;
	var name = root.name;
	var email = root.email;
	var country = root.countries;
	var fname = root.fname;
	var femail = root.femail;
	var message = root.message;
	if(id.value==""){
		alert("Please select the card");
		this.focus();
		return false;
	}
	if(name.value==""){
		alert("Please enter your name");
		name.focus();
		return false;
	}
	if(email.value==""){
		alert("Please enter your email address");
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = email.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address");
		email.focus();
		return false;
	}
	if(country.value==""){
		alert("Please enter your country name");
		country.focus();
		return false;
	}
	if(fname.value==""){
		alert("Please enter your friend name");
		fname.focus();
		return false;
	}
	if(femail.value==""){
		alert("Please enter your friend email");
		femail.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var flag2 = femail.value.match(pattern);
	if(!flag2){
		alert("Please enter a valid email address for your freind");
		femail.focus();
		return false;
	}

	if(message.value==""){
		alert("Please enter the message content");
		message.focus();
		return false;
	}
}


function validateLogin(){
	var root = document.login;
	var name = root.name;
	var password = root.password;
	if(name.value==""){
		alert("Please enter your Username.");
		name.focus();
		return false;
	}
	if(password.value==""){
		alert("Please enter your Password.");
		password.focus();
		return false;
	}
	//	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	//	var flag2 = email.value.match(pattern);
	//	if(!flag2){
	//		alert("Please enter a valid email address");
	//		email.focus();
	//		return false;
	//	}
	return true;
}
function validateSearch(){
	var root = document.searchForm;
	var keyword = root.keyword;
	var category = root.category;
	var subcategory = root.subcategory;
	if(keyword.value==""){
		alert("Please provide a keyword.");
		keyword.focus();
		return false
	}
	if(category.value==""){
		alert("Please provide a category.");
		category.focus();
		return false
	}
	if(category.value==2){
		if(subcategory.value==""){
			alert("Please provide a subcategory.");
			subcategory.focus();
			return false
		}
	}
	return true;
}
////////////////////////////////////////////
//POP IMAGE JS FUNCTION
////////////////////////////////////////////

function popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 480;
	defaultHeight = 530;
	//alert(imageURL);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
			writeln('<img name="Image" src="'+imageURL+'" style="display:block"></body></html>');
			close();
		}
}

function emptyGuestbookForm(){
	var formElements = document.guestbook_form.elements;
	for(i=0;i<formElements.length;i++){
		formElements[i].value="";
	}
}
function checkGuestbookForm(){
	var root = document.guestbook_form;
	var name = root.name;
	var email = root.email;
	var country = root.countries[document.guestbook_form.countries.selectedIndex];
	var comment = root.comment;
	var vcode = root.vcode;
	if (name.value == "")
	{
		alert("Please enter your Name");
		name.focus();
		return false;
	}
	if (email.value == "")
	{
		alert("Please enter your email address");
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	var email_address = email.value.match(pattern);
	if(!email_address)
	{
		alert("Please enter a valid email address");
		email.focus();
		return false;
	}
	if(country.value == "")
	{
		alert("Please enter your country");
		country.focus();
		return false;
	}
	if(comment.value == "")
	{
		alert("Please enter a comment");
		comment.focus();
		return false;
	}
	if(vcode.value == "")
	{
		alert("Please enter the visual code");
		vcode.focus();
		return false;
	}
	return true;
}
