var nm=navigator.appName+navigator.appVersion;
var ap=navigator.userAgent;
var browserOK = false;

if( (nm.indexOf("Netscape5")!=-1) )
	browserOK = true;
else if( document.all != null )	
	browserOK = true;

if( browserOK ) 
   var pics = new Array();
else
   document.location="browser.php";
   
/******** Form Email Validation ***********/
function m_sfcon (u) {
pre = "mail";
url = pre + "to:" + u;
document.location.href = url + "@NativeSpiritEntertainment.com";
}
function validate_email( theControl )
{
    if ( theControl.value == "" || theControl.value.length <= 0 )
    {
		alert("Your email address must be filled in correctly. Please" + " check the prefix and '@' sign.");
		theControl.focus();
        return false;
    }
    var reEmail = /^.+\@.+\..+$/
    var holderValue;
    var thisValue = theControl.value;
    // Check for e-mail addresses from ISPs and other sources that have been consistently
    // entered incorrectly.  If detected, correct the situation.
    if( (thisValue.substring(thisValue.length - 4, thisValue.length).toLowerCase()) == '@aol' ||
        (thisValue.substring(thisValue.length - 4, thisValue.length).toLowerCase()) == '@msn' ||
        (thisValue.substring(thisValue.length - 6, thisValue.length).toLowerCase()) == '@yahoo' ||
        (thisValue.substring(thisValue.length - 6, thisValue.length).toLowerCase()) == '@lycos' ||
        (thisValue.substring(thisValue.length - 7, thisValue.length).toLowerCase()) == '@excite' ||
        (thisValue.substring(thisValue.length - 10, thisValue.length).toLowerCase()) == '@altavista' ||
        (thisValue.substring(thisValue.length - 11, thisValue.length).toLowerCase()) == '@compuserve' ||
        (thisValue.substring(thisValue.length - 8, thisValue.length).toLowerCase()) == '@prodigy' ||
        (thisValue.substring(thisValue.length - 8, thisValue.length).toLowerCase()) == '@hotmail' ||
        (thisValue.substring(thisValue.length - 9, thisValue.length).toLowerCase()) == '@netscape' )
	{
		holderValue = thisValue.concat('.com');
		thisValue = holderValue;
		theControl.value = thisValue;
	}
    if( (thisValue.substring(thisValue.length - 5, thisValue.length).toLowerCase()) == '@home' )
	{
		holderValue = thisValue.concat('.net');
		thisValue = holderValue;
		theControl.value = thisValue;
	}
    // Now check the actual value of the e-mail address for validity.
    var flagFirstCheck = (theControl.value.length < 6) ||
						 (thisValue.indexOf('@') == -1) ||
						 (thisValue.indexOf('.') == -1) ||
						 (thisValue.indexOf('@',(thisValue.indexOf('@')+1)) != -1) ||
						 ((thisValue.indexOf('.')+1) == thisValue.length) ||
						 ((thisValue.indexOf('@')+1) == thisValue.length)
	var flagSecondCheck = reEmail.test(thisValue)
    if ( flagFirstCheck || !flagSecondCheck )
    {
		alert("Your email address seems to be incorrect. Please" + " check the prefix and '@' sign.");
		theControl.focus();
        return false;
    }
    else
        return true;
}

/********* Show hidden layers **********/

function showHideLayers() 
{
	var magicMX = 0;
	var i, visStr, args, theObj;
	args = showHideLayers.arguments;
	if( (document.all)&&(ap.indexOf("Opera")==-1) )
	{ 
		availW = document.body.clientWidth; 
		availH = document.body.clientHeight; 
	} 
	else
	{ 
		availW = innerWidth; 
		availH = innerHeight; 
	} 
	magicMX = availW / 2 - 398;

	//with arg triples (objNS,objIE,visStr)
   	for( i=0; i < (args.length-2); i+=3 ) 
   	{
		visStr   = args[i+2];
		if(navigator.appName == 'Netscape')
		{
			if (visStr == 'show') 
				visStr = 'visible'; //convert vals
			if (visStr == 'hide') 
				visStr = 'hidden';
			theObj = eval(args[i]);
			if (theObj)
			{
				if(magicMX >= 0)
				{
					if(theObj.id == "events")
						theObj.style.left = -2 + magicMX;
					if(theObj.id == "dancers")
						theObj.style.left = 116 + magicMX;
					if(theObj.id == "photos")
						theObj.style.left = 245 + magicMX;
					if(theObj.id == "press")
						theObj.style.left = 376 + magicMX;
					if(theObj.id == "danceclass")
						theObj.style.left = 490 + magicMX;						
				}
	            theObj.style.visibility = visStr;
			}	  
		} //IE
		else if ( document.all != null )
		{ 
			if (visStr == 'show') 
				visStr = 'visible'; //convert vals
			if (visStr == 'hide') 
				visStr = 'hidden';
			theObj = eval(args[i+1]);
			if (theObj) 
			{
				if(magicMX >= 0)
				{
					if(theObj.id == "events")
						theObj.style.left = 8 + magicMX;
					if(theObj.id == "dancers")
						theObj.style.left = 126 + magicMX;
					if(theObj.id == "photos")
						theObj.style.left = 255 + magicMX;
					if(theObj.id == "press")
						theObj.style.left = 386 + magicMX;
					if(theObj.id == "danceclass")
						theObj.style.left = 500 + magicMX;														
				}
				theObj.style.visibility = visStr;
			}
		} 
	}
}

