// JavaScript Document
// for checking valid email;
var email = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 




// step 1
function step1()
{
	if($('agree').checked != true)
	{
		alert('You have not Agreed to the Rules');
		return false
	}
	else
		return true
}




function check_bands()
{
	check_band()
	if($("usernames").value == "")
		{
			alert("Enter Username / Bands First");
			$("usernames").focus();
			return false;
		}			
		else
			
			return true;
}

// step 2
var check_bns = 0;
function check_band()
{
	var bn = $("usernames").value
	params = "bn="+bn+"&sid="+Math.random();
	//alert(params)
	new Ajax.Request('steps/call_band.php',{ method:'get', parameters:params, onComplete:call_band });
}



function call_band(originalRequest)
{
	var res = originalRequest.responseText
	//alert(res)
	if (res == 1)
	{
		$('check_bn').innerHTML = "<font color ='red'><strong>Username / Band Name already exits</strong></font>";
		//check_bns = 1;
		document.getElementById("check_bnss").value = "1";
		$("l_username").style.backgroundColor="#00CCFF";
	}
	if (res == 2 )
	{
		u = $("usernames").value
		$('check_bn').innerHTML = "<font color ='green'><strong>Quick URL: www.createaconcert.com/"+u+"</strong></font>";
		document.getElementById("check_bnss").value = "2";
		$("l_username").style.backgroundColor="";
		//check_bns = 2
		
	}
	if (res == 3 )
	{
		$('check_bn').innerHTML = "<font color ='red'><strong>No Spaces In Band Name</strong></font>";
		//check_bns = 1;
		document.getElementById("check_bnss").value = "1";
		$("l_username").style.backgroundColor="#00CCFF";
	}
	
	
	
}





var c_e= 0;
function check_email()
{
	var email = $("email").value
	params = "email="+email+"&sid="+Math.random();
	//alert(params)
	new Ajax.Request('steps/call_email.php',{ method:'get', parameters:params, onComplete:call_email });
}



function call_email(originalRequest)
{
	var res = originalRequest.responseText
	if (res == 0 )
	{
		$('c_email').innerHTML = "<font color ='red'><strong>Email already exits</strong></font>";
		$("l_email").style.backgroundColor="#00CCFF";
		c_e =0
	}
	if (res == 1 )
	{
		$('c_email').innerHTML = "";
		c_e = 1;
		$("l_email").style.backgroundColor="";
	}
}




// step 2
function step2()
{
	var check = $("check_bnss").value;
	var e = c_e
	var chk = document.getElementById('agree').checked;
		//alert(check)
		if($("email").value == "" || (!email.test($("email").value)))
		{
			//$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="#00CCFF";
			//$("l_c_email").style.backgroundColor="";
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("email").focus();
			return false;
		}	
			
		else if($("passwords").value == "")
		{
			//$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="#00CCFF";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="";
			//$("l_c_email").style.backgroundColor="";
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("passwords").focus();
			return false;
		}
		else if($("c_passwords").value == "")
		{
			//$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="#00CCFF";
			$("l_email").style.backgroundColor="";
			//$("l_c_email").style.backgroundColor="";
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("c_passwords").focus();
			return false;
		}
		else if($("c_passwords").value != $("passwords").value )
		{
			//$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="#00CCFF";
			$("l_c_password").style.backgroundColor="#00CCFF";
			$("l_email").style.backgroundColor="";				
			//$("l_c_email").style.backgroundColor="";				
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("passwords").focus();
			return false;
		}
		else if($("usernames").value == "" || (check == 0))
		{
			alert('username')
			//$("l_username").style.backgroundColor="#00CCFF";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="";
			//$("l_c_email").style.backgroundColor="";
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("usernames").focus();
			return false;
		}		
		/*else if($("c_email").value == "" || (!email.test($("c_email").value)))
		{
			$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="";				
			$("l_c_email").style.backgroundColor="#00CCFF";				
			$("l_capta").style.backgroundColor="";							
			$("c_email").focus();
			return false;
		}	
		else if($("c_email").value != $("c_email").value )
		{
			$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="#00CCFF";				
			$("l_c_email").style.backgroundColor="#00CCFF";				
			$("l_capta").style.backgroundColor="";							
			$("c_email").focus();
			return false;
		}	
		else if($("capta").value == "")
		{
			$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="";				
			$("l_c_email").style.backgroundColor="";				
			$("l_capta").style.backgroundColor="#00CCFF";							
			$("capta").focus();
			return false;
		}*/
		else if(check == 1 || check == 3)
		{
			//$("l_username").style.backgroundColor="#00CCFF";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="";				
			//$("l_c_email").style.backgroundColor="";				
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("usernames").focus();
			return false;
		}	
		else if(e == 0)
		{
			//$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="#00CCFF";				
			//$("l_c_email").style.backgroundColor="";				
			//$("l_capta").style.backgroundColor="";
			$("l_chk").style.backgroundColor="";
			$("email").focus();
			return false;
		}	
		
		else if(chk == false)
		{
			//$("l_username").style.backgroundColor="";
			$("l_password").style.backgroundColor="";
			$("l_c_password").style.backgroundColor="";
			$("l_email").style.backgroundColor="";
			$("l_chk").style.backgroundColor="#00CCFF";
			document.getElementById('agree').focus();
			return false;
		}	
		else
		{
			return true;
		}
}





