function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}  

function submitform(url, actionval, categoryname, productid)
{
  document.form1.action          = url + ".php";
  document.form1.Action.value    = actionval;
  document.form1.CategoryName.value = categoryname;
  document.form1.ProductID.value = productid;
  document.form1.submit();
}

function AddToCart(actionval)
{
	// Validate input first

    // Need at least select one lens
    var leftQty = document.getElementById("left_qty");
    var rightQty = document.getElementById("right_qty");
    if (leftQty.value == 0 && rightQty.value == 0)
    {
        alert("Sorry, you haven't selected any lenses yet.");
        return;
    }
    
    // Validate left eye lenses
    if (leftQty.value > 0)
    {
	    ctl = "left_curve";
	    if ( !ValidateInput("left_curve", "Left Eye Base Curve") )
		    return;

	    ctl = "left_diameter";
	    if ( !ValidateInput("left_diameter", "Left Eye Diameter") )
		    return;	

	    ctl = "left_power";
	    if ( !ValidateInput("left_power", "Left Eye Power") )
		    return;	

	    ctl = "left_addpower";
	    if ( !ValidateInput("left_addpower", "Left Eye AddPower") )
		    return;	

	    ctl = "left_cylinder";
	    if ( !ValidateInput("left_cylinder", "Left Eye Cylinder") )
		    return;	

	    ctl = "left_axis";
	    if ( !ValidateInput("left_axis", "Left Eye Axis") )
		    return;	

	    ctl = "left_color";
	    if ( !ValidateInput("left_color", "Left Eye Color") )
		    return;	
    }

    // Validate left eye lenses
    if (rightQty.value > 0)
    {
	    ctl = "right_curve";
	    if ( !ValidateInput("right_curve", "Right Eye Base Curve") )
		    return;	


	    ctl = "right_diameter";
	    if ( !ValidateInput("right_diameter", "Right Eye Diameter") )
		    return;	


	    ctl = "right_power";
	    if ( !ValidateInput("right_power", "Right Eye Power") )
		    return;	


	    ctl = "right_addpower";
	    if ( !ValidateInput("right_addpower", "Right Eye AddPower") )
		    return;	


	    ctl = "right_cylinder";
	    if ( !ValidateInput("right_cylinder", "Right Eye Cylinder") )
		    return;	


	    ctl = "right_axis";
	    if ( !ValidateInput("right_axis", "Right Eye Axis") )
		    return;	


	    ctl = "right_color";
	    if ( !ValidateInput("right_color", "Right Eye Color") )
		    return;	
    }
	//
	document.form1.action = "";
	document.form1.Action.value    = actionval;
	document.form1.submit();		
}

function ValidateInput(obj, msg)
{
	// Validate input
	if (document.getElementById(obj) != null) 
	{
		if (document.form1.elements[obj].value == "NOTSELECTED")
		{
			alert("Please select " + msg + ".");
			return false;
		}
	}
	return true;	
}


function fav()
{
	var link = "http://www.lensnow.com";
	var title = "Lensnow.com - Contact Lenses"; 

	if(document.all)
    	window.external.AddFavorite(link,title);
}
function add_bookmark(){
   var url="http://www.lensnow.com";
   var title="Lensnow.com - Contact Lenses";

   if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
      if (confirm('Add contactlensesprice.com to your favorite?')){
         window.external.AddFavorite (url,title);
      }
   }
   else{
      var msg = "Sorry. The automatic creation of bookmarks does not work.";
      if (navigator.appName == "Netscape") msg += " (Press <CTRL+D>)";
      alert(msg);
   }
}

function add_bookmark(title){
   var url=top.document.location;
   if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)){
      if (confirm('Add '+url+' to your favorite?')){
         window.external.AddFavorite (url,title);
      }
   }
   else{
      var msg = "Sorry. The automatic creation of bookmarks does not work.";
      if (navigator.appName == "Netscape") msg += " (Press <CTRL+D>)";
      alert(msg);
   }
}