/******* linup cris ***********/

function lineupcris(pict)
{
    var magicCRIS = 0;
	if( document.all )
	{ 
		availW = document.body.clientWidth; 
		availH = document.body.clientHeight; 
	} 
	else 
	{ 
		availW = innerWidth; 
		availH = innerHeight; 
	}
	if( availW > 796 ) 	
		magicCRIS = (availW / 2) - 398 - 204;
	//NETSCAPE 6+
	if( navigator.appName == 'Netscape' )
	{
		if( magicCRIS >= -204 )
			document.getElementById(pict).style.left = magicCRIS - 10;						
	} //IE
	else if( document.all != null ) 
	{ 
		if( magicCRIS >= -204 )
		{
			document.all[pict].style.visibility = "visible";
			document.all[pict].style.left = magicCRIS;
		}
		else
			document.all[pict].style.visibility = "hidden";													
	} 
}

/**************  Preload  ***************/

var objCount = 0; // number of (changing) images on web-page
function preload( name, first, second, third ) 
{
	if( browserOK ) 
	{
		pics[objCount] = new Array(3);
		pics[objCount][0] = new Image();
		pics[objCount][0].src = first;
		pics[objCount][1] = new Image();
		pics[objCount][1].src = second;
		pics[objCount][2] = name;
		if( third != null )
		{
			pics[objCount][3] = new Image();
			pics[objCount][3].src = third;
		}
		objCount++;
	}
}

/***************** ON ******************/

function on( name )
{
	if( browserOK ) 
	{
		for( i = 0; i < objCount; i++ ) 
		{
			if( document.images[pics[i][2]] != null )
			{ 
				if( name != pics[i][2] ) 
				{ 
					if( pics[i][0].complete )
						document.images[pics[i][2]].src = pics[i][0].src;
				} 
				else // show the second image because cursor moves across this image
				{
					if (pics[i][1].complete)
						document.images[pics[i][2]].src = pics[i][1].src;
				}  
			}
		}
	}
}

/***************** ON 3 images ******************/

function on3( name )
{
	if( browserOK ) 
	{
		for( i = 0; i < objCount; i++ ) 
		{
			if( document.images[pics[i][2]] != null )
			{ 
				if( name != pics[i][2] ) 
				{ 
					if( pics[i][0].complete )
						document.images[pics[i][2]].src = pics[i][0].src;
				} 
				else // show the second image because cursor moves across this image
				{
					if (pics[i][1].complete)
						document.images[pics[i][2]].src = pics[i][3].src;
				}  
			}
		}
	}
}

/***************** OFF ******************/

function off()
{
   if( browserOK ) 
   {
      for( i = 0; i < objCount; i++ ) // set back all pictures
      {
         if( document.images[pics[i][2]] != null )
         {
            if( pics[i][0].complete )
               document.images[pics[i][2]].src = pics[i][0].src;
         }
      }
   }
}

function menuoff()
{
	if( browserOK ) 
	{
		document.nav1.src = "images/nav1a.jpg";
		document.nav2.src = "images/nav2a.jpg";
		document.nav3.src = "images/nav3a.jpg";
		document.nav4.src = "images/nav4a.jpg";
		document.nav5.src = "images/nav5a.jpg";
		document.nav6.src = "images/nav6a.jpg";
	}
}

/************* Form Validation ***************/

function checkLen(Target) 
{
	StrLen = Target.value.length;
	document.GBSubmit.charstyped.value = StrLen;
}

/************* Form Validation ***************/

