function totalCost()
{

var totCost = 0;
var tutorial=0;
var tutorialPrice = 0;
var tutorialDiscount = 0;
var tutCost= 0;
var eventType = "";

for( i = 0; i < document.casos_register.eventReg.length; i++ )
{
		if( document.casos_register.eventReg[i].checked == true )
		{
		eventType = document.casos_register.eventReg[i].value;
		break;
		}
}

for (var i=0; i < document.casos_register.member.length; i++)
   {
   if (document.casos_register.member[i].checked)
      {
      var member = document.casos_register.member[i].value;
      }
   }
   
   
for (var i=0; i < document.casos_register.group1.length; i++)
   {
   if (document.casos_register.group1[i].checked)
      {
      var group1 = document.casos_register.group1[i].value;
      }
   }
    
for (var i=0; i < document.casos_register.group2.length; i++)
   {
   if (document.casos_register.group2[i].checked)
      {
      var group2 = document.casos_register.group2[i].value;
      }
   }
   
for (var i=0; i < document.casos_register.group3.length; i++)
   {
   if (document.casos_register.group3[i].checked)
      {
      var group3 = document.casos_register.group3[i].value;
      }
   }
        
for (var i=0; i < document.casos_register.memberType.length; i++)
   {
   if (document.casos_register.memberType[i].checked)
      {
      var memberType = document.casos_register.memberType[i].value;
      }
   }

if(member == "current")
	{
		switch(memberType)
		{
		case 'faculty':

		
			totCost = 175;
		
			tutorialPrice = 100;
			tutorialDiscount = 50;
			break
		
		case 'student':
		
			totCost = 100;
		
			tutorialPrice = 80;
			tutorialDiscount = 45;
			break
		case 'other':
			totCost = 250;
			tutorialPrice = 150;
			tutorialDiscount = 100;
			break	
		}
	}
	else
	
	{
		switch(memberType)
		{
		case 'faculty':
			totCost = 275;
			tutorialPrice = 100;
			tutorialDiscount = 50;
			break
		
		case 'student':
			totCost = 150;
			tutorialPrice = 80;
			tutorialDiscount = 45;
			break
		case 'other':
			totCost = 350;
			tutorialPrice = 150;
			tutorialDiscount = 100;
			break	
		}
	}
if(group1 != "not interested")
{
	tutorial = tutorial + 1;
}

	if(group2 != "not interested")
	{
		tutorial = tutorial + 1;
	}

	if(group3 != "not interested")
	{
		tutorial = tutorial + 1;
	}


	if(tutorial > 1)
	{
		tutCost = (tutorialPrice + (tutorialDiscount *(tutorial - 1)));
		confCost = totCost;
		totCost = totCost + tutCost;
	}
	else
	{	
		tutCost = (tutorialPrice * tutorial);
		confCost = totCost;
		totCost = totCost + tutCost;
	}

	switch(eventType)
	{
		case 'cws':
			document.casos_register.totCost.value = totCost;
			document.casos_register.tutCost.value = tutCost;
			document.getElementById("cost").innerHTML = "$" + totCost.toString() + ".00";
			break
		case 'ws':
			document.casos_register.totCost.value = tutCost;
			document.casos_register.tutCost.value = tutCost;
			document.getElementById("cost").innerHTML = "$" + tutCost.toString() + ".00";
			break
		case 'c':
			document.casos_register.totCost.value = totCost;
			document.casos_register.tutCost.value = 0.00;
			document.getElementById("cost").innerHTML = "$" + totCost.toString() + ".00";
			break
	}
}

function activateGroup()
{
	var eventType="";
	
	for( i = 0; i < document.casos_register.eventReg.length; i++ )
	{
			if( document.casos_register.eventReg[i].checked == true )
			{
			eventType = document.casos_register.eventReg[i].value;
			break;
			}
	}
	
	alert(eventType);
	if(eventType != "c")
	{
		for(i=0;i< document.casos_register.eventReg.length;i++)
		{
		document.casos_register.group1[i].disabled = true
		document.casos_register.group2[i].disabled = true
		document.casos_register.group3[i].disabled = true
		}
	}
	else
	{
		for(i=0;i< document.casos_register.eventReg.length;i++)
		{
		document.casos_register.group1[i].disabled = true
		document.casos_register.group2[i].disabled = true
		document.casos_register.group3[i].disabled = true
		}
}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function isValid(){
	var emailID=document.form1.emailAddress	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	 document.form1.submit();
 }