// Take all the elements whatever you want to make Draggable.
/***********Commenetd by avesh(SP)--start**************/ 
/*
   var elements = [
   'overlay400',
   //'overlay673',
   'overlay764',  
   ];
   

   
//Make all the items drag able by creating Draggable objects
window.onload = function() {
   elements.each(
       function(itemj) {
           new Draggable(itemj, {});
	   }
   );
}*/

 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12940621-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



function disableButton(id)
{
	$(id+'submit').disabled = true;
}


function m_DisplayPaymentInput()
{
 if($('renewAccountCheckId').checked)
 {
		$('upgradePaymentId').style.display='';
		$('validateId').value='1';
 }
 else
 {
		$('upgradePaymentId').style.display='none';
		$('validateId').value='0';
 }
 
}

/***********Commenetd by avesh(SP)--end**************/ 
function m_Twitts(url)
{
	 if (location.protocol === 'https:')
	 {
    	// page is secure
		url= url.replace(/^http:/, 'https:');
 	 }
	$('overlay764').style.display='';
	$('overlay764').style.marginTop = '19.6px'
	$('overlay764').innerHTML='<div class="loader"></div>';
	$('transparentdiv').style.display='';
	new Ajax.Updater('overlay764',url,{evalScripts:true, evalJS:true});
	scrollEvent('overlay764');
	//setTimeout("new Draggable('overlay764',{handle:'dragIdNewStuff'});",10000);
}

function m_MobileVersion(url)
{
    $('overlay764').style.display='';
	$('overlay764').style.marginTop = '19.6px'
	$('overlay764').innerHTML='<div class="loader"></div>';
	$('transparentdiv').style.display='';
	new Ajax.Updater('overlay764',url,{evalScripts:true, evalJS:true});
	scrollEvent('overlay764');
}


function affiliate_logout(url)
{
   new Ajax.Request('affiliate/users/index.php?action=logout',{onComplete: function(transport)
   {
		window.location = url; 
	}
});					
}

/*********Added by Avesh(SP) ***************/
function m_Affiliates(url)
{
	$('overlay764').style.display='';
	$('overlay764').style.marginTop = '19.6px'
	$('overlay764').innerHTML='<div class="loader"></div>';
	$('transparentdiv').style.display='';
	new Ajax.Updater('overlay764',url,{evalScripts:true, evalJS:true});
	scrollEvent('overlay764');
}

/*********Added by Avesh(SP) ***************/
function m_HelpPage(url)
{
	if($('overlay764'))
	{
	$('overlay764').style.display='';
	$('overlay764').style.marginTop = '19.6px'
	$('overlay764').innerHTML='<div class="loader"></div>';
	$('transparentdiv').style.display='';
	new Ajax.Updater('overlay764',url,{evalScripts:true, evalJS:true});
	scrollEvent('overlay764');
	}
}

function setcustomValue(custom_min1,custom_max1,custom_min2,custom_max2,custom_min3,custom_max3,pageId,radioVal,customMinVal1,customMaxVal1,customMinVal2,customMaxVal2,customMinVal3,customMaxVal3,action,unitType)
{
  if(radioVal=='F')
  {	
	$(pageId+'custom0').value='';
	$(pageId+'custom1').value='';
	$(pageId+'custom2').value='';
	if(custom_max1!='')
	{
	  $(pageId+'custom_outof0').value=custom_max1;
	  $(pageId+'custom_outof0').style.display='none';
	  $('customoutofTextId0').style.display='none';
	  $('customId0').style.display='';
	  $('customIdText0').style.display='';
	}
	if(custom_max2!='')
	{
	  $(pageId+'custom_outof1').value=custom_max2;
	  $(pageId+'custom_outof1').style.display='none';
	  $('customoutofTextId1').style.display='none';
	  $('customId1').style.display='';
	  $('customIdText1').style.display='';
	}
	if(custom_max3!='')
	{
	  $(pageId+'custom_outof2').value=custom_max3;
	  $(pageId+'custom_outof2').style.display='none';
	  $('customoutofTextId2').style.display='none';
	  $('customId2').style.display='';
	  $('customIdText2').style.display='';
	}
	//set the default value for edit option
  if(action==1 && unitType == 'F')
  {
 	if(customMinVal1!='')
	{
	   $(pageId+'custom0').value=customMinVal1;
	}
	if(customMaxVal1!='')
	{
	   $(pageId+'custom_outof0').value=customMaxVal1;
	}
	if(customMinVal2!='')
	{
	   $(pageId+'custom1').value=customMinVal2;
	}
	if(customMaxVal2!='')
	{
	   $(pageId+'custom_outof1').value=customMaxVal2;
	}
	if(customMinVal3!='')
	{
	   $(pageId+'custom2').value=customMinVal3;
	}
	if(customMaxVal3!='')
	{
	   $(pageId+'custom_outof2').value=customMaxVal3;
	}
  }
  
  }
  else
  {
 	  $(pageId+'custom_outof0').value='';
	  $(pageId+'custom_outof1').value='';
	  $(pageId+'custom_outof2').value='';
	  $(pageId+'custom0').value='';
	  $(pageId+'custom1').value='';
	  $(pageId+'custom2').value='';
	  $(pageId+'custom_outof0').style.display='';
	  $(pageId+'custom_outof1').style.display='';
	  $(pageId+'custom_outof2').style.display='';
	  $('customId0').style.display='';
	  
	  $('customoutofTextId0').style.display='';
	  $('customoutofTextId1').style.display='';
	  $('customoutofTextId2').style.display='';
	  
	  $('customIdText0').style.display='none';
	  $('customId1').style.display='';
	  $('customIdText1').style.display='none';
	  $('customId2').style.display='';
	  $('customIdText2').style.display='none';
	  if(action==1 && unitType=='P')
	  {
		if(customMinVal1!='')
		{
		   $(pageId+'custom0').value=customMinVal1;
		}
		if(customMaxVal1!='')
		{
		   $(pageId+'custom_outof0').value=customMaxVal1;
		}
		if(customMinVal2!='')
		{
		   $(pageId+'custom1').value=customMinVal2;
		}
		if(customMaxVal2!='')
		{
		   $(pageId+'custom_outof1').value=customMaxVal2;
		}
		if(customMinVal3!='')
		{
		   $(pageId+'custom2').value=customMinVal3;
		}
		if(customMaxVal3!='')
		{
		   $(pageId+'custom_outof2').value=customMaxVal3;
		}
	  }
	  
  }
}


function m_setCustomUniType(radioVal,customNo,pageId,action,customMinVal,customMaxVal,selectedRadio)
{
   if(customNo==1)
   {
	  if(selectedRadio!=radioVal)
	  {
	     confirmMsg = confirm("You have changed the tracking method\n(i.e. Percentage or Total number) for one\n or more of your Custom stats. This will reset \nyour history for custom stats. Are you sure?");    
	  }
	  if(confirmMsg==true)
	  {	
		/***********set the value that's must be reset to 1 ***********************/
		$('input_custom_reset0').value = 1; 
		/***********set the value that's must be reset ***********************/
		if(radioVal=='F')
		{
		   $('PreferencecustomId1').style.display='';
		   if(action==1)
		   {
			$(pageId+'feu_customfieldMinVal0').value = customMinVal;
			$(pageId+'feu_customfieldMaxVal0').value = customMaxVal;  
		   }
		 }
		 else
		 {
		   $('PreferencecustomId1').style.display='none';
		   $(pageId+'feu_customfieldMinVal0').value = '';
		   $(pageId+'feu_customfieldMaxVal0').value = '';
		 }
	  }
	  else
	  {
	   /***********set the value that's must be reset to 1 ***********************/
		$('input_custom_reset0').value = 0; 
		if(selectedRadio=='P')
		{
		 	$('cntnt01input_custom_type11').checked=true;
		}
		else
		{
			$('cntnt01input_custom_type12').checked=true;
		}
		
	    /***********set the value that's must be reset ***********************/
	  }
   }
   if(customNo==2)
   {
  	 if(selectedRadio!=radioVal)
	  {
		confirmMsg = confirm("You have changed the tracking method\n(i.e. Percentage or Total number) for one\n or more of your Custom stats. This will reset \nyour history for custom stats. Are you sure?");    
	  }
	  if(confirmMsg==true)
	  {		 
		/***********set the value that's must be reset to 1 ***********************/
		 $('input_custom_reset1').value = 1; 
		/***********set the value that's must be reset ***********************/
		 if(radioVal=='F')
		 {
		   $('PreferencecustomId2').style.display='';
		   if(action==1)
		   {
			$(pageId+'feu_customfieldMinVal1').value = customMinVal;
			$(pageId+'feu_customfieldMaxVal1').value = customMaxVal;  
		   }
		 }
		 else
		 {
		   $('PreferencecustomId2').style.display='none';
		   $(pageId+'feu_customfieldMinVal1').value = '';
		   $(pageId+'feu_customfieldMaxVal1').value = '';
		 }
	  }
	  else
	  {
	   /***********set the value that's must be reset to 0 ***********************/
		 	$('input_custom_reset1').value = 0; 
		    if(selectedRadio=='P')
			{
				$('cntnt01input_custom_type21').checked=true;
			}
			else
			{
				$('cntnt01input_custom_type22').checked=true;
			}
		/***********set the value that's must be reset ***********************/
	  }
   }
    if(customNo==3)
   {
	 if(selectedRadio!=radioVal)
	 {
		confirmMsg = confirm("You have changed the tracking method\n(i.e. Percentage or Total number) for one\n or more of your Custom stats. This will reset \nyour history for custom stats. Are you sure?");    
	  }
	  if(confirmMsg==true)
	  {		  
	  /***********set the value that's must be reset to 1 ***********************/
	  $('input_custom_reset2').value = 1; 
	  /***********set the value that's must be reset ***********************/
	 if(radioVal=='F')
     {
	   $('PreferencecustomId3').style.display='';
	   if(action==1)
	   {
		$(pageId+'feu_customfieldMinVal2').value = customMinVal;
	    $(pageId+'feu_customfieldMaxVal2').value = customMaxVal;  
	    }
	  }
	  else
	  {
	   $('PreferencecustomId3').style.display='none';
	   $(pageId+'feu_customfieldMinVal2').value = '';
	   $(pageId+'feu_customfieldMaxVal2').value = '';
	  }
	}
	else
	{
	  		$('input_custom_reset2').value = 0; 
	   		if(selectedRadio=='P')
			{
				$('cntnt01input_custom_type31').checked=true;
			}
			else
			{
				$('cntnt01input_custom_type32').checked=true;
			}
	}
  }
}
function m_updateAccount(url,divId,bigDivId)
{
  m_CloseCardExpiry('cardId','maskId','md9f06');
  m_UpdateCalculatorPopup(url,divId,bigDivId,'','');
}