// step 4
function step4()
{
	if($("cmbGN").value == "")
	{
		$("gn").style.backgroundColor="#00CCFF";
		$("b1").style.backgroundColor="";
		$("b2").style.backgroundColor="";
		$("b3").style.backgroundColor="";						
		$("cmbGN").focus();
		return false;
	}			
	else if($("band1").value == "")
	{
		$("b1").style.backgroundColor="#00CCFF";
		$("gn").style.backgroundColor="";
		$("b2").style.backgroundColor="";
		$("b3").style.backgroundColor="";						
		$("band1").focus();
		return false;
	}
	else if($("band2").value == "")
	{
		$("b2").style.backgroundColor="#00CCFF";
		$("gn").style.backgroundColor="";
		$("b1").style.backgroundColor="";
		$("b3").style.backgroundColor="";						
		$("band2").focus();
		return false;
	}
	else if($("band3").value == "")
	{
		$("b3").style.backgroundColor="#00CCFF";
		$("gn").style.backgroundColor="";
		$("b1").style.backgroundColor="";
		$("b2").style.backgroundColor="";						
		$("band3").focus();
		return false;
	}			
	else
	{
		return true;
	}
}


// step 5
function step5()
{
	if($("genre").value == "")
	{
		$("gn").style.backgroundColor="#00CCFF";
		$("st").style.backgroundColor="";
		$("ct").style.backgroundColor="";					
		$("genre").focus();
		return false;
	}	
	if($("state").value == "")
	{
		$("ct").style.backgroundColor="";
		$("st").style.backgroundColor="#00CCFF";
		$("gn").style.backgroundColor="";
		$("state").focus();
		return false;
	}			
	else if($("city").value == "")
	{
		$("ct").style.backgroundColor="#00CCFF";
		$("st").style.backgroundColor="";
		$("gn").style.backgroundColor="";
		$("city").focus();
		return false;
	}
	else
	{
		return true;
	}
}

// step 6
function step6()
{
	if($("price_college").value == "")
	{				
		$("cprice").style.backgroundColor="#00CCFF";
		$("price_college").focus();
		return false;
	}
	else if( eval($("price_college").value) > 1200 )
	{
		$("cprice").style.backgroundColor="#00CCFF";
		alert("Amount exeeded the maximum value");
		$("price_college").focus();
		return false;
	}
	else
	{
		return true;	
	}		
}


// step 7
function step7()
{
	if($("price_frat").value == "0" || $("price_frat").value == "")
	{				
		$("ft").style.backgroundColor="#00CCFF";
		$("price_frat").focus();
		return false;
	}
	
	else if( eval($("price_frat").value) > 500 )
	{
		$("ft").style.backgroundColor="#00CCFF";
		alert("Amount exeeded the maximum value");
		$("price_frat").focus();
		return false;
	}
	else
	{
		return true;	
	}	
}
function showTr(divid, val)
{
	if(val == 1)
	{				
		$(divid).style.visibility="visible";
	}
	else if(val == 0)
	{
		$(divid).style.visibility="hidden";
	}
}


function showTr(divid, val)
{
	if(val == 1)
	{				
		$(divid).style.visibility="visible";
	}
	else if(val == 0)
	{
		$(divid).style.visibility="hidden";
	}
}



