function toggleUserType() {
	
	var usertype = $('usertype').getValue();
	var coach = $('coach');
	var teamadmin = $('teamadmin');
	var player = $('player');
	var sales = $('sales');
	var superuser = $('superuser');
	
	switch(usertype) {
		
		case '1':
			superuser.show();
			coach.hide();
			teamadmin.hide();
			player.hide();
			sales.hide();
		break;
		case '2':
			superuser.hide();
			coach.hide();
			teamadmin.hide();
			player.hide();
			sales.show();		
		break;
		
		case '3':
			superuser.hide();
			coach.show();
			teamadmin.hide();
			player.hide();
			sales.hide();		
		break;
		
		case '4':
			superuser.hide();
			coach.hide();
			teamadmin.show();
			player.hide();
			sales.hide();	
		break;
		
		case '5':
			superuser.hide();
			coach.hide();
			teamadmin.hide();
			player.show();
			sales.hide();		
		break;
		
		case '6':
			superuser.hide();
			coach.hide();
			teamadmin.hide();
			player.show();
			sales.hide();
		break;
		
	}
	
}

function showTeamInfo() {
	
	var jr_team = $('current_team').getValue();
	
	if (jr_team.blank()) {
		$('athletic_infobox').hide();
		return false;
	}
	
	new Ajax.Request('ajax/front_ajax.php',
	{   	
		method: 'post',
		parameters: {action: 'getteaminfo',jrteam: jr_team},
		onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
         	m = json.message; 
         	$('athletic_infobox').show();
			$('athletic_infobox').update(m);

	  }
	  
	}); 		
	
}

