﻿	<!-- Begin
	/* This script and many more are available free online at
	The JavaScript Source!! http://javascript.internet.com
	Created by: Ultimater :: http://ultimiacian.tripod.com/
	Add this snippet to the very beginning of your script. */

	if(!document.getElementById){
	if(document.all)
	document.getElementById=function(){
		if(typeof document.all[arguments[0]]!="undefined")
		return document.all[arguments[0]]
		else
		return null
	}
	else if(document.layers)
	document.getElementById=function(){
		if(typeof document[arguments[0]]!="undefined")
		return document[arguments[0]]
		else
		return null
	}
	}
	// End -->
	
function InitRollOverImages() {

	browserName=navigator.appName;
	browserVer=parseInt(navigator.appVersion);
	
	if (browserVer > 2) {
	
	Hdr_Home_R = new Image(75, 37);
	Hdr_Home_R.src= _DDFS + "images/Hdr_Home_R.gif";
	Hdr_Home_O = new Image(75, 37);
	Hdr_Home_O.src=_DDFS + "images/Hdr_Home_O.gif";	
	
	Hdr_FCD_R = new Image(132, 37);
	Hdr_FCD_R.src= _DDFS + "images/Hdr_FCD_R.gif";
	Hdr_FCD_O = new Image(132, 37);
	Hdr_FCD_O.src= _DDFS + "images/Hdr_FCD_O.gif";		
	
	Hdr_PHP_R = new Image(160, 37);
	Hdr_PHP_R.src= _DDFS + "images/Hdr_PHP_R.gif";
	Hdr_PHP_O = new Image(160, 37);
	Hdr_PHP_O.src= _DDFS + "images/Hdr_PHP_O.gif";			
	
	Hdr_Gear_R = new Image(229, 37);
	Hdr_Gear_R.src= _DDFS + "images/Hdr_Gear_R.gif";
	Hdr_Gear_O = new Image(229, 37);
	Hdr_Gear_O.src= _DDFS + "images/Hdr_Gear_O.gif";		
	
	Hdr_Foundation_R = new Image(149, 37);
	Hdr_Foundation_R.src= _DDFS + "images/Hdr_Foundation_R.gif";
	Hdr_Foundation_O = new Image(149, 37);
	Hdr_Foundation_O.src= _DDFS + "images/Hdr_Foundation_O.gif";			
	
	Home_R = new Image(73, 37);
	Home_R.src=_DDFS + "images/Home_R.gif";
	Home_O = new Image(73, 37);
	Home_O.src=_DDFS + "images/Home_O.gif";
		
	TheFCDWay_R = new Image(126, 37);
	TheFCDWay_R.src= _DDFS + "images/TheFCDWay_R.gif";
	TheFCDWay_O = new Image(126, 37);
	TheFCDWay_O.src= _DDFS + "images/TheFCDWay_O.gif";	
						
	Teams_R = new Image(76, 37);
	Teams_R.src= _DDFS + "images/Teams_R.gif";
	Teams_O = new Image(76, 37);
	Teams_O.src= _DDFS + "images/Teams_O.gif";	
	
	News_R = new Image(69, 37);
	News_R.src= _DDFS + "images/News_R.gif";
	News_O = new Image(69, 37);
	News_O.src= _DDFS + "images/News_O.gif";	

	Camps_R = new Image(148, 37);
	Camps_R.src= _DDFS + "images/Camps_R.gif";
	Camps_O = new Image(148, 37);
	Camps_O.src= _DDFS + "images/Camps_O.gif";	
	
	Tournaments_R = new Image(123, 37);
	Tournaments_R.src= _DDFS + "images/Tournaments_R.gif";
	Tournaments_O = new Image(123, 37);
	Tournaments_O.src= _DDFS + "images/Tournaments_O.gif";	
	
	Pyramid_5_R = new Image(174, 24);
	Pyramid_5_R.src= _DDFS + "images/Pyramid_5_R.gif";
	Pyramid_5_O = new Image(174, 24);
	Pyramid_5_O.src= _DDFS + "images/Pyramid_5_O.gif";		
	
	Pyramid_4_R = new Image(174, 27);
	Pyramid_4_R.src= _DDFS + "images/Pyramid_4_R.gif";
	Pyramid_4_O = new Image(174, 27);
	Pyramid_4_O.src= _DDFS + "images/Pyramid_4_O.gif";			
	
    Pyramid_3_R = new Image(174, 27);
	Pyramid_3_R.src= _DDFS + "images/Pyramid_3_R.gif";
	Pyramid_3_O = new Image(174, 27);
	Pyramid_3_O.src= _DDFS + "images/Pyramid_3_O.gif";			

    Pyramid_2_R = new Image(174, 27);
	Pyramid_2_R.src= _DDFS + "images/Pyramid_2_R.gif";
	Pyramid_2_O = new Image(174, 27);
	Pyramid_2_O.src= _DDFS + "images/Pyramid_2_O.gif";			

    Pyramid_1_R = new Image(174, 27);
	Pyramid_1_R.src= _DDFS + "images/Pyramid_1_R.gif";
	Pyramid_1_O = new Image(174, 27);
	Pyramid_1_O.src= _DDFS + "images/Pyramid_1_O.gif";			

	DashImg = new Image(5, 9);
	DashImg.src= _DDFS + "images/SideNavDash.gif";
	ClearImg = new Image(5, 9);
	ClearImg.src= _DDFS + "images/Clear.gif";
	
    }
}
	
	function Dash_Roll(imgName) {
		var el = document.getElementById(imgName);
		if (el != null) {
				el.src = DashImg.src;
		}
	}
		
	function Dash_UnRoll(imgName) {
		var el = document.getElementById(imgName);
		if (el != null) {
				el.src = ClearImg.src;
		}

	}		
	
	function RollIt(imgName) {
		var el = document.getElementById(imgName);
		el.src = eval(imgName + "_O.src");
		
		}
	
	function UnRollIt(imgName) {
		var el = document.getElementById(imgName);
		el.src = eval(imgName + "_R.src");
	}
	
