// jampadMaster.js

//document.onkeypress = processFormSubmition;
var sendingFormName;

function setFormName(formName)
{
	if (formName == "LoginFormOn")
	{
		sendingFormName = formName;
		//alert("sendingFormName = " + sendingFormName);
		
	}
	else (formName == "")
	{
		sendingFormName = formName;
		//alert("sendingFormName = " + sendingFormName);
		
	}
	
		
}

document.onkeypress = processSubmit;

function processSubmit(e)
{
  if (null == e)
    	e = window.event ;
  
  if ((e.keyCode == 13) && (sendingFormName == "performQuote"))
  {
   		editQuoteForm() ;
  }
  else if ((e.keyCode == 13) && (sendingFormName == "BecomeMbrFormOn"))
  {
       editNewMbrApplication();
 }
  else if ((e.keyCode == 13) && (sendingFormName == "LoginFormOn"))
  {
    	editLoginForm() ;
  }
  else if ((e.keyCode == 13) && (sendingFormName == "EmailFormOn"))
  {
    	editEmailForm() ;
  }
}

function checkEmail(email)
{
		var at="@";
		var dot=".";
		var lat=email.indexOf(at);
		var lstr=email.length;
		var ldot=email.indexOf(dot);
		var a; 
		
		if (
			(email.indexOf(at)==-1) ||
			(email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lstr) ||
			(email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lstr) ||
			(email.indexOf(at,(lat+1))!=-1) ||
			(email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot) ||
			(email.indexOf(dot,(lat+2))==-1) ||
			(email.indexOf(" ")!=-1)
			)
		{
			a = "bad";
			return a;
		}
		
}

function toggleDiv(id,flagit) {
	if (flagit=="1"){
	if (document.layers) document.layers[''+id+''].visibility = "show"
	else if (document.all) document.all[''+id+''].style.visibility = "visible"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
	}
	else
	if (flagit=="0"){
	if (document.layers) document.layers[''+id+''].visibility = "hide"
	else if (document.all) document.all[''+id+''].style.visibility = "hidden"
	else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
}



function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