function VerifyPlayerForm() {
	
	var formdata = $('playerform').serialize();
	

	new Ajax.Request('ajax/front_ajax.php',
	{   	
		onCreate:function() {
			$('signupbutton').href = 'javascript:void(0);';
		},
		method: 'post',
		parameters: formdata,
		onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
         	m = json.message; 

         	$('signupbutton').href = 'javascript:VerifyPlayerForm();';
         	
         	if (m == '') {
         		$('status').hide();
         	} else {
         		$('status').addClassName('failure').show();
         		$('status').show();
         		$('status').update(m);
         	}
         	 	
         	(json.first_name_error == '1') ? $('first_name').addClassName('fielderror').show() : $('first_name').removeClassName('fielderror').show();
         	(json.last_name_error == '1') ? $('last_name').addClassName('fielderror').show() : $('last_name').removeClassName('fielderror').show();
         	(json.birth_date_error == '1') ? $('birth_date').addClassName('fielderror').show() : $('birth_date').removeClassName('fielderror').show();
         	(json.address_error == '1') ? $('address').addClassName('fielderror').show() : $('address').removeClassName('fielderror').show();
         	(json.city_error == '1') ? $('city').addClassName('fielderror').show() : $('city').removeClassName('fielderror').show();
     	 	(json.state_province_error == '1') ? $('state_province').addClassName('fielderror').show() : $('state_province').removeClassName('fielderror').show();
     	 	(json.postal_code_error == '1') ? $('postal_code').addClassName('fielderror').show() : $('postal_code').removeClassName('fielderror').show();
     	 	(json.country_error == '1') ? $('country').addClassName('fielderror').show() : $('country').removeClassName('fielderror').show();
         	(json.email_error == '1') ? $('email').addClassName('fielderror').show() : $('email').removeClassName('fielderror').show();
         	(json.home_phone_areacode_error == '1') ? $('home_phone_areacode').addClassName('fielderror').show() : $('home_phone_areacode').removeClassName('fielderror').show();
        	(json.home_phone1_error == '1') ? $('home_phone1').addClassName('fielderror').show() : $('home_phone1').removeClassName('fielderror').show();
        	(json.home_phone2_error == '1') ? $('home_phone2').addClassName('fielderror').show() : $('home_phone2').removeClassName('fielderror').show();
         	(json.cell_phone_areacode_error == '1') ? $('cell_phone_areacode').addClassName('fielderror').show() : $('cell_phone_areacode').removeClassName('fielderror').show();
        	(json.cell_phone1_error == '1') ? $('cell_phone1').addClassName('fielderror').show() : $('cell_phone1').removeClassName('fielderror').show();
        	(json.cell_phone2_error == '1') ? $('cell_phone2').addClassName('fielderror').show() : $('cell_phone2').removeClassName('fielderror').show();
         	(json.weight_error == '1') ? $('weight').addClassName('fielderror').show() : $('weight').removeClassName('fielderror').show();
         	(json.graduation_date_error == '1') ? $('graduation_date').addClassName('fielderror').show() : $('graduation_date').removeClassName('fielderror').show();
       
         	
         	if ($('league_id')) {
         		(json.league_id_error == '1') ? $('league_id').addClassName('fielderror').show() : $('league_id').removeClassName('fielderror').show();
         	}
         	
         	if ($('current_team')) {
         		(json.current_team_error == '1') ? $('current_team').addClassName('fielderror').show() : $('current_team').removeClassName('fielderror').show();
         	}
         	
         	if ($('head_coach_error')) {
         		(json.head_coach_error == '1') ? $('headcoach').addClassName('fielderror').show() : $('headcoach').removeClassName('fielderror').show();
         		(json.head_coach_phone_error == '1') ? $('headcoachphone').addClassName('fielderror').show() : $('headcoachphone').removeClassName('fielderror').show();
         		(json.head_coach_email_error == '1') ? $('headcoachemail').addClassName('fielderror').show() : $('headcoachemail').removeClassName('fielderror').show();
         	}
         	
         	if ($('gm_error')) {	         	
	         	(json.gm_error == '1') ? $('generalmanager').addClassName('fielderror').show() : $('generalmanager').removeClassName('fielderror').show();
	         	(json.gm_phone_error == '1') ? $('generalmanagerphone').addClassName('fielderror').show() : $('generalmanagerphone').removeClassName('fielderror').show();
	         	(json.gm_email_error == '1') ? $('generalmanageremail').addClassName('fielderror').show() : $('generalmanageremail').removeClassName('fielderror').show();
         	}	

         	(json.family_members_error == '1') ? $('family_members').addClassName('fielderror').show() : $('family_members').removeClassName('fielderror').show();
         	
         	if ($('player_id')) {
         		(json.player_id_error == '1') ? $('player_id').addClassName('fielderror').show() : $('player_id').removeClassName('fielderror').show();
         	}
         	
         	(json.current_school_error == '1') ? $('current_school').addClassName('fielderror').show() : $('current_school').removeClassName('fielderror').show();
         	(json.current_status_error == '1') ? $('current_status').addClassName('fielderror').show() : $('current_status').removeClassName('fielderror').show();
         	(json.gpa_score_error == '1') ? $('gpa_score').addClassName('fielderror').show() : $('gpa_score').removeClassName('fielderror').show();
         	(json.sat_score_error == '1') ? $('sat_score').addClassName('fielderror').show() : $('sat_score').removeClassName('fielderror').show();
         	(json.ncaa_clearance_number_error == '1') ? $('ncaa_clearance_number').addClassName('fielderror').show() : $('ncaa_clearance_number').removeClassName('fielderror').show();
         	(json.college_list1_error == '1') ? $('college_list1').addClassName('fielderror').show() : $('college_list1').removeClassName('fielderror').show();
         	(json.college_list2_error == '1') ? $('college_list2').addClassName('fielderror').show() : $('college_list2').removeClassName('fielderror').show();
         	(json.college_list3_error == '1') ? $('college_list3').addClassName('fielderror').show() : $('college_list3').removeClassName('fielderror').show();
         	(json.study_intention_error == '1') ? $('study_intention').addClassName('fielderror').show() : $('study_intention').removeClassName('fielderror').show();
         	(json.career_ambition_error == '1') ? $('career_ambition').addClassName('fielderror').show() : $('career_ambition').removeClassName('fielderror').show();
         	(json.gpa_file_error == '1') ? $('gpa_file').addClassName('fielderror').show() : $('gpa_file').removeClassName('fielderror').show();
         	(json.sat_file_error == '1') ? $('sat_file').addClassName('fielderror').show() : $('sat_file').removeClassName('fielderror').show();
         	(json.other_file_error == '1') ? $('other_file').addClassName('fielderror').show() : $('other_file').removeClassName('fielderror').show();
         	(json.verification_error == '1') ? $('verificationcode').addClassName('fielderror').show() : $('verificationcode').removeClassName('fielderror').show();
         	
         	(json.guardian_name_error == '1') ? $('guardianname').addClassName('fielderror').show() : $('guardianname').removeClassName('fielderror').show();
         	(json.guardian_email_error == '1') ? $('guardianemail').addClassName('fielderror').show() : $('guardianemail').removeClassName('fielderror').show();
         	(json.guardian_areacode_error == '1') ? $('guardian_areacode').addClassName('fielderror').show() : $('guardian_areacode').removeClassName('fielderror').show();
         	(json.guardian_phone1_error == '1') ? $('guardian_phone1').addClassName('fielderror').show() : $('guardian_phone1').removeClassName('fielderror').show();
         	(json.guardian_phone2_error == '1') ? $('guardian_phone2').addClassName('fielderror').show() : $('guardian_phone2').removeClassName('fielderror').show();
         	
         	
			if (json.good == '1') {
				$('signupbutton').disabled = true;
				document.playerform.submit();
			}
			
	  }
	  
	}); 
		
	
}