// JavaScript Document
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}
 /**
	* Added By:	Avesh(A)
	* Added On	 : 01 Sept
    * DESC		 :to display the tooltip message.
	* @PARAM :  html contorl id integer, html control value 
    * @return  :  string 
	*/
function  tooltipone(id,val)
{
	var elementObject = document.getElementById(id);
	elementObject.style.border = '1px solid #999999';
	
	if (elementObject.value == '')
	{
		// set all values on html control
		elementObject.value = val;
		elementObject.style.color = '#999999';
		
	}
	
}

 /**
	* Added By:	Avesh(A)
	* Added On	 : 01 Sept
    * DESC		 :This develpoed to hide tooltip message.
	* @PARAM :  html contorl id integer, html control value 
    * @return  :  string 
	*/
	
function tooltiptwo(id,val)
{
	var elementObject = document.getElementById(id);
	
	if (elementObject.value == val)
	{
		// set all values on html control
		elementObject.value = ''; 
		elementObject.style.color = '#000000';
		//elementObject.style.border = '1px solid #999999';
		
	}
}

function m_showCardExpiryDate()
{
$('cardId').style.display='';
$('maskId').style.display='';
scrollEvent('cardId');
}

function m_CloseCardExpiry(sContainerId,sBgId,pageId)
{
	m_DisplayHideObject(true);
	new Effect.Fade(sContainerId,{duration:0.8,afterFinish:function(){Effect.Fade(sBgId,{duration:1.0})}});;
	hide_dropdowns('out');
	new Ajax.Request('index.php?page=dashboard&'+pageId+'closeCardExpiry=1&'+pageId+'ajaxRequest=1',{method:'post'});
}

function extractNumber(obj,decimalPlaces, allowNegative)
{
	var temp = obj.value;
	
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	return isFirstN || isFirstD || reg.test(keychar);
}
 /**
	* Added By:	Avesh(A)
	* Added On	 : 01 oct
    * DESC		 : this function is used for show and hide contents on my account page
	* @PARAM     : html contorl id integer, html control value 
    * @return    : container id 
	*/
	
function showPageContent(container_id,labclass,tabid)
{		
	if($('personalInfo'))
	$('personalInfo').style.display="none";	
	if($('billingInfo'))
	$('billingInfo').style.display="none";
	if($('preferences'))
	$('preferences').style.display="none";
	if($('referralsInfo'))
	$('referralsInfo').style.display="none";
	if($('giftcodeInfo'))
	$('giftcodeInfo').style.display="none";
	if($(container_id))
	$(container_id).style.display="block";	
	if($('containerlable'))
	$('containerlable').className=labclass;
	if($('personalTab'))
	$('personalTab').className='';
	if($('billingTab'))
	$('billingTab').className='';
	if($('preferencesTab'))
	$('preferencesTab').className='';	
	if($('referralsTab'))
	$('referralsTab').className='';		
	if($('giftcodeTab'))
	$('giftcodeTab').className='';	
	if($(tabid))
	$(tabid).className='selected';
	if($('tabselected'))
	$('tabselected').value=tabid;
	if($('success_messages')){
		  $('success_messages').hide();	
	//  $('success_messages').style.display='none';
	}
}




/*******************************************************
Purpose		: show edit page on my account section
Parameters	: showBoxId, hideBoxId 
Created By	: Avesh Srivastava
Created On	: 20-oct-2009
********************************************************/

function showEditOptions(showBoxId,hideBoxId,groupid){
	  if(showBoxId=="preferencesEdit" && groupid==2){	
		 document.getElementById('privacy').onclick=null;
		 document.getElementById('notifications').onclick=null;
	   }
	   if(showBoxId=="preferencesEdit" && (groupid==1 || groupid==3)){	
		 
		 document.getElementById('notifications').onclick=null;
		 document.getElementById('notifications_1').onclick=null;
	   }
	   document.getElementById(showBoxId).style.display="block";	
	   document.getElementById(hideBoxId).style.display="none";	   
}
		
		
/*******************************************************
Purpose		: for pagination option
Parameters	: url, container id in which the pop up will imerge
			  and the background layout div id
Created By	: Avesh Srivastava
Created On	: 20-oct-2009
********************************************************/		
	
  function getPageContents(sUrl,sContainerId){
		ajax_simple_post_new(sUrl,sContainerId,'');
  }  
  
  
  
/*******************************************************
Purpose		: delete the messages for player
Parameters	: url, container id in which the pop up will imerge
			  and the background layout div id
Created By	: Avesh Srivastava
Created On	: 20-oct-2009
********************************************************/
 function deleteMessage(achr,sContainerId){	
       var check  = confirm(WRN_STUDENT_MESSAGE_DELETE);
       if(check == true){	
	         ajax_simple_post_new(achr.href,sContainerId,'');
	         return false;
		   }
  }  
  
  
  /*
* @Added by : Ashutosh Singh
* @date     : 29 Oct 2009
* @Purpose  : To display the category 
*
*/ 
function showCategory(catDivid,anchObj)
{
	resetAnchorClass();
	$(anchObj).className = 'boldelinker';
	$('load-cat').style.display ='';
	setTimeout("$('load-cat').style.display ='none';",1200);
	Effect.BlindDown(catDivid);
	catNum = catDivid.match(/[\d\.]+/g);
	//alert(catNum);
	hideOther(catNum);
	
}
/*
* @Added by : Ashutosh Singh
* @date     : 29 Oct 2009
* @Purpose  : To Hide all the categories except selected one
*
*/
function hideOther(catDivid,anchObj)
{
	for(i=1;i<12;i++)
	{
		liId = 'cat'+i;
		activeLi = 'cat'+catDivid;
		
		if(liId !=  activeLi)
		{			
			 Effect.BlindUp(liId,{Duration:0.01});				
		}		
	}
}
/*
* @Added by : Ashutosh Singh
* @date     : 29 Oct 2009
* @Purpose  : To Display all the categories
*
*/
function viewAllCat(anchObj)
{
	anchObj.className = 'boldelinker';
	resetAnchorClass();
	$(anchObj).className = 'boldelinker';
	$('load-cat').style.display ='';
	setTimeout("$('load-cat').style.display ='none';",1200);
	for(i=1;i<12;i++)
	{		liId = 'cat'+i;	
			 Effect.Appear(liId);				
	
	}
}
/*
* @Added by : Ashutosh Singh
* @date     : 29 Oct 2009
* @Purpose  : To set the default class to all the Faq category links
*
*/
function resetAnchorClass()
{
	for(i=1;i<=12;i++)
		{		liId = 'catlink'+i;	
				$(liId).className='cat-links';				
		
		}
}
/*
* @Added by : Ashutosh Singh
* @date     : 2 Nov 2009
* @Purpose  : To delete the students from My Student grid for a coach  
*
*/
function deleteRow(rowDivId,anchorTag)
{
	//$(rowDivId).fade();alert(rowDivId);
	if(confirm(WRN_STUDENT_DELETE))
	{
	Effect.Fade(rowDivId,{ duration: 5.0, from: 1, to: 0 });
	pars ='';	
	new Ajax.Updater({ success: 'student-rounds-container' },anchorTag.href,{method:'post', parameters: pars,onLoading:function(request){} , onComplete:function(request){checkSessionOut(request.responseText);setTimeout("Effect.Fade('success_messages')",5000)}});		
	}

}

// JavaScript Document
/*******************************************************
Purpose		: sort the round details 
Parameters	: url, container id in which the pop up will imerge
			  and the background layout div id
Created By	: Avesh Srivastava
Created On	: 20-oct-2009
********************************************************/
  function getSort(achr,sContainerId){	 
   
		ajax_simple_post_new(achr.href,sContainerId,'');
  }
  
  