function ValidateEnewsSignUp() {

    var el;
    
    el = FindMyControl('txtENews_Name');
    if (el.value.length <= 1) { alert('You must provide a valid name in order to sign up for our Email Updates.'); return; }
    el = FindMyControl('txtENews_Email');
    if (validEmail(el.value) == false) { alert('You must provide a valid email address in order to sign up for our Email Updates.'); return; }
    el = FindMyControl('hdAction');
    el.value = 'Email Updates';
    document.forms[0].submit();
    
}

function ShowPhoto(POA_ID) {

    var el;
    var html;
    
    el = document.getElementById('imgPA_Main_Horizontal');
    el.src = 'GetFileP.aspx?Type=Photo&POA_ID=' + POA_ID;
    
}

function validEmail(email) 
{
     var invalidChars = " /:,;"; // NOTE - first char is a SPACE

     for (i = 0;  i < invalidChars.length; i++) { // does it contain any invalid characters?
          var badChar = invalidChars.charAt(i);
          if (email.indexOf(badChar, 0) > -1) return false;
     }

     var atPos = email.indexOf("@", 1);  // there must be one "@" symbol
     if (atPos == -1) return false;
     // and only one "@" symbol
     if (email.indexOf("@", atPos + 1) != -1) return false;

     periodPos = email.indexOf(".", atPos);
     // and at least one "." after the "@"
     if (periodPos == -1) return false;
     // must be at least 2 characters after the "."
     if (periodPos + 3 > email.length)  return false;

     return true;
}

function PositionLayer(LayerName, OffSetX, OffSetY) {

	var imgX;
	var imgY;
	var MyScrollTop;
    var el;
           
		
   	if (OffSetX == 450 ) { OffSetX = 325 }		// correction
	if (navigator.appVersion.indexOf('MSIE 7') > -1) { OffSetY = OffSetY + 20 } // correct for IE 7
	
	// find the center of the window
	
	// NOTE: The lines below are only required if the application design is centered, otherwise don't adjust
	//imgX = (document.body.clientWidth / 2);	
	//imgX = imgX - OffSetX

	imgX = OffSetX
	imgY = OffSetY;
	// adjust for scroll position
	if (document.documentElement && !document.documentElement.scrollTop)   // IE6 +4.01 but no scrolling going on
        { MyScrollTop = 0 }    
    else if (document.documentElement && document.documentElement.scrollTop)  // IE6 +4.01 and user has scrolled
        { MyScrollTop = document.documentElement.scrollTop }   
    else if (document.body && document.body.scrollTop) // IE5 or DTD 3.2
        { MyScrollTop = document.body.scrollTop }   
	imgY = imgY + MyScrollTop;
	// make sure they are integers
	imgX = parseInt(imgX);
	imgY = parseInt(imgY);
	
	//el = FindMyControl(LayerName);
	el = document.getElementById(LayerName);
	if ( el != false ) {
	    el.style.left = imgX + 'px'; 
	    el.style.top = imgY + 'px';
	}

  
}

function CancelLayer(LayerName) {

    var f;
    var el;
    
	el = document.getElementById(LayerName);
	if ( el != null ) {
		el.style.visibility = 'hidden';
    }    

}		

