/*
	Global Javascript Document
	Created By: Arthur Chang

*/

function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter a 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}
//  End -->


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Shadowbox.init();

//-----------------------
//  Station Finder
//-----------------------

var stationFinderDropdown = [
	"Alameda, CA",
    "Alamo, CA",
	"Albany, CA",
	"Antioch, CA",
	"Bay Point, CA",
	"Berkeley, CA",
	"Brentwood, CA",
	"Byron, CA",
	"Castro Valley, CA",
	"Canyon, CA",
	"Clayton, CA",
	"Concord, CA",
	"Crockett, CA",
	"Danville, CA",
	"Discovery Bay, CA",
	"Dublin, CA",
	"El Cerrito, CA",
	"El Sobrante, CA",
	"Emeryville, CA",
	"Fremont, CA",
	"Hayward, CA",
	"Hercules, CA",
    "Kensington, CA",
	"Knightsen, CA",
	"Lafayette, CA",
	"Livermore, CA",
	"Martinez, CA",
	"Moraga, CA",
	"Newark, CA",
	"Oakland, CA",
	"Oakley, CA",
	"Orinda, CA",
	"Rodeo, CA",
	"Piedmont, CA",
	"Pinole, CA",
	"Pittsburg, CA",
	"Pleasant Hill, CA",
	"Pleasanton, CA",
	"Richmond, CA",
	"San Leandro, CA",
    "San Lorenzo, CA",
	"San Pablo, CA",
	"San Ramon, CA",
	"Sunol, CA",
	"Union City, CA",
	"Walnut Creek, CA"
];

var UTDropDown = [
"Bountiful, UT"
, "West Bountiful, UT"
, "Centerville, UT"
, "Clearfield, UT"
, "Farmington, UT"
, "Kaysville, UT"
, "Layton, UT"
, "North Salt Lake, UT"
, "Cottonwood Heights, UT"
, "Draper, UT"
, "Herriman, UT"
, "Holladay, UT"
, "Midvale, UT"
, "Murray, UT"
, "Salt Lake City, UT"
, "Sandy, UT"
, "West Jordan, UT"
, "West Valley City, UT"
];

var stationFinderOptions = '';

// lets look at the url...
//alert("document.url: " + document.URL);
var xDropdown = [];

if (document.URL.lastIndexOf("/UT/") > -1 || document.URL.lastIndexOf("/ut/") > -1) {
    //for Utalh
    xDropdown = UTDropDown;
} else {
    xDropdown = stationFinderDropdown;  
}

for (var i = 0; i < xDropdown.length; i++) {
	
	stationFinderOptions += '<option value="';
	stationFinderOptions += xDropdown[i];
	stationFinderOptions += '">';
	stationFinderOptions += xDropdown[i];
	stationFinderOptions += '</option>';
	
}

$('#addressDropdown').change(function(){
						  
	$('form').submit();								  
});
//---------------------------------------
//  On Document Load
//---------------------------------------

$(document).ready(function(){
	
	//Fill the address dropdown
	$("#addressDropdown").append(stationFinderOptions);
	
	//Preload some images
	MM_preloadImages('imgs/top_imgs/top_menu_03_h.jpg','imgs/top_imgs/top_menu_05_h.jpg','imgs/top_imgs/top_menu_06_h.jpg','imgs/top_imgs/top_menu_04_h.jpg','imgs/home_imgs/home_get_started_over.png','imgs/home_imgs/home_spread_word_over.png');
	
	
	
	
	//--------------------------------------
	//  Handles any screen slide animations
	//--------------------------------------
	//hide all the slides
	$('.screen-slides').hide();
	
	//if a screen link is clicked
	$('.screen-links').click(function(){
	
	
		var curPos = $(this).attr('id');
		//if the screen is currently in view
		//if($('.screen-slides:visible').attr('id') == curPos && isDown == true){
			
			//Do nothing	
		
		//}else 
		
		if($('.screen-slides:visible').length > 0 && isDown == true){
		
			slideUp();
			
			setTimeout("$('.screen-slides').hide().filter('."+curPos+"').show();slideDown();"
			,2000);
		}else{
		
		
			//show the current slide
			$('.screen-slides').hide().filter("'."+curPos+"'").show();
			
			
			slideDown();
		}
		
		
	});
	
	
	//close the slide button
	$('.screen-slides button.close-btn').click(function(){
														
		slideUp();
		//terminate the swf
		closeIntroSwf();
		
	});
	
	
	
});
						   

