
function show_round_form(round, type) {


	if(document.getElementById("round_" + round + "_" + type + "_layer").style.display == "none") {
		if(type == "my") {
		
			 document.getElementById("round_" + round + "_oob_layer").style.display = "none";
		}
		
		document.getElementById("round_"+round).value = type;
                document.getElementById("round_" + round + "_" + type + "_layer").style.display = "block";
		//document.getElementById(round + "_selections").style.display = "none";
		
			event_id = document.getElementById("event_id").value;
			if(event_id) {
				xajax_getEventUniqueCourses(event_id, round);
			}	
		
        } else {
		document.getElementById("round_"+round).value = "";
                document.getElementById("round_" + round + "_" + type + "_layer").style.display = "none";
                if(document.getElementById(round + "_event_othercourses_out")) {
	                document.getElementById(round + "_event_othercourses_out").style.display = "none";
	            }
		//document.getElementById(round + "_selections").style.display = "block";
        }

}

//function show_round_form(round) {
//
//
//	if(document.getElementById("round_" + round + "_layer").style.display == "none") {
//                document.getElementById("round_" + round + "_layer").style.display = "block";
//        } else {
//                document.getElementById("round_" + round + "_layer").style.display = "none";
//        }
//
//}




function call_add_course(ap) {
	alert(xajax.getFormValues("Shadowbox." + ap + "_form_addcourse"));
	xajax_insertCourse(xajax.getFormValues("Shadowbox." + ap + "_form_addcourse"), ap);
}


function call_oob_find(ap, page, event_id) {
	
	oob_city = document.getElementById(ap + '_oob_city').value
	oob_state = document.getElementById(ap + '_oob_state').value
	oob_radius = document.getElementById(ap + '_oob_radius').value
	oob_keywords = document.getElementById(ap + '_oob_keywords').value
	
	xajax_OOB_find_course(ap, oob_city, oob_state, oob_radius, oob_keywords, page, event_id);	
}

function addPlayerFields(num_fields, org_fname, org_lname, org_email, org_phone, org_hcp) {

	var addlayer = document.getElementById('add_players');

	num_fields2 = parseInt(num_fields);
	data = "";
	
	data = '<br><br>Fill in as many as you know now, you will be able to add (or subtract) at any time later.<table width="400px" border="0" cellspacing="2" cellpadding="0"><tr>	<td><b>Name</b></td> <td><b>E-mail</b></td>	</tr>';
	   data = data + '<tr class="tabletext">	<td class="form_col">'+org_email+'</td></tr>';
	
	for (i=2;i<=num_fields2;i++) 
	{
		
	   data = data + '<tr class="tabletext">	<td class="form_col"><input type="text" name="'+ i +'name" value="" size="20"></td>  <td class="form_col"><input type="text" name="'+ i +'email" value="" size="20"></td></tr>';


	}
	data = data + "</table>";
	
	//data = '<table width="100%" border="0" cellspacing="2" cellpadding="0"><tr>	<td><h3><b>First Name</b></h3></td>	<td><h3><b>Last Name</b></h3></td>	<td><h3><b>E-mail</b></h3></td>	<td><h3><b>Cell phone</b></h3></td>	<td><h3><b>USGA<br>Handicap</b></h3></td></tr>';
	//   data = data + '<tr class="tabletext">	<td class="form_col"><b>1 </b> '+org_fname+'</td>	<td class="form_col">'+org_lname+'</td>	<td class="form_col">'+org_email+'</td>	<td class="form_col">'+org_phone+'</td>	<td class="form_col">'+org_hcp+'</td></tr>';
	//
	//for (i=2;i<=num_fields2;i++) 
	//{
	//	
	//   data = data + '<tr class="tabletext">	<td class="form_col"><b>'+ i +'</b> <input type="text" name="'+ i +'fname" value="" size="20"></td>	<td class="form_col"><input type="text" name="'+ i +'lname" value="" size="20"></td>	<td class="form_col"><input type="text" name="'+ i +'email" value="" size="20"></td>	<td class="form_col"><input type="text" name="'+ i +'cell" value="" size="10"></td>	<td class="form_col"><input type="text" name="'+ i +'hcp" value="" size="3"></td></tr>';
	//
	//
	//}
	
	addlayer.innerHTML = data;

}

function addPlayerFields2(num_fields, start_num) {

	var addlayer = document.getElementById('add_players');

	num_fields2 = parseInt(num_fields);
	data = "";
	
	data = '<h3>Participant to Add</h3><i>Fill in as many as you know now, you will be able to add (or subtract) at any time later.</i><table width="400px" border="0" cellspacing="2" cellpadding="0"><tr>	<td><b>Name</b></td> <td><b>E-mail</b></td></tr>';
	//start_num = start_num + 1;
	for (i=start_num;i<num_fields2;i++) 
	{
		
 	   data = data + '<tr class="tabletext">	<td class="form_col"><input type="text" name="'+ i +'name" value="" size="20"></td> <td class="form_col"><input type="text" name="'+ i +'email" value="" size="20"></td>	</tr>';


	}
	data = data + '</table>';
	
	addlayer.innerHTML = data;

}