function showTeamList() {
	
	var leagueid = $('league_id').getValue();
	
	if (leagueid.blank()) {
		$('team_listbox_title').update();
		$('team_listbox').update();
		$('position_listbox_title').update();
		$('position_listbox').update();
		return false;
	}
		
	new Ajax.Request('ajax/front_ajax.php',
	{   	
		method: 'post',
		parameters: {action: 'getteamlist',leagueid: leagueid},
		onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
         	html = json.html; 
         	html2 = json.html2;
         	html3 = json.html3;
         	html4 = json.html4;
         	
         	$('team_listbox').update(html);
			$('team_listbox_title').update(html2);
			$('position_listbox_title').update(html3);
			$('position_listbox').update(html4);
			
			
	    }
	  
	}); 	
		
}

function VerifySuperUserForm() {
	
	var formdata = $('superuserform').serialize();
	
	new Ajax.Request('ajax/front_ajax.php',
	{   	
		method: 'post',
		parameters: formdata,
		onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
        	message = json.message;
			first_name_error = json.first_name_error;
			last_name_error = json.last_name_error;
			email_error = json.email_error;
        	
         	(first_name_error == '1') ? $('first_name_error').update('*') : $('first_name_error').update();
         	(last_name_error == '1') ? $('last_name_error').update('*') : $('last_name_error').update();
         	(email_error == '1') ? $('email_error').update('*') : $('email_error').update();	
         			
        	if (json.good == '1') document.superuserform.submit();
	    }
	  
	}); 	
		
}

function VerifySalesForm() {
	
	var formdata = $('salesform').serialize();
	
	new Ajax.Request('ajax/front_ajax.php',
	{   	
		method: 'post',
		parameters: formdata,
		onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
        	message = json.message;
        	        	
         	(json.first_name_error == '1') ? $('sales_first_name_error').update('*') : $('sales_first_name_error').update();
         	(json.last_name_error == '1') ? $('sales_last_name_error').update('*') : $('sales_last_name_error').update();
         	(json.email_error == '1') ? $('sales_email_error').update('*') : $('sales_email_error').update();	
         			
        	if (json.good == '1') document.salesform.submit();
	    }
	  
	}); 	
		
}

function VerifyCoachForm() {
	
	var formdata = $('coachform').serialize();
	
	new Ajax.Request('ajax/front_ajax.php',
	{   	
		method: 'post',
		parameters: formdata,
		onSuccess:function(transport) {
 	      	var json = transport.responseText.evalJSON(true);
        	m = json.message;
					
          	if (m == '') {
         		$('status').hide();
         	} else {
         		$('status').addClassName('failure').show();
         		$('status').show();
         		$('status').update(m);
         	}
         	       	
         	(json.coach_college_team_error == '1') ? $('college_team').addClassName('fielderror').show() : $('college_team').removeClassName('fielderror').show();
         	(json.first_name_error == '1') ? $('first_name').addClassName('fielderror').show() : $('first_name').removeClassName('fielderror').show();
         	(json.last_name_error == '1') ? $('last_name').addClassName('fielderror').show() : $('last_name').removeClassName('fielderror').show();
         	(json.email_error == '1') ? $('email').addClassName('fielderror').show() : $('email').removeClassName('fielderror').show();
         	(json.extension_error == '1') ? $('coach_extension').addClassName('fielderror').show() : $('coach_extension').removeClassName('fielderror').show();
         	(json.phone_error == '1') ? $('coach_phone').addClassName('fielderror').show() : $('coach_phone').removeClassName('fielderror').show();
         	
         	
        	if (json.good == '1') document.coachform.submit();

		
	    }
	  
	}); 
		
}

