/***********************************************************
 *  This is the default javascript file for ParadiseCoast.com
 ***********************************************************/

function MM_findObj(n, d) { //v3.0
	var p, i, x;
	if (!d) d = document;
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if (!(x = d[n]) && d.all) x = d.all[n];
	for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
	return x;
}

function MM_swapImage() { //v3.0
	var i, j = 0,
		x, a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i = 0; i < (a.length - 2); i += 3)
	if ((x = MM_findObj(a[i])) != null) {
		document.MM_sr[j++] = x;
		if (!x.oSrc) x.oSrc = x.src;
		x.src = a[i + 2];
	}
}

function MM_swapImgRestore() { //v3.0
	var i, x, a = document.MM_sr;
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d = document;
	if (d.images) {
		if (!d.MM_p) d.MM_p = new Array();
		var i, j = d.MM_p.length,
			a = MM_preloadImages.arguments;
		for (i = 0; i < a.length; i++)
		if (a[i].indexOf("#") != 0) {
			d.MM_p[j] = new Image;
			d.MM_p[j++].src = a[i];
		}
	}
}


function popmap(pageSource) {
	map = window.open(pageSource, 'popwindow', 'width=400,height=400,scrollbars=auto');
	map.focus();
}

function cmsZoom(pageSource, pageName, theHeight, theWidth) {
	showScrollbars = '';
	leWindow = window.open(pageSource, pageName, 'width=' + theWidth + ',height=' + theHeight + ',' + showScrollbars + 'resizable');
	leWindow.resizeTo(theWidth, theHeight);
	leWindow.focus();
}
// and yet another pop up function

function homeMapPop(page, name, options) {
	somevariable = window.open(page, name, options);
}

//flash detection
FlashObject = function (swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver || 6;
	this.align = "middle";
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "download flash to view";
	this.bypassTxt = "";
	this.params = new Object();
	this.variables = new Object();
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('menu', 'false'); // default to no menu
	this.doDetect = getQueryParamValue('detectflash');
}

FlashObject.prototype.addParam = function (name, value) {
	this.params[name] = value;
}
FlashObject.prototype.getParams = function () {
	return this.params;
}
FlashObject.prototype.getParam = function (name) {
	return this.params[name];
}
FlashObject.prototype.addVariable = function (name, value) {
	this.variables[name] = value;
}
FlashObject.prototype.getVariable = function (name) {
	return this.variables[name];
}
FlashObject.prototype.getVariables = function () {
	return this.variables;
}

FlashObject.prototype.getParamTags = function () {
	var paramTags = "";
	for (var param in this.getParams()) {
		paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
	}
	if (paramTags == "") {
		paramTags = null;
	}
	return paramTags;
}

FlashObject.prototype.getHTML = function () {
	var flashHTML = "";
	if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) {
		flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
		flashHTML += '<param name="movie" value="' + this.swf + '" />';
		if (this.getParamTags() != null) {
			flashHTML += this.getParamTags();
		}
		if (this.getVariablePairs() != null) {
			flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
		}
		flashHTML += '</object>';
	} else {
		flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
		for (var param in this.getParams()) {
			flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
		}
		if (this.getVariablePairs() != null) {
			flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
		}
		flashHTML += '></embed>';
	}
	return flashHTML;
}


FlashObject.prototype.getVariablePairs = function () {
	var variablePairs = new Array();
	for (var name in this.getVariables()) {
		variablePairs.push(name + "=" + escape(this.getVariable(name)));
	}
	if (variablePairs.length > 0) {
		return variablePairs.join("&");
	} else {
		return null;
	}
}

FlashObject.prototype.write = function (elementId) {
	if (detectFlash(this.version) || this.doDetect == 'false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt + "" + this.bypassTxt;
			} else {
				document.write(this.altTxt + "" + this.bypassTxt);
			}
		}
	}
}

function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if (x) {
			if (x.description) {
				var y = x.description;
				flashversion = y.charAt(y.indexOf('.') - 1);
			}
		}
	} else {
		result = false;
		for (var i = 15; i >= 3 && result != true; i--) {
			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + i + '"))', 'VBScript');
			flashversion = i;
		}
	}
	return flashversion;
}

function detectFlash(ver) {
	if (getFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}

function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
	if (q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex) + 1, endIndex);
	} else {
		return "";
	}
}

if (Array.prototype.push == null) {
	Array.prototype.push = function (item) {
		this[this.length] = item;
		return this.length;
	}
}

//end flash detection

function popwindow(pageSource){
	leWindow = window.open(pageSource, 'popwindow', 'width=500,height=400,resize=yes,resizable=yes,scrollbars=yes,x=10,y=20,left=10,top=20'); 
	leWindow.focus();
} 
function popwindow2(pageSource, width, height){
	popwin = window.open(pageSource, 'popwindow', 'width='+width+',height='+height+',resizable=yes,scrollbars=yes,x=10,y=20,left=10,top=20');
	popwin.focus();
}

function showItems(myItem){
	$("div[id^='footer_links_promo']").hide();
	$('#'+myItem).show();
}
function hideItems(myItem){
	$(myItem).hide();
}

$(document).ready(function(){
	try{
		var data = "Alabama|Alaska|American Samoa|Arizona|Arkansas|Armed Forces - Europe|Armed Forces - Pacific|Armed Forces - USA/Canada|California|Colorado|Connecticut|Delaware|District of Columbia|Federated States of Micronesia|Florida|Georgia|Guam|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Marshall Islands|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Puerto Rico|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virgin Islands|Virginia|Washington|West Virginia|Wisconsin|Wyoming|Alberta|British Columbia|Manitoba|New Brunswick|Newfoundland|Northern Mariana Island |Northwest Territories|Nova Scotia|Ontario|Palau Island|Prince Edward Island|Quebec|Saskatchewan|Yukon Territory|Australian Capital Territory|New South Wales|Northern Territory|Queensland|South Australia|Tasmania|Victoria|Western Australia";
		$("#state").autocomplete(data.split("|"));
		var country_list = "Afghanistan|Albania|Algeria|Andorra|Angola|Antigua and Barbuda|Argentina|Armenia|Australia|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Brazil|Brunei|Bulgaria|Burkina Faso|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Central African Republic|Chad|Chile|China|Colombi|Comoros|Congo (Brazzaville)|Congo|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Cyprus|Czech Republic|Denmark|Djibouti|Dominica|Dominican Republic|East Timor (Timor Timur)|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Finland|France|Gabon|Gambia, The|Georgia|Germany|Ghana|Greece|Grenada|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Israel|Italy|Jamaica|Japan|Jordan|Kazakhstan|Kenya|Kiribati|Korea, North|Korea, South|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macedonia|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Mauritania|Mauritius|Mexico|Micronesia|Moldova|Monaco|Mongolia|Morocco|Mozambique|Myanmar|Namibia|Nauru|Nepa|Netherlands|New Zealand|Nicaragua|Niger|Nigeria|Norway|Oman|Pakistan|Palau|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Poland|Portugal|Qatar|Romania|Russia|Rwanda|Saint Kitts and Nevis|Saint Lucia|Saint Vincent|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Senegal|Serbia and Montenegro|Seychelles|Sierra Leone|Singapore|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|Spain|Sri Lanka|Sudan|Suriname|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Togo|Tonga|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Tuvalu|Uganda|Ukraine|United Arab Emirates|United Kingdom|United States|Uruguay|Uzbekistan|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe";
		$("#country").autocomplete(country_list.split('|'));
		$("#date, .date").datepicker();
	}
	catch(e){}
});