function addHoleContest(num_fields, out_layer, ap) {

	 if(document.getElementById(out_layer).style.display == "block") {
	
		 document.getElementById(out_layer).style.display = "none";
	
	 } else {
		document.getElementById(out_layer).style.display = "block";
		
		var addlayer = document.getElementById(out_layer);
	
		num_fields2 = parseInt(num_fields);
		data = "";
		
		for (i=1;i<=num_fields2;i++) 
		{
			
		   data = data + '<select name="'+ i + ap + '_contest_type"><option value=""></option><option value="closest">Closest to pin</option><option value="straightest">Straightest drive Men</option><option value="longest">Longest drive Men</option><option value="straightest_women">Straightest drive Women</option><option value="longest_women">Longest drive Women</option></select> &nbsp;&nbsp; Hole #<input type="text" name="'+ i + ap + '_contest_hole" value="" size="2"><br>';
	
	
		   
		   
		}
		
		data = data + "<input type='text' name='custom_game_"+ ap + "' value='' size='22'> &nbsp;&nbsp; Hole #<input type='text' name='"+ ap + "_custom_contest_hole' value='' size='2'><br>";
		
		addlayer.innerHTML = data;
	}
	

}


function removeEvent(id) {


	var confirm_msg = confirm("Are you sure you want to remove this event? All information associated with this event will be lost. Click OK to delete.")
 	if (confirm_msg)
 	{
		top.location.href = '/events/signup.html?action=remove&event_id=' + id;
    	return true
  	}

}


function ShadowboxAddCourse(url){

    Shadowbox.open({
        player:     'iframe',
        content:    'http://www.organizeyourgolfevent.com'+url,
        height:     477,
        width:      977
    });

};

function removePlayer(url) {
	
	var confirm_msg = confirm("Are you sure you want to remove this user? Click OK to delete.")
 	if (confirm_msg)
 	{
		top.location.href = url;
    	return true
  	}
}


function removeConfirm(url) {
	
	var confirm_msg = confirm("Are you sure you want to remove this? Click OK to delete.")
 	if (confirm_msg)
 	{
		top.location.href = url;
    	return true
  	}
}

function removeRound(event_round_id, event_id, ap) {
	
	var confirm_msg = confirm("Are you sure you want to remove this round? Click OK to delete.")
 	if (confirm_msg)
 	{
		xajax_removeRound(event_round_id, event_id, ap);
    	return true
  	}
}

function uploadcomplete() {
	
	var c_event_id = document.getElementById("saved_event_id").value;
	
	xajax_event_get_photos(c_event_id);
}

field_changed = 0;

function form_field_updated() {
	field_changed = 1;
}

function check_form_changed(url) {
	
	if(field_changed == 1) {
		var confirm_msg = confirm("Are you sure you want to leave this page without saving?")
		if (confirm_msg)
		{
			location.href = url;
			return true
		}
	} else {
		location.href = url;
	}
	
	
}

function FCKeditor_OnComplete( editorInstance )
{
    editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
}



function DoSomething( editorInstance )
{
   
    form_field_updated()
}



function enable_disable_travel(selection)
{

	if(selection == "flying") {
	
		document.dform.travel_arrival_date.disabled=false;
		document.dform.travel_arrival_time.disabled=false;
		document.dform.travel_arrival_airline.disabled=false;
		document.dform.travel_arrival_flight.disabled=false;
		document.dform.travel_depart_date.disabled=false;
		document.dform.travel_depart_time.disabled=false;
		document.dform.travel_depart_airline.disabled=false;
		document.dform.travel_depart_flight.disabled=false;
	} else {
		document.dform.travel_arrival_date.disabled=true;
		document.dform.travel_arrival_date.style.backgroundColor = '#CCCCCC';
		document.dform.travel_arrival_time.disabled=true;
		document.dform.travel_arrival_airline.disabled=true;
		document.dform.travel_arrival_flight.disabled=true;
		document.dform.travel_depart_date.disabled=true;
		document.dform.travel_depart_time.disabled=true;
		document.dform.travel_depart_airline.disabled=true;
		document.dform.travel_depart_flight.disabled=true;
		
		document.dform.travel_arrival_time.style.backgroundColor = '#CCCCCC';
		document.dform.travel_arrival_airline.style.backgroundColor = '#CCCCCC';
		document.dform.travel_arrival_flight.style.backgroundColor = '#CCCCCC';
		document.dform.travel_depart_date.style.backgroundColor = '#CCCCCC';
		document.dform.travel_depart_time.style.backgroundColor = '#CCCCCC';
		document.dform.travel_depart_airline.style.backgroundColor = '#CCCCCC';
		document.dform.travel_depart_flight.style.backgroundColor = '#CCCCCC';
	}

}

function removeMessage(event_id, id) {


	var confirm_msg = confirm("Are you sure you want to remove this message? Click OK to delete.")
 	if (confirm_msg)
 	{
		xajax_removeMSG(event_id, id);
    	return true
  	}

}

function points_showhide(field) {

	if(document.getElementById(field).style.display == "none") {
		document.getElementById(field).style.display = "block";
	} else {
		document.getElementById(field).style.display = "none";
	}

}

function toggle_pp_divs(layer) {

	if(document.getElementById(layer).style.display == "none") {
		document.getElementById(layer).style.display = "block";
		document.getElementById(layer+"l").innerHTML = 'HIDE';
	} else {
		document.getElementById(layer).style.display = "none";
		document.getElementById(layer+"l").innerHTML = 'SHOW';
	}

}