/*******************************************************
Purpose		: sort the round details 
Parameters	: url, container id in which the pop up will imerge
			  and the background layout div id
Created By	: Avesh Srivastava
Created On	: 20-oct-2009
********************************************************/
  function requestForCheck(achr,sContainerId,sBgId){	
      if(parseInt(document.getElementById('totalAvailBal').value) > 25){   
		    m_UpdateCalculatorPopup(achr.href,sContainerId,sBgId,'');
	  }else{
		      alert(WARN_CURRUNT_BAL)
		      return false;		  
		   }
  }  
 /*******************************************************
Purpose		: set possible fairways value in enter round 
			  section  
Parameters	: int page id 
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/
  function m_ValidatePossibleFairways(id)
  {     	
		var iMaxValue = 16; // 14
		var iGetValue = parseInt(document.getElementById(id+'fairways_possible').value);
		if(document.getElementById(id+'holes_played1').checked)
			iMaxValue=8; // 7
		if(iGetValue > iMaxValue)
		{
			alert(ERR_FAIRWAYS_MAX + iMaxValue);
			document.getElementById(id+'fairways_possible').value="";
			return false;
		}
		return true;
    }

/*******************************************************
Purpose		: Validating the fairways hit.  
Parameters	: int page id 
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/

   function setFairwaysHits(id){     
		 var fairPoos      = document.getElementById(id+'fairways_possible');
		 var fairways      = document.getElementById(id+'fairways_number');
		 var fairPoosible  =  parseInt(fairPoos.value);
		 var fairval       =  parseInt(fairways.value);
		 //get the fairWays for 9 holes 18 holes Added by Avesh(SP) --start
		 var iFairwaysPossible = parseInt(document.getElementById(id+'fairways_possible').value);
		 // check if 9 holes has been chosen and value is 16 
		if(document.getElementById(id+'holes_played1').checked)
		 {
		   if(iFairwaysPossible == 16)
		   {
		     var iFairwaysPossible9 = 8;
			 var iFairwaysPossible18 = 16;
		   }
		   else
		   {
		     var iFairwaysPossible9 = 7;
			 var iFairwaysPossible18 = 14;
		   }
		 }
		 else
		 {
		   if(iFairwaysPossible == 8)
		   {
		     var iFairwaysPossible9 = 8;
			 var iFairwaysPossible18 = 16;
		   }
		   else
		   {
		     var iFairwaysPossible9 = 7;
			 var iFairwaysPossible18 = 14;
		   }  
		 }
	  //get the fairWays for 9 holes 18 holes Added by Avesh(SP) --end
		
	   if(document.getElementById(id+'holes_played1').checked){   		      
				if(!fairPoosible){
					  fairPoos.value=iFairwaysPossible9; //7
			     	
				 }
				 
					document.getElementById(id+'par_course').value=36;
			    if(fairval > fairPoosible || fairval > 8){ // 7
					alert("Fairways Hit should not be greater than Fairways Possible");
					fairways.value="";
			   }
         }   		   
		if(document.getElementById(id+'holes_played2').checked){ 
		    if(!fairPoosible){
			       fairPoos.value = iFairwaysPossible18; //14
				   
			}	
			document.getElementById(id+'par_course').value=72;
			if(fairval > fairPoosible || fairval > 16){ //14
					alert("Fairways Hit should not be greater than Fairways Possible")
					fairways.value="";
		    }
		}	
  }
  

/*******************************************************
Purpose		: Determining the possible scrambles.  
Parameters	: int page id 
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/  
 function setPossibleScramble(id)
 {  
         //get the fairWays for 9 holes 18 holes Added by Avesh(SP) --start
		 var iFairwaysPossible = parseInt(document.getElementById(id+'fairways_possible').value);
		 // check if 9 holes has been chosen and value is 8 
		  if(iFairwaysPossible == 8 || iFairwaysPossible == 16)
		  {
				 var iFairwaysPossible9 = 8;
				 var iFairwaysPossible18 = 16;
		   }
		   else
		   {
			    var iFairwaysPossible9 = 7;
				var iFairwaysPossible18 = 14;
		   }
		 //get the fairWays for 9 holes 18 holes Added by Avesh(SP) --end
	
		var val = $(id+'greens_hit').value;				
		 if(document.getElementById(id+'holes_played1').checked)
		 {   
		       //var setVal  =  Math.floor(val/2);
			   holesPlayed = 9;
			   var calcScr  = 9 - val;
			   $(id+'fairways_possible').value = iFairwaysPossible9; // 7
			   
		   }
			if( document.getElementById(id+'holes_played2').checked)
			{
				holesPlayed = 18;
				var calcScr  = 18 - val;   
			   $(id+'fairways_possible').value = iFairwaysPossible18; //14 
		   }	
		   			
			if(val !="")
			{		 		
				if(val > holesPlayed)
				{
					alert('Green hits value should not be greater than '+holesPlayed+'.');	
					$(id+'greens_hit').value="";
					
					$(id+'greens_hit').focus();
					return false;			
				} 			   
				$('scrambles_possible_div').style.display = "block";  	      
				$(id+'possible_scrambles').value = calcScr;  
				
				if($(id+'scrambling').value > calcScr)
				{
					alert('Successful Scrambling should not be greater than Possible Scrambles.');
					$(id+'scrambling').value="";	
				}			 
			}
 } 

/*******************************************************
Purpose		: Validating the scrambles  
Parameters	: int page id , int entval
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/
  function validatePossibleScramble(id,entval){	
      var scrval = parseInt(document.getElementById(id+'possible_scrambles').value);
  		if(entval > scrval){	
				alert('Successful Scrambling should not be greater than Scrambles Possible');	
				document.getElementById(id+'scrambling').value="";
				return false;
		}     
  } 
/*******************************************************
Purpose		: change the Possible scrambles  
Parameters	: int page id , int entval
Created By	: Avesh(SP)
Created On	: 30-Oct-2010
********************************************************/
	function changePossibleScramble(id,entVal)
 	{    
	     var iPossibleScramble = parseInt(document.getElementById(id+'possible_scrambles').value);
		 isNumeric(id+'possible_scrambles',iPossibleScramble);
		 if(document.getElementById(id+'holes_played1').checked)
		 {   
		   if(iPossibleScramble > 9)
		   {
		    alert('Possible Scrambling can not be greater than 9');	
			document.getElementById(id+'possible_scrambles').value="";
			return false;
		   }
		 }
		 else if(document.getElementById(id+'holes_played2').checked)
		 {   
		   if(iPossibleScramble > 18)
		   {
			alert('Possible Scrambling can not be greater than 18');	
			document.getElementById(id+'possible_scrambles').value="";
			return false;
		   }
		 } 
	}
  
/*******************************************************
Purpose		: allow only integer val 
Parameters	: int entval
Created By	: Avesh(SP)
Created On	: 30-Oct-2010
********************************************************/

function isNumeric(id,val)
{
        if(isNaN(val))
		{
		document.getElementById(id).value="";
		return false;
		}
}
  
  
/*******************************************************
Purpose		: Validating the birdies  
Parameters	: int page id 
Created By	: Avesh(SP)
Created On	: 16-oct-2010
********************************************************/
 function m_ValidateBirdies(id)
 {
   var birdiesVal = parseInt(document.getElementById(id+'birdies').value);
   // if 9 holes has been Chosen
   if(document.getElementById(id+'holes_played1').checked)
	{
	 if(birdiesVal > 9)
	 {
	  alert('Birdies should not be greater than 9');	
	  document.getElementById(id+'birdies').value="";
	  return false;
	 }
	}
	else
	{
	 if(birdiesVal > 18) // if 18 holes has been Chosen
	 {
	  alert('Birdies should not be greater than 18');	
	  document.getElementById(id+'birdies').value="";
	  return false;
	 }
	}
 }
	/*******************************************************
	Purpose		: Validating the scrambles  
	Parameters	: int page id
	Created By	: Avesh Srivastava
	Created On	: 26-oct-2009
	********************************************************/ 
  function getFilteredList(id,module){	
		if(module=="" || module==undefined)
			module="game-builders";
        var categoryId = document.getElementById('input_category').value;	
	    var sortBy     = document.getElementById('input_sort_by').value;					
        sUrl           = "index.php?page="+module+"&"+id+"category="+categoryId+"&"+id+"sortby="+sortBy;
		sUrl          += "&showtemplate=false&"+id+"ajaxRequest=true";  		
		if(document.getElementById('currentpage')){
			var page       = document.getElementById('currentpage').value;	
			sUrl          += "&"+id+"page="+page;
		}			
	    ajax_simple_post_new(sUrl,'tipscontainer',''); 
	 }
	 
	 
	 
	 