function VerifyTeamAdminForm() {
	
	var formdata = $('teamadminform').serialize();
	
	new Ajax.Request('ajax/front_ajax.php',
	{   	
		method: 'post',
		parameters: formdata,
		onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
        	m = json.message;
        			
          	if (m == '') {
         		$('status').hide();
         	} else {
         		$('status').addClassName('failure').show();
         		$('status').show();
         		$('status').update(m);
         	}
         			
         	(json.team_admin_jr_team_error == '1') ? $('jr_team').addClassName('fielderror').show() : $('jr_team').removeClassName('fielderror').show();
         	(json.first_name_error == '1') ? $('first_name').addClassName('fielderror').show() : $('first_name').removeClassName('fielderror').show();
         	(json.last_name_error == '1') ? $('last_name').addClassName('fielderror').show() : $('last_name').removeClassName('fielderror').show();
         	(json.email_error == '1') ? $('email').addClassName('fielderror').show() : $('email').removeClassName('fielderror').show();
         	(json.extension_error == '1') ? $('teamadmin_extension').addClassName('fielderror').show() : $('teamadmin_extension').removeClassName('fielderror').show();
         	(json.phone_error == '1') ? $('teamadmin_phone').addClassName('fielderror').show() : $('teamadmin_phone').removeClassName('fielderror').show();
         	
         	
        	if (json.good == '1') document.teamadminform.submit();
	    }
	  
	}); 	
	
}

function selectUserType() {
	
	var usertype = Form.getInputs('signupform','radio','usertype').find(function(radio) { return radio.checked; }).value;
	var coach = $('coach');
	var teamadmin = $('teamadmin');
	var player = $('player');
	
	switch(usertype) {
		case '3':

			coach.show();
			teamadmin.hide();
			player.hide();	
		break;
		
		case '4':
			coach.hide();
			teamadmin.show();
			player.hide();
		break;
		
		case '5':
			coach.hide();
			teamadmin.hide();
			player.show();	
		break;
		
	}	
	
}

function displayTip(type) {

	switch (type) {
		
		case 'birthdate':
			Dialog.alert("<div align='center'>Birth Date format should be (YYYY-MM-DD)</div>", {windowParameters: {width: 300, className: "alphacube", zIndex:1000}});
		break;
		
		case 'phone':
			Dialog.alert("<div align='center'>Phone number format should be in (xxxxxxxxx)</div>", {windowParameters: {width: 300, className: "alphacube", zIndex:1000}});
		break;
		
		case 'playerid':
			Dialog.alert({url: "ajax/front_ajax.php?action=tooltip&type=playerid", options: {method: 'GET'}}, {className: "alphacube", width:800, height:700, okLabel: "Close",buttonClass: "button", zIndex:1000});			
		
		break;
	}
	             
}

function switchVideo(link,description) {

	new Ajax.Request('ajax/front_ajax.php',
   	{
      	method: 'post',
      	evalScripts: true,
      	parameters: {action: 'showvideo',
      				 videolink: link,
      				 videodescription: description
      				 },
      	onSuccess:function(transport) {
        	var json = transport.responseText.evalJSON(true);
        	$('videoplayer').update(json.html);
      	}
   	}); 
}

function turnOnImageBorder(t) {
	
	turnOffAllImageBorder();
	
	$(t).addClassName('videoimageborderon').show();
}

function turnOffAllImageBorder() {

	var i=0;
	var img;

	while (img = document.getElementsByTagName('img')[i++]){
		if (img.id.match(/stevathumb_/)) {
			$(img).removeClassName('videoimageborderon').show();
		}
	}

}

function playVideo(link,description) {


	flashembed("videoplayer", {src:link}, {config: { 
	playlist: [
	   { url: link,
	     autoPlay: true, 
	     autoBuffering: true 
	   }
	]
	}}); 


	$('description').update(description);

	
}

function playPublicVideo(link,description) {

	flowplayer("videoplayer", "swf/flowplayer-3.2.3.swf",  {
			
		// here is our playlist with two clips
		playlist: [
					
			// second clip is a video. when autoPlay is set to false the splash screen will be shown
			{
				url: link, 
				autoPlay: true, 
				
				// video will be buffered when splash screen is visible
				autoBuffering: true 
			}
		]
	});


	$('description').update(description);

}