function FValidateControl( control, prompt ) 
{
	if (control.value=="") 
	{
		alert("The " + prompt +" field is a required field, and it must be filled in before your form can be sent to our server.");
		control.focus();
		return false; 
	}
	return true; 
}

/************* Form Validation ***************/
function paymentMethod(type)
{
	document.forms[0].paymentmethod.value=type;
}

function accountType(type)
{
	document.forms[0].accounttype.value=type;
}

function TJOFVerify( form ) 
{
	if (!FValidateControl(form.x_First_Name,'First Name')) return false;
	if (!FValidateControl(form.x_Last_Name,'Last Name')) return false;
	if (!FValidateControl(form.x_Address,'Address')) return false;
	if (!FValidateControl(form.x_City,'City')) return false;
	if (!FValidateControl(form.x_State,'State')) return false;
	if (!FValidateControl(form.x_Zip,'Zip Code')) return false;
	if (!FValidateControl(form.x_Phone,'Phone Number')) return false;
	if (!FValidateControl(form.x_Country,'Country')) return false;
	if (!validate_email(form.x_Email)) return false;
	if( form.paymentmethod.value == "CC" )
	{
		if (!FValidateControl(form.x_Card_Num,'Credit Card Number')) return false;
		if (!FValidateControl(form.x_Exp_Date,'Expiration Date')) return false;
	}
	else if( form.paymentmethod.value == "ECHECK" )
	{
		if (!FValidateControl(form.x_bank_name,'Bank Name')) return false;
		if (!FValidateControl(form.x_bank_acct_name,'Name On Account')) return false;	
		if (!FValidateControl(form.x_Bank_ABA_Code,'Routing Number')) return false;
		if (!FValidateControl(form.x_Bank_Acct_Num,'Account Number')) return false;
	}
	return true;
}

/*************** Check Username ****************/

function checkUsername( strng ) 
{
	if( strng == "" ) 
	{
		alert("You didn't enter a User Name.");
		return false;
	}
	var illegalChars = /\W/; // allow only letters and numbers and underscores
	
	if( (strng.length < 4) || (strng.length > 10) ) 
	{
		alert("Your user name must be between 4 and 10 characters length.");
		return false;
	}
	else if( illegalChars.test(strng) ) 
	{
		alert("Your user name must contain only letters, numbers and underscores.");
		return false;
	} 
	return true;    
} 

/*************** Check Password ****************/

function checkPassword( strng ) 
{
	if( strng == "" ) 
	{
		alert("You didn't enter a password.");
		return false;
	}
	var illegalChars = /[\W_]/; // allow only letters and numbers
	
	if( (strng.length < 6) || (strng.length > 8) ) 
	{
		alert("Your password must be between 6 and 8 characters length.");
		return false;
	}
	else if( illegalChars.test(strng) ) 
	{
		alert("Your password must contain only letters and numbers.");
		return false;
	} 
	return true;    
} 

/*************** Cookies Enabled *************/

function cookies_enabled()
{
   document.cookie = "Enabled=true";
   var cookieValid = document.cookie;
   
   // if retrieving the VALUE we just set actually works 
   // then we know cookies enabled
   if (cookieValid.indexOf("Enabled=true") != -1)
      return true;
   else
      return false;
}

/*********** Strip Non Numbers ****************/

function stripNonNumbers (InString)  {
	OutString="";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar=InString.substring (Count, Count+1);
		Strip = false;
		CharString="0123456789";
		for (Countx = 0; Countx < CharString.length; Countx++) {
			StripThis = CharString.substring(Countx, Countx+1)
			if (TempChar == StripThis) {
				Strip = true;
				break;
			}
		}
		if (Strip)
			OutString=OutString+TempChar;
	}
	return (OutString);
}	

/************* Image Preloads ***************/
preload("navi1_main", "images/navi1a_main.jpg", "images/navi1b_main.jpg");
preload("navi1", "images/navi1a.jpg", "images/navi1b.jpg");
preload("navi2", "images/navi2a.jpg", "images/navi2b.jpg");
preload("navi3", "images/navi3a.jpg", "images/navi3b.jpg");
preload("navi4", "images/navi4a.jpg", "images/navi4b.jpg");
preload("navi5", "images/navi5a.jpg", "images/navi5b.jpg");
preload("navi6", "images/navi6a.jpg", "images/navi6b.jpg");

/********** Check Cookies ***************/

if( !cookies_enabled() ) 
   alert("Please enable session cookies in your internet browser security setting.\nYou may need to resart your browser to insure the new settings have taken effect.");