/*******************************************************
Purpose		: Displaying Tip Details 
Parameters	: str rUrl
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/ 

function showTipDetails(rUrl,fileType)
{
	pars ='';	
	new Ajax.Updater({ success: 'tipDetailDontainer' },rUrl,{method:'post', parameters: pars,onLoading:function(request){} , onComplete:function(request){checkSessionOut(request.responseText);if(fileType=="video"){showVideo();} new Effect.ScrollTo('tipDetailDontainer'); }});	
}
 
 
 /*******************************************************
Purpose		: Displaying video
Parameters	: na
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/ 
 
function showVideo(){
		$f("player", {src: 'uploads/EyelineGolfBlack/js/flowplayer-3.1.5.swf',wmode: 'transparent'}, {  
		controls: { 
			fullscreen: false,      
			scrubber: true, 
			mute: true, 
			volume: true, 
			time: false, 
			background: '#F2EDDD url(controlbar_bg.gif)',  
			timeColor: '#52483D',       
			durationColor: '#000000',      
			progressColor: '#ffffff',      
			progressGradient: 'medium',      
			bufferColor: '#F2EDDD',      
			bufferGradient: 'none',      
			sliderColor: '#ffffff',      
			sliderGradient: 'none',      
			buttonColor: '#D7CCC0',     
			buttonOverColor: '#D7CCC0' 
				} ,
			clip: {
		// stop at the first frame and start buffering
		autoPlay: false,
		autoBuffering: true
		}		
			} 
	);
	
	} 
 
function m_reactivateaccount(formid)
{
	document.reactivatefrm.cntnt01feu_submit.disabled=true;
	if(formid)	
	{
		var params = $(formid).serialize();	
	}
	else
	{
		var params =''	;
	}
	new Ajax.Updater('overlay764',$(formid).action,{method:'post',evalScripts:true, evalJS:true,parameters:params,onLoading:function(request){$('loaderimage').style.display='';},onComplete:function(request){checkSessionOut(request.responseText);$('loaderimage').style.display='none';$('overlay764').scrollIntoView(true);} });
}
function m_activateuser(anchObj,userid)
{
	//javascript:m_UpdatePopup('','overlay400','transparentdiv','');
	$('transparentdiv').style.display ='';
	$('overlay764').style.display ='';
	$('overlay764').style.marginTop = '19.6px'
	$('overlay764').innerHTML ="<div class='loader'></div>";
	new Ajax.Updater('overlay764',anchObj.href,{method:'post',parameters:{userid:userid},onComplete:function(request){checkSessionOut(request.responseText);} });
	scrollEvent('overlay764');
}
  
/*******************************************************
Purpose		: Displaying video
Parameters	: str url ,str divid
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/ 
 
function rateTip(sUrl){
     ajax_simple_post_new(sUrl,'setrating','');
}

function rateTestimonials(sUrl,postVal)
{
   document.getElementById('CountCharId').style.display='';
   var tex = document.getElementById('commentTextArea').value;
   var len = tex.length;
   if(postVal==1)
   {
	vote=gup('cntnt01vote',sUrl);
	document.getElementById('HiddenVoteId').value = vote;
	ajax_simple_post_new(sUrl,'setrating','');
   }
   if(len>0)
   {
	vote=gup('cntnt01vote',sUrl);
	document.getElementById('HiddenVoteId').value = vote;
	ajax_simple_post_new(sUrl,'setrating','');
   }
   else
   {
    document.getElementById('HiddenVoteId').value = 0;
   }
 }

function ShowStaticStar()
{
 document.getElementById('staticId').style.display='';
 document.getElementById('dynamicId').style.display='none';
}

function ShowDynamicStar()
{
 document.getElementById('dynamicId').style.display='';
 document.getElementById('staticId').style.display='none';
  
}


function gup(name,url )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec(url);
  if( results == null )
    return "";
  else
    return results[1];
}



function m_countCharTestiminal()
{
	var count=800;
	document.getElementById('CountCharId').style.display='';
	var tex = document.getElementById('commentTextArea').value;
	var len = tex.length;
	if(len>0)
	{
	  document.getElementById('setrating').style.display='';
	}
	if(len==0)
	{
	  document.getElementById('setrating').style.display='none';
	}
	if(len > count)
	{
	 tex = tex.substring(0,count);
	 document.getElementById('commentTextArea').value=tex;
	 document.getElementById('leftId').innerHTML = 0;
	 return false;
	}
	document.getElementById('leftId').innerHTML = count-len;
}

/*******************************************************
Purpose		: Sorting of the grid wrt statistics
Parameters	: anchor obj, container id
Created By	: Avesh Srivastava
Created On	: 05-Nov-2009
********************************************************/    
function getSortGrid(anchObj,updateContainer){
	
 new Ajax.Updater({ success: 'maincontainer'},anchObj.href,{method:'post',onLoading:function(request){pageLoading('page-box')} , onComplete:function(request){checkSessionOut(request.responseText); pageComplete('page-box');$('page-box').style.display ='none'}});		
}
/*******************************************************
Purpose		: To delete a round
Parameters	: anchor obj, container id
Created By	: Avesh Srivastava (A)
Created On	: 05-Nov-2009
********************************************************/ 
function deleteRound(anchObj,updateContainer){
 if(confirm(WRN_ROUND_DELETE))	
 {
 new Ajax.Updater({ success: 'maincontainer'},anchObj.href,{method:'post',onLoading:function(request){pageLoading('page-box')} , onComplete:function(request){checkSessionOut(request.responseText); setTimeout("$('success_messages').fade()",5000); pageComplete('page-box');$('page-box').style.display ='none'}});		
 }
}  

function deleteNote(anchObj,updateContainer){
 if(confirm(WRN_NOTE_DELETE))	
 {
 new Ajax.Updater({ success: updateContainer},anchObj.href,{method:'post',onLoading:function(request){pageLoading('page-box')},onComplete:function(request){checkSessionOut(request.responseText);setTimeout("$('success_messages').fade()",5000);pageComplete('page-box');$('page-box').style.display ='none'}});		
 }
}  

function m_EditNote(iId)
{
    $('overlay673').style.display ='';
	$('transparentdiv').style.display ='';
	divId = 'overlay673';
	url = 'index.php?page=edit-note&showtemplate=false&ajax=1&noteId='+iId;	
	new Ajax.Updater(divId,url);
	Effect.ScrollTo('overlay673');
}

/*******************************************************
Purpose		: Function to ristrict uesr
Parameters	: htmlObj , charlimit
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/ 
function m_checkLimit(htmlObj,limit)
{
	var val = $(htmlObj.id).value
	if(val.length > limit){
		$(htmlObj.id).value = val.substr(0,limit-1)
		alert(ERR_limit_exceeded.replace('[CHR]',limit));
	}
}

function resetChar()
{
 $('CountCharId').hide();
}

/*******************************************************
Purpose		: Function to ristrict uesr
Parameters	: htmlObj , charlimit
Created By	: Avesh Srivastava
Created On	: 26-oct-2009
********************************************************/ 
function m_countChar(){
	var count=800;
	document.getElementById('CountCharId').style.display='';
	if(document.getElementById('notesText'))
	{
	 var tex = document.getElementById('notesText').value;
	}
	else if(document.getElementById('commentTextArea'))
	{
	 var tex = document.getElementById('commentTextArea').value;
	}
	var len = tex.length;
	if(len > count)
	{
			tex = tex.substring(0,count);
			if(document.getElementById('notesText'))
			{
			 document.getElementById('notesText').value=tex;
			}
			else if(document.getElementById('commentTextArea'))
			{
			 document.getElementById('commentTextArea').value=tex;
			}
	 document.getElementById('leftId').innerHTML = 0;
	 return false;
	}
	document.getElementById('leftId').innerHTML = count-len;
}


function m_countCharEdit(){
	var count=800;
	document.getElementById('CountCharIdEdit').style.display='';
	var tex = document.getElementById('commentTextAreaEdit').value;
	var len = tex.length;
	if(len > count)
	{
	 tex = tex.substring(0,count);
	 document.getElementById('commentTextAreaEdit').value=tex;
	 document.getElementById('leftIdEdit').innerHTML = 0;
	 return false;
	}
	document.getElementById('leftIdEdit').innerHTML = count-len;
}

/*******************************************************
Purpose		: Function sort the grid details
Parameters	: anchor object a, container id
Created By	: Avesh (A)
Created On	: 27-Oct-2009
********************************************************/ 
function getSortGrid(anchObj,updateContainer){
	
 new Ajax.Updater({ success: 'maincontainer'},anchObj.href,{method:'post',onLoading:function(request){pageLoading('page-box')} , onComplete:function(request){ 
																																					checkSessionOut(request.responseText);
																																					 pageComplete('page-box');$('page-box').style.display ='none'}});		
}
/*******************************************************
Purpose		: Function to delete the round details
Parameters	: anchor object a, container id
Created By	: Avesh (A)
Created On	: 1-NOv-2009
********************************************************/ 
function deleteRound(anchObj,updateContainer){
 if(confirm('Are you sure you want to permanently delete this round?'))	
 {
 new Ajax.Updater({ success: 'maincontainer'},anchObj.href,{method:'post',onLoading:function(request){pageLoading('page-box')} , onComplete:function(request){checkSessionOut(request.responseText); setTimeout("$('success_messages').fade()",5000); pageComplete('page-box');$('page-box').style.display ='none'}});		
 }
}  
/*******************************************************
Purpose		: Function to display the round data on click of bars
Parameters	: round id from the swf file
Created By	: Avesh (A)
Created On	: 11-NOv-2009
********************************************************/ 
function m_ShowRoundDetails(roundId){
//uid = $('userIdforGraph').value;

new Ajax.Updater('roundDetailsContainer',$('ajaxlink').href+"&roundId="+roundId,{method:'get',onLoading:function(request){new Effect.BlindUp('roundDetailsContainer')},onComplete:function(request){checkSessionOut(request.responseText);setTimeout("new Effect.BlindDown('roundDetailsContainer')",1000)}});
}
/*******************************************************
Purpose		: Function to display the round data when graph loads
Parameters	: round date from the swf file
Created By	: Avesh (A)
Created On	: 11-NOv-2009
********************************************************/ 
function m_DisplayUserRoundDetails(rounddate)
{
	
new Ajax.Updater('roundDetailsContainer',$('ajaxlink').href+"&roundDate="+rounddate,{method:'get',onLoading:function(request){new Effect.BlindUp('roundDetailsContainer')},onComplete:function(request){checkSessionOut(request.responseText);setTimeout("new Effect.BlindDown('roundDetailsContainer')",1000)}});	
}

