// JavaScript Document

function confirmDelete(sub, tit, ex) {

  var msg = "Are you sure you want to Delete " + sub + ": " + tit + " " + ex + " ?";
  if (confirm(msg)) {
      return true;
  } else {
      return false;
  }
}

function PrintThisRecipe(base_dir)
{ 
	   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
	         sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 
	   var winprint=window.open(base_dir+"print_page.htm","Print",sOption); 
	   winprint.focus(); 
}

function ValidateEmail(frm)
{
  var tmp = returnObjById('email');
	if(tmp && !isValidEmail(tmp.value))
	{
		alert(" Please enter a valid E-mail Address. ");
		frm.email.focus();
		return false;
	}
	
	return true; 
}

function ValidateLogin(frm)
{
  if (frm.username.value == '' || frm.username.value == 'username')
  {
    alert(" Please enter your user name. ");
    frm.username.focus();
    return false;
  }  

  if (frm.password.value == '')
  {
    alert(" Please enter your password. ");
    frm.password.focus();
    return false;
  }  
  
  return true;
}

function returnObjById( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id]; 
    return returnVar; 
} 

function get_radio_value(plan)
{
    var rad_val = 0;    
    for (var i=0; i < plan.length; i++)
    {
       if (plan[i].checked)
       {
          rad_val = plan[i].value;
       }
    }
    return rad_val;
}

function ValidatePlan(frm)
{
    var plan_id = get_radio_value(frm.plan);
    if (plan_id == 0)
    {
        alert("Please select from the above plans before continuing. ");
        return false;
    }
   
    return true;
}
