// JavaScript Document



function noSpam(user,domain) {

locationstring = "mailto:" + user + "@" + domain; window.location = locationstring; }



function checkFields(theForm)
{
    for (var ind in reqFieldNames ) {
        var field = eval("theForm.elements['" + reqFieldNames[ind] + "']");
        if (field.type == "text") {
            if(isEmpty(field.value)) {
                //alert("Please enter a value for: " + field.name);
                field.focus();
                return(false);
            }
        } else if (field.type == "radio") {
            if (!isRadioChecked(field)) {
                //alert("Please select a option for: " + field.name);
                field.focus();
                return(false);
            }
        } else if (field.type == "select-one") {
        	//alert(field.type);
        	if (field.value == 0) {
        		//alert("Please select a option for: " + field.name);
        		field.focus();
        		return(false);
        	}
        }
        if (field.name == 'dropoff_day') {
        	//alert(field.type);
        }
        
    }
}

function setLocation(href){

   if(href.charAt(0) != '#'){

      href = '#' + href;

   }

   var hash = window.location.href.split('#');

   var location = hash[0];

   window.location.href = location + href;

}



function getLocation(){

   var hash = window.location.href.split('#');

   if(hash.length > 1){

        /*var lioSlash = hash[1].lastIndexOf('/');

        if(lioSlash > -1){

            hash = hash[1].substring(0, lioSlash);

            alert('in + ' + hash);

            return hash;

            

        }else{*/

          //alert('out + ' + hash[1]);

          return hash[1];

          

       //}

   }else{

      return '';

   }

}



//flash detection

// set this to the max version of flash that you'll ever deal with.

var MAX_FLASH_VERSION = 9;



// this needs to be global to use in VBScript with IE/Win

var FlashVersionInstalled = 0;



// the Object Definition

function FlashSwapper(flashVersionRequired, flashMovieFileName, flashContainerId, flashMovieId, flashMovieWidth, flashMovieHeight, flashMovieQuality, flashMovieWindowMode, flashswapMethod )