function SetPageHeight() {

    var el;
    var t,left1,top1;
    var left2,top2;
    var diff;
    
    el = document.getElementById('imgBottomLeft');
    t = findPos(el);
    left1 = parseInt(t[0]);
    top1 = parseInt(t[1]);    
           
    el = document.getElementById('imgBottomCopy');
    if ( el != null ) {
        t = findPos(el);
        left2 = parseInt(t[0]);
        top2 = parseInt(t[1]);    
        
        if ( top2 < top1 ) {
            el = document.getElementById('divBodySpacer');
            diff = top1 - top2
            if ( diff > 0 ) { el.style.height = diff + 'px'; }
        }
    } 
    

}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function FindMyControl(MyID) {

	var frmElements,i,t,ctl;
		
	// Since the use of master pages mangles the names of child controls, we need a method 
	// of searching through the form elements and returning a reference to the control we are 
	// looking for that control by the name we know it as instead of the name ASP.Net creates.
	// First scan through all of the input elements and look for our control

	var tempMyID;
	tempMyID = MyID + '***';
    frmElements=document.getElementsByTagName('input');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t + '***';
        //alert(t + ' - ' + tempMyID);
        if (t.indexOf(tempMyID) > -1 )
            { return frmElements[i] }
    }   
    
   // Still not found, scan through all of the select elements
    frmElements=document.getElementsByTagName('select');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    } 
   
   // Still not found, scan through all of the textarea elements
    frmElements=document.getElementsByTagName('textarea');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }   
   
   // Still not found, scan through all of the iframe elements
    frmElements=document.getElementsByTagName('td');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }         
   
   // Still not found, scan through all of the span elements
    frmElements=document.getElementsByTagName('div');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    } 
    
   // Still not found, scan through all of the iframe elements
    frmElements=document.getElementsByTagName('img');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    } 
    
   // Still not found, scan through all of the span elements
    frmElements=document.getElementsByTagName('table');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    } 
          
    
   // Still not found, scan through all of the iframe elements
    frmElements=document.getElementsByTagName('iframe');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }       
   
   // Still not found, scan through all of the span elements
    frmElements=document.getElementsByTagName('span');
    for(i in frmElements)
    {
        t = String(frmElements[i].id); 
        t = '_' + t;
        if (t.indexOf(MyID) > -1 )
            { return frmElements[i] }
    }  
   
  return false;  

}

var _DDFS;

function SetDDFS(DDFS) {
    _DDFS = DDFS;
    InitRollOverImages();
}

function NewWin(Link) {
	var w = 	window.open(Link, 'NewWin');
	w.focus();
}			

function MustAgree() {

    var el;
    
    el = FindMyControl('chkAgree');
    if ( el.checked == false ) {
        alert('You must check that you agree to the terms outlined above in order to continue.');
        }
    else {
        location.href = 'Registration.aspx?Mode=RecurringAgree'
    }
}

function MustRecurringAgree() {

    var el;
    
    el = FindMyControl('chkRecurringAgree');
    if ( el.checked == false ) {
        alert('You must check that you agree to the recurring billing terms outlined above in order to continue.');
        }
    else {
        location.href = 'Registration.aspx?Mode=Capture'
    }
    
}

function ValidateBilling() {

    var el;
    var CN;
    var AN;
    
    el = FindMyControl('Billing_Address');
    if ( el.value.length <= 2 ) { alert('You must provide a valid billing address in order to continue.'); return };
    el = FindMyControl('Billing_City');
    if ( el.value.length <= 2 ) { alert('You must provide a valid billing city in order to continue.'); return };    
    el = FindMyControl('Billing_PostalCode');
    if ( el.value.length <= 2 ) { alert('You must provide a valid billing zip code in order to continue.'); return };
    
    el = FindMyControl('CC_Number');
    CN = el.value;

    el = FindMyControl('Players_ECP_AccountNumber');
    AN = el.value;
    
    if ( CN.length <= 2 && AN.length <= 2) { alert('You must provide either credit card information or electronic check information in order to continue.'); return };
    
    if ( CN.length > 2 ) {
        if ( CN.length != 15 && CN.length != 16 ) { alert('The credit card number you provided does not appear to be the right length.  Please double check making sure to not enter spaces.'); return };
        el = FindMyControl('Players_CC_NameOnCard');
        if ( el.value.length <= 2 ) { alert('You must provide a name from the credit card in order to continue.'); return };        
        el = FindMyControl('CC_SecCode');
        if ( el.value.length <= 2 ) { alert('You must provide a valid security code from the credit card in order to continue.'); return };        
    }
    else {
        el = FindMyControl('ECP_RoutingNumber');
        if ( el.value.length != 9 ) { alert('The routing number number you provided does not appear to be the right length.  It should have 9 digits. Please double check making sure to not enter any spaces.'); return };
   }

    el.form.submit();   
    
}