///This function make disable the drop down list
function setReactivateStateOption(value){
  
   if(value=="US"){   
         $("selectUsState").style.display="block";	 
		 $("m03851feu_other_input_state").style.display="none";
		$("selectUsState").disabled=false;
		 $("m03851feu_other_input_state").disabled=true;
		 $("m03851feu_other_input_state").value="";		 
   }else{
         var x=$("selectUsState").style.display="none";
		 var x=$("m03851feu_other_input_state").style.display="block";
		 $("selectUsState").disabled=true;
		 $("m03851feu_other_input_state").disabled=false;
		 $("m03851feu_other_input_state").value="";		
   }   
}

///This function make disable the drop down list
function setEditStateOption(value){
  
   if(value=="US"){   
         $("selectUsState").style.display="block";	 
		 $("cntnt01feu_other_input_state").style.display="none";
		$("selectUsState").disabled=false;
		 $("cntnt01feu_other_input_state").disabled=true;
		 $("cntnt01feu_other_input_state").value="";		 
   }else{
         var x=$("selectUsState").style.display="none";
		 var x=$("cntnt01feu_other_input_state").style.display="block";
		 $("selectUsState").disabled=true;
		 $("cntnt01feu_other_input_state").disabled=false;
		 $("cntnt01feu_other_input_state").value="";		
   }   
}
/************************************************************
Thumbnail rotation
***********************************************************/
varCount=0;
varInterval=0;
varInterval2=0;
var arImg= new Array();

function m_GetImgArray()
{    if(arguments.length)
    {
		 for(count=0;count<arguments.length;count++)
		 {
			arImg[count]=arguments[count];
		 }
	}
	 
}
/**
Function : m_SetId 
Description  : For assigning id of selected image
*/
function m_SetId(arg1)
{
	imgId=arg1;
}

function m_AssignImg()
{    
   getSrc = document.images[imgId].src;  // Will get image path for animation   
    lastPos = getSrc.lastIndexOf('/');  // Will remove image name from path
    imgPath = getSrc.substr(0,lastPos)+'/';
   document.images[imgId].src=imgPath+arImg[varCount];
  //window.status =path+arImg[varCount];
}
function m_SetImage()
{
	if(varCount<arImg.length-1)
	{		varCount++; // for setting next image in  array arImg 
	        varInterval2 = setInterval("m_AssignImg()",10);	} 
	else
	{		varCount=0;	
	}
}

function m_ChangeMe()
{ 
  varInterval=setInterval("m_SetImage()",500) 
  // will call function m_setImage in 500 miliseconds and assign interval into varInterval
}
function m_Stop()
{  
    clearInterval(varInterval);
	clearInterval(varInterval2);
	varCount=0; // it will assign first image to canvas
	            // to set last visited frame make it unset;  
}




function validateCode(URL)
{
	//get the value of player option checkbox
	if($('cntnt01feu_input_player_option1'))
	{
		var playerValue = Form.getInputs('cntnt01moduleform_1','radio','cntnt01feu_input_player_option').find(function(radio) { return radio.checked; }).value;
		//prepare params list to post
		params ={'cntnt01feu_input_gift_code':$('cntnt01feu_input_gift_code').value
			 ,'cntnt01feu_charges':$('deductCharge').value
			 ,'cntnt01feu_input_player_option':playerValue
			 }
	}
	//get the value of coach options
	if($('cntnt01feu_input_coach_option1'))
	{
		var coachValue = Form.getInputs('cntnt01moduleform_1','radio','cntnt01feu_input_coach_option').find(function(radio) { return radio.checked; }).value;
		//prepare params list to post
		params ={'cntnt01feu_input_gift_code':$('cntnt01feu_input_gift_code').value
			 ,'cntnt01feu_charges':$('deductCharge').value
			 ,'cntnt01feu_input_coach_option' :coachValue
			 ,'cntnt01feu_input_no_of_memberships':$('no_of_memberships').value 
			 }

	}
	if($('cntnt01feu_input_teacher_option1'))
	{
		var techValue = Form.getInputs('cntnt01moduleform_1','radio','cntnt01feu_input_teacher_option').find(function(radio) { return radio.checked; }).value;
		//prepare params list to post
		params ={'cntnt01feu_input_gift_code':$('cntnt01feu_input_gift_code').value
			 ,'cntnt01feu_charges':$('deductCharge').value
			 ,'cntnt01feu_input_teacher_option' :techValue			 
			 }
	}

	//alert($('cntnt01feu_input_gift_code').value	+ URL);			 
	new Ajax.Updater('overlay764',URL,{method:'get',parameters:params ,onLoading:function(request){},onComplete:function(request){checkSessionOut(request.responseText);$('overlay764').scrollIntoView(true);}});
}
function m_displayValdateBtn()
{
	$('validateCoupBtn').style.display='';
}

//################## SIGN UP PAGE JS ###############

///This function make disable the drop down list
function setStateOption(value,id){
  
   if(value=="US"){   
         document.getElementById("selectUsState").style.display="block";	 
		 document.getElementById(id+"input_other_state").style.display="none";
		 document.getElementById("selectUsState").disabled=false;
		 document.getElementById(id+"input_other_state").disabled=true;	
	         document.getElementById(id+"input_other_state").value="";	
   }else{
         var x=document.getElementById("selectUsState").style.display="none";
		 var x=document.getElementById(id+"input_other_state").style.display="block";
		 document.getElementById("selectUsState").disabled=true;
		 document.getElementById(id+"input_other_state").disabled=false;
                  document.getElementById(id+"input_other_state").value="";		
   }   
}
///This function make disable the drop down list
function makeDisable(){
    var x=document.getElementById("no_of_memberships")
    x.disabled=true
}

///This function make enable the drop down list
function makeEnable(){
    var x=document.getElementById("no_of_memberships")
    x.disabled=false
}

//This function calculate the total cost
function calculateTotalCharge(count,jsPackage,jsMembership){
	var radioGrp = document['forms']['registeruser']['m94bd6input_coach_term_option'];
	if(radioGrp.length >1)
	{
		for(i=0; i < radioGrp.length; i++)
			{
				if (radioGrp[i].checked == true)
				{
					var radioValue = String(radioGrp[i].value);
			    }
	 	}
	}
	else
	{
	   	var radioValue = document.registeruser.m94bd6input_coach_term_option.value;
	}
     CoachAmt = packageAmount(jsPackage,radioValue);
	 PerPlayerAmt = packageAmount(jsMembership,radioValue);   
	 /*****Find which option is being checked***********************/
	 var radioGrp1 = document['forms']['registeruser']['m94bd6input_coach_option'];
	 for(i=0; i < radioGrp1.length; i++)
			{
				if (radioGrp1[i].checked == true)
				{
					var radioValue1 = String(radioGrp1[i].value);
			    }
	 }  
	 if(radioValue1==1)
	 {
	   totalCharge =  parseFloat(CoachAmt); 
	 }
	 else
	 {
	 	var count = document.getElementById("no_of_memberships").value;
	 	totalCharge =  parseFloat(CoachAmt)+(parseFloat(PerPlayerAmt)*count);
		document.getElementById("PerPlayerMembershipId").innerHTML=PerPlayerAmt;
		document.getElementById("CoachAmtId").innerHTML=CoachAmt;
	 }
	 /*****Find which option is being checked***********************/	
	 totalCharge = totalCharge.toFixed(2);
	 document.getElementById("totalcharge").innerHTML="$"+round(totalCharge);	
	 document.getElementById("totalcost").innerHTML="$"+round(totalCharge);
	 document.getElementById("deductCharge").value=round(totalCharge);
}

function setCost(optvalue,deft){
   if(deft=="0"){
      document.getElementById("totalcharge").innerHTML="$"+optvalue;
	  document.getElementById("deductCharge").value=optvalue;	
	 if(optvalue =='5.99'){
	   document.getElementById("term").value="M";
	  }else{
	    document.getElementById("term").value="Y";	  
	  }	 	
    }else if(deft=="1"){	
	 alert('1'); 
	 document.getElementById("totalcharge").innerHTML="$"+optvalue;	
	 document.getElementById("totalcost").innerHTML="0";	
	 document.getElementById("deductCharge").value=optvalue;	
	}else if(deft=="2"){
	alert('2');	
	var count = document.getElementById("no_of_memberships").value;
	 totalCharge = 99.99+(29.99*count);	
	 document.getElementById("totalcharge").innerHTML="$"+round(totalCharge);	
	 document.getElementById("totalcost").innerHTML="$"+round(totalCharge);
	 document.getElementById("deductCharge").value=round(totalCharge);		 
	}
}