{

	// user-defined initializations

	if(flashVersionRequired)this.requiredVersion = flashVersionRequired;

	if(flashMovieFileName)this.fileName = flashMovieFileName;

	if(flashContainerId)this.LoadContainer(flashContainerId);

	if(flashMovieId)this.id = flashMovieId;

	if(flashMovieHeight)this.height = flashMovieHeight;

	if(flashMovieWidth)this.width = flashMovieWidth;

	if(flashMovieQuality)this.quality = flashMovieQuality;

	if(flashMovieWindowMode)this.wmode = flashMovieWindowMode;

	if(flashswapMethod)this.swapMethod = flashswapMethod;

	else this.swapMethod = 'over';



	//other variables

	this.errors = '';

	this.version = 0;



	this.LoadContainer = function(theId) {

		if(!document.getElementById){

			this.containerId = '';

			this.container = null;

		}else{

			if(theId) this.containerId = theId;

			this.container = document.getElementById(this.containerId);

		}

	}



	this.HasVersion = function(sVersion)

	{

		if(!this.DetectFlash())return false;

		if(!sVersion)sVersion = this.requiredVersion;

		if(!sVersion){

			this.errors += 'No version specified.  Set the requiredVersion property or send a version as an argument to HasVersion.\n';

			return false;

		}

		if(!this.version) {

			this.errors +='No version could be found.\n';

			return false;

		}

		return (this.version >= sVersion);

	}



	this.DetectFlash = function()

	{

		if(this.Detected) return this.HasFlash;



		this.Detected = false;



		this.HasFlash=false;

		var flashDescription = '';

		if(!navigator)return false; //??



		if(navigator.appVersion) {

			if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1)this.version = FlashVersionInstalled;

		}



		if(navigator.mimeTypes||navigator.plugins){

			if(navigator.mimeTypes) {

				if(navigator.mimeTypes['application/x-shockwave-flash']){

					this.HasFlash=true;

					if(navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin){

						if(navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description){

							// A flash plugin-description (usually) looks like this: Shockwave Flash 7.0 r19

							// pull the first number out of it, and hope for the best!

							flashDescription=navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin.description;

						}else this.errors+='no description on the flash plugin.\n'; //can't know version without description.

					}else this.errors+='the mimeType is defined, but no plugin is enabled.\n'; //? this is weird.  

				}

			}else{

				//no mimeTypes.  Try the plugins array

				if(navigator.plugins['Shockwave Flash']||navigator.plugins['Shockwave Flash 2.0']){

					var isVersion2 = navigator.plugins['Shockwave Flash 2.0'] ? ' 2.0' : '';

					flashDescription = navigator.plugins['Shockwave Flash' + isVersion2].description;

				}

			}

		}

		if(flashDescription != '') {

			//found something somewhere...

			var v=parseInt(flashDescription.replace(/^[^0-9]*/,''));

			if(!isNaN(v))this.version=v;

		}

		//doing this in a weird way because we might have flash, and yet not know the version.

		if(this.version){

			this.HasFlash=true;

			//whatever the error was, we worked past it!

			this.errors='';

		}

		this.Detected = true;

		return this.HasFlash;

	}



	this.Swap = function() {

		if(!document.getElementById)this.errors += 'Not using a DOM-compatible browser.  Could not swap.\n';

		if(!this.DetectFlash())this.errors += 'No flash detected.\n';

		if(!this.container)this.errors+='Container not found id:['+this.containerId+']\n';

		else if(!this.container.innerHTML)this.errors += 'No innerHTML property on container.\n';

		if(this.version<this.requiredVersion)this.errors +='Flash Version not sufficient.  Have:'+this.version+' Need:'+this.requiredVersion+'\n';

		if(!this.fileName)this.errors += 'Flash movie filename not specified!\n';

		if(this.errors!='')return false;



		var sHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+

			'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.requiredVersion+',0,0,0" ';

		if(this.width) sHTML += 'width="'+this.width+'" ';

		if(this.height) sHTML += 'height="'+this.height+'" ';

		if(this.id)sHTML += 'id="'+this.id+'"';

		sHTML += '><param name="movie" value="'+this.fileName+'" />';

		if(this.wmode && this.requiredVersion >= 6)sHTML += '<param name="wmode" value="'+this.wmode+'" />';

		if(this.quality)sHTML+='<param name="quality" value="'+this.quality+'" />';

		sHTML+='<embed wmode="opaque" src="'+this.fileName+'"';

		if(this.quality)sHTML+=' quality="'+this.quality+'"';

		if(this.width)sHTML+=' width="'+this.width+'"';

		if(this.height)sHTML+=' height="'+this.height+'"';

		if(this.id)sHTML+=' name="'+this.id+'"';

		sHTML+=' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';



		if(this.swapMethod=='over')this.container.innerHTML = sHTML;

		else if(this.swapMethod=='before') this.container.innerHTML = sHTML + this.container.innerHTML;

		else this.container.innerHTML+=sHTML;



		return true;

	}

}



// Write vbscript detection on ie win. IE on Windows doesn't support regular

// JavaScript plugins array detection.

// I changed the VBScript from the original MoockFPI in order to reduce the

// number of steps that the browser must go through. --IZS

if(navigator){

	if(navigator.appVersion) {

		if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1) {

			document.write('<scr' + 'ipt language="VBScript" type="text/VBScript"> \n');

			document.write('on error resume next\n');

			document.write('dim i,f\n');

			document.write('i = MAX_FLASH_VERSION\n');

			document.write('Do While i >= 2 \n');

			document.write('	Set f = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)\n');

			document.write('	If Err.Number = 0 Then\n');

			document.write('		FlashVersionInstalled = i\n');

			document.write('		Set f = Nothing\n');

			document.write('		Exit Do\n');

			document.write('  Else\n');

			document.write('    Err.Clear\n');

			document.write('	End If\n');

			document.write('	Set f = Nothing\n');

			document.write('	i = i - 1\n');

			document.write('Loop\n');

			document.write('<\/scr' + 'ipt> \n'); // break up end tag so it doesn't end our script

		}

	}

}



function versionCheck(baseUrl){

    var Flasher = new FlashSwapper();

    if(Flasher.HasVersion(8)) {

        

	    var url = window.location.href;

	    //alert("url:" + url);

	    var posI = url.indexOf('://');

	    if(posI > -1)

	        url = url.substring(posI+3,url.length);

	    var pos = url.indexOf(baseUrl);

	    if(pos > -1)

	        url = url.substring((pos +baseUrl.length), url.length);

	    var lioSlash = url.lastIndexOf('/');

	    //alert("url:" + url);

	    if(lioSlash > -1)

	        url = url.substring(0, lioSlash);

	        //alert("url:" + url);

	    url = baseUrl + 'index.html#' + url;

	    //alert("url:" + url);

	    location.replace(url);

    }

}