// step 8
function step8(id, id2)
{
	if($(id).style.visibility=="visible")	
	{
		if($("agent_name").value == "")
		{
			$("an").style.backgroundColor="#00CCFF";
			$("ap").style.backgroundColor="";
			$("ae").style.backgroundColor="";			
			$("ad1").style.backgroundColor="";
			$("ad2").style.backgroundColor="";
			$("ad3").style.backgroundColor="";
			$("agent_name").focus();
			return false;
		}
		else if($("agent_phone").value == "")
		{
			$("ap").style.backgroundColor="#00CCFF";
			$("an").style.backgroundColor="";
			$("ae").style.backgroundColor="";			
			$("ad1").style.backgroundColor="";
			$("ad2").style.backgroundColor="";
			$("ad3").style.backgroundColor="";
			$("agent_phone").focus();
			return false;
		}
		else if($("agent_email").value == "")
		{
			$("ae").style.backgroundColor="#00CCFF";
			$("an").style.backgroundColor="";
			$("ap").style.backgroundColor="";			
			$("ad1").style.backgroundColor="";
			$("ad2").style.backgroundColor="";
			$("ad3").style.backgroundColor="";
			$("agent_email").focus();
			return false;
		}		
		else if($("add1").value == "")
		{
			$("ad1").style.backgroundColor="#00CCFF";			
			$("ad2").style.backgroundColor="";
			$("ad3").style.backgroundColor="";
			$("an").style.backgroundColor="";
			$("ap").style.backgroundColor="";
			$("ae").style.backgroundColor="";				
			$("add1").focus();
			return false;
		}			
		/*else if($("txtAD2").value == "")
		{
			$("ad2").style.backgroundColor="#00CCFF";
			$("ad1").style.backgroundColor="";
			$("ad3").style.backgroundColor="";
			$("an").style.backgroundColor="";
			$("ap").style.backgroundColor="";
			$("ae").style.backgroundColor="";			
			$("txtAD2").focus();
			return false;
		}*/
		else if($("zip").value == "")
		{
			$("ad3").style.backgroundColor="#00CCFF";
			$("ad1").style.backgroundColor="";
			$("ad2").style.backgroundColor="";
			$("an").style.backgroundColor="";
			$("ap").style.backgroundColor="";
			$("ae").style.backgroundColor="";				
			$("zip").focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	else 
	{
		if($(id2).style.visibility=="visible")	
		{	
			if($("agent_name").value == "")
			{
				$("an").style.backgroundColor="#00CCFF";
				$("ap").style.backgroundColor="";
				$("ae").style.backgroundColor="";			
				$("ad1").style.backgroundColor="";
				$("ad2").style.backgroundColor="";
				$("ad3").style.backgroundColor="";
				$("agent_name").focus();
				return false;
			}
			else if($("agent_phone").value == "")
			{
				$("ap").style.backgroundColor="#00CCFF";
				$("an").style.backgroundColor="";
				$("ae").style.backgroundColor="";			
				$("ad1").style.backgroundColor="";
				$("ad2").style.backgroundColor="";
				$("ad3").style.backgroundColor="";
				$("agent_phone").focus();
				return false;
			}
			else if($("agent_email").value == "")
			{
				$("ae").style.backgroundColor="#00CCFF";
				$("an").style.backgroundColor="";
				$("ap").style.backgroundColor="";			
				$("ad1").style.backgroundColor="";
				$("ad2").style.backgroundColor="";
				$("ad3").style.backgroundColor="";
				$("agent_email").focus();
				return false;
			}	
			else 
				return true;
		}
	}
}


// step 10
function step10()
{
	/*if($("txtIMG").value == "")
	{
		$("img").style.backgroundColor="#00CCFF";
		$("bd").style.backgroundColor="";
		$("txtIMG").focus();
		return false;
	}			
	else */if($("BriefDesc").value == "")
	{
		$("bd").style.backgroundColor="#00CCFF";
		$("img").style.backgroundColor="";
		$("BriefDesc").focus();
		return false;
	}
	else
	{
		return true;
	}
}


function showForm2()
{
	//$('r_theFormDiv2').style.display='block';
	$('r_theFormDiv2').appear();
}
function hideForm2()
{
	//$('r_theFormDiv2').style.display='none';
	$('r_theFormDiv2').hide();
}