function setCostSignup(optvalue,deft,term,jsPackage,jsMembership)
{
  if(deft=="0")
  {
      document.getElementById("totalcharge").innerHTML="$"+optvalue;
	  document.getElementById("deductCharge").value=optvalue;	
	  document.getElementById("term").value=term;
  }
  else if(deft=="1"){	
	 document.getElementById("totalcharge").innerHTML="$"+optvalue;	
	 document.getElementById("totalcost").innerHTML="$"+optvalue;	
	 document.getElementById("deductCharge").value=optvalue;	
	}
    else if(deft=="2"){
	var radioGrp = document['forms']['registeruser']['m94bd6input_coach_term_option'];
	if(radioGrp.length >1)
	{
		for(i=0; i < radioGrp.length; i++)
				{
					if (radioGrp[i].checked == true)
					{
						var radioValue = String(radioGrp[i].value);
					}
		 }
	 }
	 else
	 {
	   	var radioValue = document.registeruser.m94bd6input_coach_term_option.value;
	 }
	 document.getElementById("CoachMembershipId").value=radioValue;
	 CoachAmt = packageAmount(jsPackage,radioValue);
	 PerPlayerAmt = packageAmount(jsMembership,radioValue);   
	 /*****Find which option is being checked***********************/
	 var radioGrp1 = document['forms']['registeruser']['m94bd6input_coach_option'];
	 for(i=0; i < radioGrp1.length; i++)
			{
				if (radioGrp1[i].checked == true)
				{
					var radioValue1 = String(radioGrp1[i].value);
			    }
	 }  
	 if(radioValue1==1)
	 {
	   totalCharge =  parseFloat(CoachAmt); 
	 }
	 else
	 {
	 	var count = document.getElementById("no_of_memberships").value;
	 	totalCharge =  parseFloat(CoachAmt)+(parseFloat(PerPlayerAmt)*count);
		document.getElementById("PerPlayerMembershipId").innerHTML=PerPlayerAmt;
		document.getElementById("CoachAmtId").innerHTML=CoachAmt;
	 }
	 /*****Find which option is being checked***********************/	
	 totalCharge = totalCharge.toFixed(2);
	 document.getElementById("totalcharge").innerHTML="$"+totalCharge;	
	 document.getElementById("totalcost").innerHTML="$"+ totalCharge;
	 document.getElementById("deductCharge").value= totalCharge;
  }	
}

function m_SetMemberShipCost(jsPackage)
{
	  var radioGrp = document['forms']['registeruser']['m94bd6input_coach_term_option'];
	  if(radioGrp)
	  {	
		if(radioGrp.length >1)
		{
			for(i=0; i < radioGrp.length; i++)
			{
						if (radioGrp[i].checked == true)
						{
							var radioValue = String(radioGrp[i].value);
						}
			 }
		 }
		 else
		 {
			var radioValue = document.registeruser.m94bd6input_coach_term_option.value;
		 }
	 }
	CoachAmt = packageAmount(jsPackage,radioValue);	 
	$('memership_id').innerHTML = CoachAmt;
}


//This function calculate the total cost
function calculateTotalChargeReactivate(count,jsPackage,jsMembership,id){
  var radioGrp = document['forms']['reactivatefrm'][id+'feu_input_coach_term_option'];
  if(radioGrp.length >1)	
   {	
	for(i=0; i < radioGrp.length; i++)
			{
				if (radioGrp[i].checked == true)
				{
					var radioValue = String(radioGrp[i].value);
			    }
	 }  
   }
   else
   {
      //var radioValue  = document.reactivatefrm.feu_input_coach_term_option.value;
	  var radioValue = document.reactivatefrm.elements[id+"feu_input_coach_term_option"].value;
   }
     CoachAmt = packageAmount(jsPackage,radioValue);
	 PerPlayerAmt = packageAmount(jsMembership,radioValue);   
	 /*****Find which option is being checked***********************/
	 var radioGrp1 = document['forms']['reactivatefrm'][id+'feu_input_coach_option'];
	 for(i=0; i < radioGrp1.length; i++)
			{
				if (radioGrp1[i].checked == true)
				{
					var radioValue1 = String(radioGrp1[i].value);
			    }
	 }  
	 if(radioValue1==1)
	 {
	   totalCharge =  parseFloat(CoachAmt); 
	 }
	 else
	 {
	 	var count = document.getElementById("no_of_memberships").value;
	 	totalCharge =  parseFloat(CoachAmt)+(parseFloat(PerPlayerAmt)*count);
		document.getElementById("PerPlayerMembershipId").innerHTML=PerPlayerAmt;
		document.getElementById("CoachAmtId").innerHTML=CoachAmt;
	 }
	 /*****Find which option is being checked***********************/	
	 totalCharge = totalCharge.toFixed(2);
	 document.getElementById("totalcharge").innerHTML="$"+round(totalCharge);	
	 document.getElementById("totalcost").innerHTML="$"+round(totalCharge);
	 document.getElementById("deductCharge").value=round(totalCharge);
}


function setCostReactivate(optvalue,deft,term,jsPackage,jsMembership,id)
{
  if(deft=="0")
  {
      document.getElementById("totalcharge").innerHTML="$"+optvalue;
	  document.getElementById("deductCharge").value=optvalue;	
	  document.getElementById("term").value=term;
  }
  else if(deft=="1"){	
	 document.getElementById("totalcharge").innerHTML="$"+optvalue;	
	 document.getElementById("totalcost").innerHTML="$"+optvalue;	
	 document.getElementById("deductCharge").value=optvalue;	
	}
    else if(deft=="2"){
	var radioGrp = document['forms']['reactivatefrm'][id+'feu_input_coach_term_option'];
	if(radioGrp.length >1)
	{
		for(i=0; i < radioGrp.length; i++)
			{
				if (radioGrp[i].checked == true)
				{
					var radioValue = String(radioGrp[i].value);
			    }
	 	}  
	}
	else
	{
		//var radioValue = document.reactivatefrm.id+"feu_input_coach_term_option+".value;
	   var radioValue = document.reactivatefrm.elements[id+"feu_input_coach_term_option"].value;
	}
	 document.getElementById("CoachMembershipId").value=radioValue;
	 CoachAmt = packageAmount(jsPackage,radioValue);
	 PerPlayerAmt = packageAmount(jsMembership,radioValue);   
	 /*****Find which option is being checked***********************/
	 
	 var radioGrp1 = document['forms']['reactivatefrm'][id+'feu_input_coach_option'];
	 for(i=0; i < radioGrp1.length; i++)
			{
				if (radioGrp1[i].checked == true)
				{
					var radioValue1 = String(radioGrp1[i].value);
			    }
	 }  
	 if(radioValue1==1)
	 {
	   totalCharge =  parseFloat(CoachAmt); 
	 }
	 else
	 {
	 	var count = document.getElementById("no_of_memberships").value;
	 	totalCharge =  parseFloat(CoachAmt)+(parseFloat(PerPlayerAmt)*count);
		document.getElementById("PerPlayerMembershipId").innerHTML=PerPlayerAmt;
		document.getElementById("CoachAmtId").innerHTML=CoachAmt;
	 }
	 /*****Find which option is being checked***********************/	
	 totalCharge = totalCharge.toFixed(2);
	 document.getElementById("totalcharge").innerHTML="$"+totalCharge;	
	 document.getElementById("totalcost").innerHTML="$"+totalCharge;
	 document.getElementById("deductCharge").value=totalCharge;
  }	
}


function packageAmount(stPackage,term)
{
	var arPackage=new Array();
	var package = stPackage.split(',');
	var amount; 
    for(i=0;i<package.length;i++)
	{
		var dpackage = package[i].split(':');
	 	key = dpackage[0];
		val = dpackage[1];
	    if(key == term)
		{
		  amount = val;
		  break;	
		}
	}
 return amount;
}

//This function will return a 2 place decimal rounded up or down accordingly: 

function round(num){
num = num.toString();
var split = num.split(".");
var dec = split[1].substr(0,3);
var dec1 = dec.match(/\d{2,2}/);
var dec2 = dec.match(/(\d$)/);
var rounded = (dec1 + "." + dec2[0]);
return split[0] + "." + Math.round(rounded);
} 

function setUserAccountType(value)
{
	if(value =='free')
	{
		new Effect.Fade('billingifoconatiner',{ duration: 1.0 });
		//new Effect.Fade('optionsDiv',{ duration: 1.0 });
		new Effect.Fade('paymentDetails',{ duration: 1.0 });
		new Effect.Fade('ccinfo',{ duration: 1.0 });
		
		$('totalcharge').innerHTML = "$0.00";
	}
	else
	{
		new Effect.Appear('billingifoconatiner',{ duration: 1.0 });
		new Effect.Appear('optionsDiv',{ duration: 1.0 });
		new Effect.Appear('paymentDetails',{ duration: 1.0 });
		new Effect.Appear('ccinfo',{ duration: 1.0 });
		$('totalcharge').innerHTML = $('deductCharge').value;
	}
	$('paidaccountid').value=value;
}



function displayFormFor(URL)
{
	$('transparentdiv').style.display ='';
	$('overlay764').style.display ='';
	$('overlay764').style.marginTop = '19.6px'
	$('overlay764').innerHTML ="<div style='padding-top: 130px;padding-left:35%'><img src='uploads/EyelineGolfBlack/small-loader.gif'/><br/><b>Loading...</b></div>";
	
	new Ajax.Updater('signupuserdetailsonatiner',URL+'&showtemplate=false',{evalScripts:true, evalJS:true,onLoading:function(request){hide_dropdowns("in")},onComplete:function(request){checkSessionOut(request.responseText);new Effect.Appear('signupuserdetailsonatiner');$('transparentdiv').style.display='none';$('overlay764').style.display ='none';hide_dropdowns();}});
}

function validateCodeSignUp(URL,frmobj,idval)
{
	
	formId = frmobj.id;
	radioName = idval+'input_user_type'
	//alert(radioName);
	var userType = Form.getInputs(formId,'radio',radioName).find(function(radio) { return radio.checked; }).value;
	//alert(userType);
	new Ajax.Updater('discountDetails',URL+'&showtemplate=false',{method:'post',evalScripts:true, evalJS:true, parameters:{'cntnt01input_user_type':userType,'cntnt01input_gift_code':$(idval+'input_gift_code').value,'cntnt01input_charges':$('deductCharge').value,'cntnt01coach_term':$('CoachMembershipId').value},onLoading:function(request){$('discountDetails').style.display='none';},onComplete:function(request){checkSessionOut(request.responseText);new Effect.BlindDown('discountDetails');}});
}

