//--  GLOBAL JAVASCRIPT FOR MEDIA SIGN-UP FORM  ---------------------------------------------------------------------


//-- set color for error indicator  -------------------------------------------------------
/*
	var errcolor =  "#FFFFCC";					//-- pale weak yellow
	var errcolor =  "#FFFF99";					//-- pale dull yellow
	var errcolor =  "#5F141A";				//--  FHP maroon (dark)
	var errcolor =  "#6F2123";				//--  FHP maroon (mid)
	var errcolor =  "#7D3134";				//--  FHP maroon (light)
	var errcolor =  "#7289A6";				//--  SMC blue-grey  (dark)
	var errcolor =  "#869AB4";				//--  SMC blue-grey  (light)
*/
	
	var errcolor =  "#B7B7B7";				//--  FHP grey

//-- set color for current field indicator  -------------------------------------------------------
/*
	var currfieldcolor = "#FF0000";		//--  red
	var currfieldcolor =  "#CCFFCC";		//-- pale weak green
	var currfieldcolor = "#71904A";		 //-- SWC green  (dark)
*/	
	var currfieldcolor = "#85A160";		 //-- SWC green (light)
	
//-- name of error pop-up window  -------------------------------------------------------
	var errWin;
	var returnTo;
	
//-- regular expression to check for all digits  -------------------------------------------------------
	var reg = /\D/;   // D = non-digit  d = digit
	
//-- adjust length for buttons on form  ---------------------------------------------------------------------	
	var lenadjust = 1;
    var startwith = 0;

//-- function to color field user currently is in   -------------------------------------------------------
function colorMe( currfield )
{
	uncolorMe( currfield )

	//-- highlight current form field
	document.getElementById( currfield ).style.backgroundColor = currfieldcolor;
	document.getElementById( currfield ).style.color = "#FFFFFF";


}

//-- function to uncolor field user just left when current field is select list   -------------------------------------------------------
function uncolorMe( currfield )
{

	var currform = document.booking.section.value;

	switch( currform )
	 {  case "3":
			lenadjust = 2;
			break;
		 case "3edit":
			startwith = 1;
			break;
		default:
	 }

//-- roll thru form fields ( except submit button ) and reset colors
	for ( var i = startwith; i < document.booking.length - lenadjust; i++ )
	  {  var currid = document.booking[i].name;

		   try
		     { document.getElementById( currid ).style.backgroundColor = "";	
			   document.getElementById( currid ).style.color = "#000000"; }
		   catch(err)
			 { /* DO NOTHING */  }			
	  }//-- end for loop

} //-- end function


//-- functions to display / hide div error message  -------------------------------------------------------

function anon_note( msg, currfield )
{
	var wide = screen.width;
	var maxwide = 800;
	var offset = wide - maxwide;
	var Xpoint = maxwide - 350;

	if ( offset > 0 )
		{  Xpoint = Xpoint + ( offset/2.4 );		}

	document.getElementById("anonmsg").innerHTML = msg;
	document.getElementById("anonfield").value = currfield;

	document.getElementById("anon").style.display = "block";
	document.getElementById("anon").style.display = "inline";
	document.getElementById("anon").style.left = Xpoint;
	
}


function anon_hide()
{
	var setfocus = document.getElementById("anonfield").value;
	
	document.getElementById("anonmsg").innerHTML = "";
	document.getElementById("anon").style.display = "none";
	document.booking.elements[ setfocus ].focus();
}


//-- functions to display error message as a pop-up window  -------------------------------------------------------

function anon_pop( msg, currfield )
{
	document.getElementById("anonfield").value = currfield;
	
	document.errorform.errormsg.value = msg;
	document.errorform.errorfield.value = currfield;

//	alert( currfield );
	
	var defaultWinH = 180;
	var setWinH;
	setWinH = defaultWinH;
		
	//-- set height exceptions where messages are longer
/*
	switch ( currfield )
		{		case "cardexpmth":
					setWinH = 220;
					break;
				case "sponsorMemberCount":
				case "donationAmount":
					setWinH = 250;
					break;
				default:
					setWinH = defaultWinH;
					break;
	    }
*/
	
	if ( currfield.lastIndexOf( "_0", currfield.length ) != -1 )
		{  document.errorform.errorfield.value = currfield.substr( 0, ( currfield.length - 1 ) );
		   document.getElementById("anonfield").value = currfield.substr( 0, ( currfield.length - 1 ) );
		   setWinH = defaultWinH;		}
		
	if ( currfield.substr(0, 5) == "phone" )
		{ setWinH = 210;		}

	
	//openErrWin( setWinH );
	anon_pop2( msg, currfield )
}


function anon_pop2( msg, currfield )
{
	$q('modal_errormsg').innerHTML = msg;
	//$('modal_overlay').style.display = 'block';
	//$('modal_modal').style.display = 'block';
	returnTo = currfield;
	
	modal_click('show'); 
}

//-- error message pop-up window  -------------------------------------------------------
function openErrWin( winhigh )
{
		var URL = "";
		var winW = 320;
		var winH = winhigh;

		var wide = screen.width;
		var maxwide = 800;
		var offset = wide - maxwide;
		
		var Xpoint = maxwide - 350;
		var Ypoint = 30 + 100;

		if ( offset > 0 )
			{  Xpoint = Xpoint + ( offset/2.4 );  }
		
		var attributes = "";
		attributes += 'width=' + winW;
		attributes += ', height=' + winH;
		attributes += ', top=' + Ypoint;
		attributes += ', left=' + Xpoint;

	
		if ( errWin )
			{ errWin.close();	}
			
		errWin = window.open( '../forms/globalErrorpage.asp?erron=booking', '', attributes  );	
}


  

