function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function login_check()
{
	if (document.loginfrm.cn.value.length == 0)
	{
		alert ("Please input your username");
		document.loginfrm.cn.focus();
		return false;
	}
	else if (document.loginfrm.userpassword.value.length == 0)
	{
		alert("Please input your password");
		document.loginfrm.userpassword.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function recipe_check()
{
	if (document.recipefrm.recipetext.value.length == 0)
	{
		alert ("No keyword is entered. No recipe will be searched");
		return false;
	}
	else
	{
		return true;
	}
}

function ROD_reg(choice)
{
	if(choice==1){
		window.open('/join_us.asp','','width=600, height=450, scrollbars=yes');
	}
	else{
		window.open('/login_redirect.asp?lang=e','','width=380, height=250');
	}
}

function regfrm()
{
	window.open('/memberupd_e.asp?ROD=4#ROD','','width=600, height=450, scrollbars=yes')
}
	


function DirectPage(){
var thisurl = new String(window.location.href);
thisurl.toLowerCase;
var thisurl = new String(thisurl.substr(thisurl.lastIndexOf("/")+1));
var pos = thisurl.indexOf("_c.asp");
if (pos != -1 ) {
	/* it's chinese web page */
//	var newurl = new String(thisurl.substr(0,pos)+".asp");
	var newurl = thisurl.replace('_c.asp','.asp')

}
else {
	pos = thisurl.indexOf(".");
//	var newurl= new String(thisurl.substr(0,pos)+"_c.asp");
	var newurl = thisurl.replace('.asp','_c.asp')

}	
window.location.href = newurl;
}

 function search_criteria(index)
 {
	switch (index){
		case 1:
			if (document.criteria.sauceid.selectedIndex > 0)
			{				
				document.criteria.ingid.options[0].selected=1
				document.criteria.cookid.options[0].selected=1
				document.criteria.choice.value=1
			}
			break;
		case 2:
			if (document.criteria.ingid.selectedIndex > 0)
			{				
				document.criteria.sauceid.options[0].selected=1
				document.criteria.cookid.options[0].selected=1
				document.criteria.choice.value=2
			}
			break;
		case 3:
			if (document.criteria.cookid.selectedIndex > 0)
			{				
				document.criteria.sauceid.options[0].selected=1
				document.criteria.ingid.options[0].selected=1
				document.criteria.choice.value=3
			}
			break;
		default:;
	}
}

function check_recipe_frm()
{
	prod=document.criteria.sauceid.value
	ing=document.criteria.ingid.value
	cookval=document.criteria.cookid.value
	
	//alert(prod+","+ing+","+cookval);
	if((prod=="" && ing=="" && cookval=="") && document.criteria.veg[0].checked==1)
	{
		
		document.criteria.choice.value=10;
		return true;
	}
	
	if((prod==0 && ing==0 && cookval==0) || document.criteria.choice.value.length==0)
	//if((prod==0 && ing==0 && cookval==0) || document.criteria.choice.value==0)
	{
		alert("Please choose the criteria to search recipe.");
		return false;
	}
	else
	{
		
		return true;
	}
}

function recipe_frm_reset()
{
	document.criteria.reset();
}