function validateCodeUpgrade(URL,frmobj,idval)
{
	
	formId = frmobj.id;
	
	new Ajax.Updater('discountDetails',URL+'&showtemplate=false',{method:'post',evalScripts:true, evalJS:true, parameters:{'cntnt01input_user_type':$('playeroption').value,'cntnt01input_gift_code':$(idval+'input_gift_code').value,'cntnt01input_charges':$('deductCharge').value,'cntnt01coach_term':$('CoachMembershipId').value},onLoading:function(request){$('discountDetails').style.display='none';},onComplete:function(request){checkSessionOut(request.responseText);new Effect.BlindDown('discountDetails');}});
}

function m_changeEmail(linkid)
{
	if($('emailAgain').style.display == 'none')	
	{
		$('cntnt01feu_input_username').style.backgroundColor="";

		$('cntnt01feu_input_username').removeAttribute('readOnly',0);
		$('emailAgain').show();
		linkid.innerHTML = 'Cancel'
		$('validateUsername').value= "1";
				
	}else
	{
		$('cntnt01feu_input_username').style.backgroundColor="#F3F4E1";		
		$('cntnt01feu_input_username').setAttribute('readOnly',1);
		$('cntnt01feu_input_username').setAttribute('class','signup_txt_fd txtfdWidth-176');
		$('cntnt01feu_input_username_again').setAttribute('class','signup_txt_fd txtfdWidth-176');
		linkid.innerHTML = 'Change'
		$('emailAgain').hide();		
		$('cntnt01feu_input_username').value= $('uid').value;
		$('cntnt01feu_input_username_again').value= "";
		$('validateUsername').value= "0";
	}
	
}


function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'appear',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'appear',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
}

function m_BuyNewGiftcodes(sUrl,msg)
{
	
	if(confirm(msg))
	{
	//disableSelectBox('registeruser','none');
	tt=document.getElementsByName('myaccountform');	
	var pars = $(tt[0]).serialize();
	
	new Ajax.Updater('overlay764',sUrl+'&getMyCodes=yes',{ parameters: pars,onLoading:function(request){$('Loading').style.display=''}, onComplete:function(request){checkSessionOut(request.responseText);$('Loading').style.display='none';$('success_messages')?setTimeout('Effect.Fade("success_messages")',5000):setTimeout('Effect.Fade("error_messages")',5500)}}); 
	}
	return false;
}

/*find the number of gift codes chosen--start**********/
function setGiftMembershipPrice(radioValue,price)
{
 	$('MembershipcostId').innerHTML = '$'+ roundNumber(price,2);
	/*find the number of gift codes chosen **********/
	var countGiftcodes = $('giftcodeselected').value;
	totCost = countGiftcodes*price;
	$('totcst').innerHTML = '$'+ roundNumber(totCost,2);
	new Effect.Highlight('totcst',{startcolor:'#D6DE8B',endcolor:'#ffffff'});
}

function calculatePrice(selObj,jsMembership)
{
	if(jsMembership == '')
	{
		$('coscontainer').style.display ='';
	}
	else
	{	
	var radioGrp = document['forms']['myaccountform']['cntnt01input_membership_type'];
	if(radioGrp.length >1)
	{
		for(i=0; i < radioGrp.length; i++)
				{
					if (radioGrp[i].checked == true)
					{
						var radioValue = String(radioGrp[i].value);
					}
		 }
	 }
	 else
	 {
	 var radioValue = document.myaccountform.cntnt01input_membership_type.value;
	 }
	price = packageAmount(jsMembership,radioValue); 
	/*****Find which option is being checked***********************/
	$('coscontainer').style.display ='';
	totCost = selObj.value*price;
	//alert(selObj.value+'*'+price+' = '+roundNumber(selObj.value*price,2));
	$('totcst').innerHTML = '$'+ roundNumber(totCost,2);
	new Effect.Highlight('totcst',{startcolor:'#D6DE8B',endcolor:'#ffffff'});
	}
}
/*find the number of gift codes chosen--end**********/

function m_SortGiftCodes(selObj,container)
{
	new Ajax.Updater(container,selObj.href,{onLoading:function(){{pageLoading('girdLoader')
	//$('girdLoader').style.display ='';
	}},onComplete:function(req){checkSessionOut(req.responseText)}})
		
}
function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
  return newnumber; // Output the result to the form field (change for your purposes)
}
function checkSessionOut(responseText)
{
	if(responseText.indexOf('Your Session has been expired')>=0)																																						
	{
		
		window.location='index.php?action=login';																															
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function showHideFilter(stDivId)
{		
		if($(stDivId).style.display=='none')
		{
			setCookie('ShowHideFilter',1,10);
			$('expandCollpaseId').innerHTML='Collapse';
		 	$(stDivId).show();
		}
		else
		{
			setCookie('ShowHideFilter',0,10);
			$('expandCollpaseId').innerHTML='Expand';
			$(stDivId).hide();
	    }
}
function m_ReArrangeSections(item1_Val,item2_Val,item3_Val)
{
	 // for 123
	  if(item1_Val==1 && item2_Val==2 && item3_Val==3){
		 $('item_1').innerHTML=$('item_1').innerHTML;
		 $('item_2').innerHTML=$('item_2').innerHTML;
		 $('item_3').innerHTML=$('item_3').innerHTML;
		 $('item_1').setAttribute('id','item_1'); 
		 $('item_2').setAttribute('id','item_2'); 
		 $('item_3').setAttribute('id','item_3'); 
		 
	    }
	   // for 132
	   if(item1_Val==1 && item2_Val==3 && item3_Val==2){
		 temp=$('item_3').innerHTML;
		 $('item_1').innerHTML=$('item_1').innerHTML;
		 $('item_3').innerHTML = $('item_2').innerHTML;
		 $('item_2').innerHTML = temp;
		 // set the attribute	
		 $('item_1').setAttribute('id','item_1'); 
		 $('item_3').setAttribute('id','item_2');
		 $('item_2').setAttribute('id','item_3'); 
		 
	    }
	   // for 213
	   if(item1_Val==2 && item2_Val==1 && item3_Val==3){
		 temp=$('item_2').innerHTML;
		 $('item_2').innerHTML=$('item_1').innerHTML;
		 $('item_1').innerHTML=temp;
		 $('item_3').innerHTML=$('item_3').innerHTML;
		 // set the attribute
		 $('item_2').setAttribute('id','item_1'); 	
		 $('item_1').setAttribute('id','item_2'); 
		 $('item_3').setAttribute('id','item_3'); 
	    }	
		
		 // for 231
	   if(item1_Val==2 && item2_Val==3 && item3_Val==1){
		 temp1=$('item_2').innerHTML;
		 temp2=$('item_3').innerHTML;
		
		 $('item_3').innerHTML=$('item_1').innerHTML;
		 $('item_2').innerHTML=temp2;
		 $('item_1').innerHTML=temp1;
	
		 // set the attribute
		 	
		 $('item_3').setAttribute('id','item_1');
		 $('item_2').setAttribute('id','item_3'); 
		 $('item_1').setAttribute('id','item_2'); 
		 
	   }	
		
		 // for 312
	   if(item1_Val==3 && item2_Val==1 && item3_Val==2){
		 temp1=$('item_2').innerHTML;
		 temp2=$('item_3').innerHTML;
		
		 $('item_3').innerHTML=temp1;
		 $('item_2').innerHTML=$('item_1').innerHTML;
		 $('item_1').innerHTML=temp2;
	
		 // set the attribute	
		 $('item_3').setAttribute('id','item_2'); 
		 $('item_2').setAttribute('id','item_1'); 
		 $('item_1').setAttribute('id','item_3'); 
	    }	
		
	  // for 321
	   if(item1_Val==3 && item2_Val==2 && item3_Val==1){
		 temp=$('item_3').innerHTML;
		 $('item_3').innerHTML=$('item_1').innerHTML;
		 $('item_2').innerHTML=$('item_2').innerHTML;
		 $('item_1').innerHTML=temp;
		 // set the attribute	
		 $('item_3').setAttribute('id','item_1');
		 $('item_2').setAttribute('id','item_2'); 
		 $('item_1').setAttribute('id','item_3'); 
	    }	
}

function checkDate(id1,id2)
{
    var str1 = document.getElementById(id1).value;
    var str2 = document.getElementById(id2).value;
	if(str1!="" && str2!="")
	{
	 date1 = str1.split("/");
     date2 = str2.split("/");
     var dt1  = date1[0];
     var mon1 = date1[1];
     var yr1  = date1[2];
	 var dt2  = date2[0];
     var mon2 = date2[1];
     var yr2  = date2[2];
     var date1 = new Date(yr1, mon1, dt1);
     var date2 = new Date(yr2, mon2, dt2);
     if(date2 < date1)
     {
        alert("From date cannot be greater than To date");
        return false;
     } 
    }
}

/**************************************Client side validation for round section *******************************

/*
	* @Added By : Avesh (A)
	* @date     : 1 Sept 2009
	* @purpose  : validates the enter a round form 
	* @param    : prefix of the id
	

	function validateRound(idPreffix)
	{
			
		 parCourse = createId(idPreffix,"par_course");
		 scoreShot =  createId(idPreffix,"score_shot");
		 round_dates =  createId(idPreffix,"round_dates");
		 course_name =  createId(idPreffix,"course_name");
		 fairways_possible =  createId(idPreffix,"fairways_possible");
		 fairways_number=   createId(idPreffix,"fairways_number");
		 greens_hit =   createId(idPreffix,"greens_hit");
		 birdies =  createId(idPreffix,"birdies");
		 scrambling =  createId(idPreffix,"scrambling");
		 three_puts =  createId(idPreffix,"3_puts");
		 total_puts =  createId(idPreffix,"total_puts");
		 out_of_bonds =  createId(idPreffix,"out_of_bonds");
		 water_hazard =  createId(idPreffix,"water_hazard");
		 unpayable_lie =  createId(idPreffix,"unpayable_lie");
		 lost_ball =  createId(idPreffix,"lost_ball");
		 other_penalty =  createId(idPreffix,"other_penalty");
		 four_putts =  createId(idPreffix,"four_putts");
		 error_bunker =  createId(idPreffix,"error_bunker");
		 hit_behind =  createId(idPreffix,"hit_behind");
		 chunked_shot =  createId(idPreffix,"chunked_shot");
		 error_other=  createId(idPreffix,"error_other");
		 notes =  createId(idPreffix,"notes");
		 
		
		 errMsg=new Array();
		 hasError = false;
		
		 if(is_empty(document.getElementById(parCourse).value))
		 {
			hasError = true;
			errMsg.push(ERR_par_course);
			setErrorTip(parCourse,ERR_par_course);
			HightLightField(parCourse);	
		 }
		 else
		 {
		   unHightLightField(parCourse);	
		 }
		
		 if(is_empty(document.getElementById(scoreShot).value))
		 { 
			hasError = true;
			errMsg.push(ERR_score_shot);
			setErrorTip(scoreShot,ERR_score_shot);
			HightLightField(scoreShot);	
		 }
		  else
		 {
		   unHightLightField(scoreShot);	
		 } 
		  if(is_empty(document.getElementById(round_dates).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_round_dates);
			setErrorTip(round_dates,ERR_round_dates);			
			HightLightField(round_dates);	
		 }  
		 else
		 {
		   unHightLightField(round_dates);	
		 }
		 
		 if(is_empty(document.getElementById(course_name).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_course_name);
			setErrorTip(course_name,ERR_course_name);
			HightLightField(course_name);
		 }
		  else
		 {
		   unHightLightField(course_name);	
		 }
		  if(is_empty(document.getElementById(fairways_possible).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_fairways_possible);
			setErrorTip(fairways_possible,ERR_fairways_possible);
			HightLightField(fairways_possible);
		 }
		  else
		 {
		   unHightLightField(fairways_possible);	
		 }
		  if(is_empty(document.getElementById(fairways_number).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_fairways_number);
			setErrorTip(fairways_number,ERR_fairways_number);
			HightLightField(fairways_number);
		 }
		  else
		 {
		   unHightLightField(fairways_number);	
		 }
		  if(is_empty(document.getElementById(greens_hit).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_greens_hit);
			setErrorTip(greens_hit,ERR_greens_hit);
			HightLightField(greens_hit);
		 }
		  else
		 {
		   unHightLightField(greens_hit);	
		 }
		  if(is_empty(document.getElementById(birdies).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_birdies);
			setErrorTip(birdies,ERR_birdies);
			HightLightField(birdies);
		 }
		  else
		 {
		   unHightLightField(birdies);	
		 }
		  if(is_empty(document.getElementById(scrambling).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_scrambling);
			HightLightField(scrambling);
		 }
		  else
		 {
		   unHightLightField(scrambling);	
		 }
		  if(is_empty(document.getElementById(three_puts).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_3_puts);
			HightLightField(three_puts);

		 }
		  else
		 {
		   unHightLightField(three_puts);	
		 }
		  if(is_empty(document.getElementById(total_puts).value ))

		 { 
			hasError = true;
			errMsg.push(ERR_total_puts);
			HightLightField(total_puts);
		 }
		  else
		 {
		   unHightLightField(total_puts);	
		 }
		  if(is_empty(document.getElementById(out_of_bonds).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_out_of_bonds);
			HightLightField(out_of_bonds);
		 }
		  else
		 {
		   unHightLightField(out_of_bonds);	
		 }
		  if(is_empty(document.getElementById(water_hazard).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_water_hazard);
			HightLightField(water_hazard);
		 }
		  else
		 {
		   unHightLightField(water_hazard);	
		 }
		  if(is_empty(document.getElementById(unpayable_lie).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_unpayable_lie);
			HightLightField(unpayable_lie);
		 }
		  else
		 {
		   unHightLightField(unpayable_lie);	
		 }
		  if(is_empty(document.getElementById(lost_ball).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_lost_ball);
			HightLightField(lost_ball);
		 }
		  else
		 {
		   unHightLightField(lost_ball);	
		 }
		  if(is_empty(document.getElementById(other_penalty).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_other_penalty);
			HightLightField(other_penalty);
		 }
		  else
		 {
		   unHightLightField(other_penalty);	
		 }
		  if(is_empty(document.getElementById(four_putts).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_four_putts);
			HightLightField(four_putts);
		 }
		  else
		 {
		   unHightLightField(four_putts);	
		 }
		  if(is_empty(document.getElementById(error_bunker).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_error_bunker);
			HightLightField(error_bunker);
		 }
		  else
		 {
		   unHightLightField(error_bunker);	
		 }
		  if(is_empty(document.getElementById(chunked_shot).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_chunked_shot);
			HightLightField(chunked_shot);
		 }
		  else
		 {
		   unHightLightField(chunked_shot);	
		 }
		 
		  if(is_empty(document.getElementById(error_other).value ))
		 { 
			hasError = true;
			errMsg.push(ERR_error_other);
			HightLightField(error_other);
		 }
		  else
		 {
		   unHightLightField(error_other);	
		 }
		
		
		if(hasError)
		{
			showErrors(errMsg);		
			 return false;
		}
		else
		{
			return true;
		}
	}
	/*
	* @Added By : Avesh (A)
	* @date     : 1 Sept 2009
	* @purpose  : HighLights a input field

	* @param    : id of the input
	
	function HightLightField(fieldId)
	{
		document.getElementById(fieldId).className +=" highlightInput"
	}
		/*
	* @Added By : Avesh (A)
	* @date     : 1 Sept 2009
	* @purpose  : removes the highlight CSS
	* @param    : id of the input
	
	function unHightLightField(fieldId)
	{	
		highlightClass =document.getElementById(fieldId).className;
    
		if(highlightClass.search("highlightInput") != -1)
		{
	
	 		document.getElementById(fieldId).className = replaceSubstring(highlightClass,"highlightInput","");
	   
		}
	}
	/*
	* @Added By : Avesh (A)
	* @date     : 1 Sept 2009
	* @purpose  : creates Id of the element by concating the prefix
	* @param    : prefix id of the input,name of the input
	
	function createId(idPreffix,iname)
	{
		return idPreffix+iname;
	}
	/*
	* @Added By : Avesh (A)
	* @date     : 1 Sept 2009
	* @purpose  : function to replace a string 
	
	function replaceSubstring(inputString, fromString, toString) 
	{
	   // Goes through the inputString and replaces every occurrence of fromString with toString
	   var temp = inputString;
	   if (fromString == "") {
		  return inputString;
	   }
	   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
		  while (temp.indexOf(fromString) != -1) {
			 var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			 var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
			 temp = toTheLeft + toString + toTheRight;
		  }
	   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
		  var midStrings = new Array("~", "`", "_", "^", "#");
		  var midStringLen = 1;
		  var midString = "";
		  // Find a string that doesn't exist in the inputString to be used
		  // as an "inbetween" string
		  while (midString == "") {
			 for (var i=0; i < midStrings.length; i++) {
				var tempMidString = "";
				for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
				if (fromString.indexOf(tempMidString) == -1) {
				   midString = tempMidString;
				   i = midStrings.length + 1;
				}
			 }
		  } // Keep on going until we build an "inbetween" string that doesn't exist
		  // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
		  while (temp.indexOf(fromString) != -1) {
			 var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			 var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
			 temp = toTheLeft + midString + toTheRight;
		  }
		  // Next, replace the "inbetween" string with the "toString"
		  while (temp.indexOf(midString) != -1) {
			 var toTheLeft = temp.substring(0, temp.indexOf(midString));
			 var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
			 temp = toTheLeft + toString + toTheRight;
		  }
	   } // Ends the check to see if the string being replaced is part of the replacement string or not
	   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

	/*
	* @Added By : Avesh (A)
	# @date     : 1 Sept 2009
	# @purpose  : function to high light the input fields having errror 
	
	function showErrors(errArr)
	{
/*		// if all error messages should display at the top uncomment the lines 
		errString = "<ul>"
		 for(i =0 ; i< errArr.length; i++ )
		 { 
			 errString += "<li>"+errArr[i]+"</li>";
		 }
		 
		 errString += "</ul>";
		errString = ERR_CORRECT;
		 document.getElementById('error_messages').innerHTML = errString;
		 document.getElementById('error_messages').style.display = "";
		 
	}
	
	/*
	* @Added By : Avesh (A)
	* @date     : 1 Sept 2009
	* @purpose  : function to dipslay the error message on tooltip.
	
	function displayError(inputId,errormsg)
	{
		if( document.getElementById(inputId).className == "highlightInput")
		{
		  
		}		
	}
	
	function setErrorTip(elemId,errMsg)
	{
		document.getElementById(elemId).setAttribute('onmouseover', 'Tip(\''+ errMsg +'\')');
		document.getElementById(elemId).setAttribute('onmouseout', 'UnTip()');	
	}
	
	**********************************************************************************************************************/

