var imageonLV  = "'/picts/bull2.gif'";
var imageoffLV = "'/picts/bull2of.gif'";

function ToggleLV(show,image) {
	if(show) {
		eval("document." + image + ".src=" + imageonLV);
	} else {
		eval("document." + image + ".src=" + imageoffLV);	
	}
}

/*
 * (c) 2001 1-Percent.com, Inc
 * Author: Matthew R. Villa <matt@1-percent.com>
 * Revised: 07/13/2001
 */

var ContactInfoFormat = {

	/* Returns phone number based on US/Canada style number format. */
	phone:function(phone) {
		var phone2 = phone.replace(/\D/g, '');
		if(phone2.length == 10) {
			var phone3 = "";
			phone3 = "(" + phone2.substring(0, 3) + ") ";
			phone3 += phone2.substring(3,6) + "-";
			phone3 += phone2.substring(6,10);
			return phone3;
		} else if(phone2.length > 10) {
			var phone3 = "";
			phone3 = "(" + phone2.substring(0, 3) + ") ";
			phone3 += phone2.substring(3,6) + "-";
			phone3 += phone2.substring(6,10);
			phone3 += " ext " + phone2.substring(10,phone3.length);
			return phone3;
		}
		return "";
	},

	/* Returns zip code based on US/Canada style number format. */
	zip:function(zip) {
		var zip2 = zip.replace(/\D/g, '');
		if(zip2.length == 5) {
			return zip2.substring(0,5);
		} else if (zip2.length == 9) {
			var zip3 = zip2.substring(0,5);
			zip3 += "-";
			zip3 += zip2.substring(5,9);
			return zip3;
		}
		return "";
	}

}

function flyerPopUp(url, windowWidth, windowHeight) {

	/* Generate unique window name. */
	currentDate = new Date();
	windowName = currentDate.getTime();

	/* Create pop-up window. */
	var windowProperties = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0," +
		"resizable=1,width=" + windowWidth + ",height=" + windowHeight + "," +
		"top=" + ((screen.height - windowHeight) / 2) + ",left=" + ((screen.width - windowWidth) / 2);
	eval("page" + windowName + " = window.open(url, windowName, windowProperties);");

}

var MyDateUtil = { 

	SECOND:1000,
	MINUTE:60000,
	HOUR:3600000,
	DAY:86400000,
	WEEK:604800000,

	lastDayInMonth:function(mm, yyyy) {
		mm = parseInt(mm);
		yyyy = parseInt(yyyy);
		var firstDate = new Date(yyyy, mm, 01, 0, 0, 0, 0);
		var secondDate = new Date(firstDate - this.DAY);
		return secondDate.getDate();
	},
	
	isDateValid:function(mm, dd, yyyy) {
		mm = parseInt(mm);
		dd = parseInt(dd);
		yyyy = parseInt(yyyy);
		
		/* Get current year */
		var curDate = new Date();
		var curYear = curDate.getFullYear();
		
		if(isNaN(mm)) return false;
		if(mm < 1 || mm > 12) return false;
		
		if(isNaN(dd)) return false;
		if(dd < 1 || dd > 31) return false;
		
		if(isNaN(yyyy)) return false;
		if(yyyy > curYear) return false;

		last_day = this.lastDayInMonth(mm, yyyy);
		if(dd > last_day) return false;
		
		return true;
	},
	
	daysBetweenDates:function(mm1, dd1, yyyy1, mm2, dd2, yyyy2) {
		mm1 = parseInt(mm1);
		dd1 = parseInt(dd1);
		yyyy1 = parseInt(yyyy1);
		mm2 = parseInt(mm2);
		dd2 = parseInt(dd2);
		yyyy2 = parseInt(yyyy2);
		var nTime = Date.UTC(yyyy1, mm1 - 1, dd1);
		var dTime = Date.UTC(yyyy2, mm2 - 1, dd2);
		var bTime = Math.abs(nTime - dTime);
		return Math.round(bTime / this.DAY);
	},
	
	yearsBetweenDates:function(mm1, dd1, yyyy1, mm2, dd2, yyyy2) {
		mm1 = parseInt(mm1);
		dd1 = parseInt(dd1);
		yyyy1 = parseInt(yyyy1);
		mm2 = parseInt(mm2);
		dd2 = parseInt(dd2);
		yyyy2 = parseInt(yyyy2);
		var days = this.daysBetweenDates(mm1, dd1, yyyy1, mm2, dd2, yyyy2);
		return Math.floor(days / 365.25);
	}
		

}

function memPopUp(url, windowWidth, windowHeight) {

	// Get user's screen resolution size.
	var screenWidth = screen.width;
	var screenHeight = screen.height

	// Get window's x, y position.
	var winPosLeft = (screenWidth - windowWidth) / 2;
	var winPosTop = (screenHeight - windowHeight) / 2;

	// Generate unique window name.
	currentDate = new Date();
	windowName = currentDate.getTime();

	// Initiate new window.
	var windowProperties = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + windowWidth + ",height=" + windowHeight + ",top=" + winPosTop + ",left=" + winPosLeft;
	eval("page" + windowName + " = window.open(url, '" + windowName + "', windowProperties);");

}

function delCookie(cookieName) {

	// Check to see if cookie exists
	var c = document.cookie;
	var indexPos = c.indexOf(cookieName);

	// If it does exist, delete it!
	if (indexPos != -1) {

		var curDate = new Date();
		var curYear = curDate.getYear();
		var expDateTimeStamp = curDate.setYear(curYear - 2);
		
		var expDate = new Date(expDateTimeStamp);
		var expDateGMTString = expDate.toGMTString();
	
		// Delete remember me cookie
		document.cookie = cookieName + "=; path=/; domain=.1-percent.com; expires=" + expDateGMTString;
	
	}

}

function showTerms() {

	// Define document location
	var url = "http://www.1-percent.com/termsofservice_pop.html";

	// Define pop-up window width and height size.
	var windowWidth = 500;
	var windowHeight = 500;

	// Get user's screen resolution size.
	var screenWidth = screen.width;
	var screenHeight = screen.height

	// Get window's x, y position.
	var winPosLeft = (screenWidth - windowWidth) / 2;
	var winPosTop = (screenHeight - windowHeight) / 2;

	// Initiate new window.
	var windowName = "terms";
	var windowProperties = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + windowWidth + ",height=" + windowHeight + ",top=" + winPosTop + ",left=" + winPosLeft;
	var terms = window.open(url,windowName,windowProperties);

}

function showTerms2() {

	// Define document location
	var url = "http://www.1-percent.com/termsofservice_pop.html#privacy";

	// Define pop-up window width and height size.
	var windowWidth = 500;
	var windowHeight = 500;

	// Get user's screen resolution size.
	var screenWidth = screen.width;
	var screenHeight = screen.height

	// Get window's x, y position.
	var winPosLeft = (screenWidth - windowWidth) / 2;
	var winPosTop = (screenHeight - windowHeight) / 2;

	// Initiate new window.
	var windowName = "termsPrivacy";
	var windowProperties = "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + windowWidth + ",height=" + windowHeight + ",top=" + winPosTop + ",left=" + winPosLeft;
	var terms = window.open(url,windowName,windowProperties);

}

function getSecAndFirstLevDomain() {
	hostname = location.hostname;
	pairs = hostname.split(".");
	pairsLen = pairs.length;
	secLevel = pairs[pairsLen - 2];
	firLevel = pairs[pairsLen - 1];
	combined = secLevel + "." + firLevel;
	return combined;
}

function closeWin() {
	timer = setTimeout('window.close();', 10);
}

/* 
Importing of text utilities
	Text.js provided by MyersDaily. For documentation see
	http://www.angelfire.com/yt/jmyers/bin/pod/Text.shtml. 
*/

var Text = {
as:function(a1) { return '' + (a1 || '') },
is:function(a1) { return '' + a1 === a1 },
no:function(a1) {
	a1 = isNaN(a1=Number(a1)) ? parseFloat(a1) : a1;
	return isNaN(a1) ? 0 : a1;
},
ex:function(a1,a2) {
	var mo = Math.floor(a2/2);
	if (mo > 1) return this.ex(a1 + a1, mo) + (a2 % 2 && a1 || '');
	var fo = '';
	while (a2 > 0) { fo += a1; a2-- }
	return fo;
},
pad:function(a1,a2,a3) {
return this.is(a1)
	? a1 + this.ex(a3 || ' ', a2 - a1.length)
	: this.ex(a3 || ' ', a1 - ('' + a2).length) + a2;
},
trim:function(a1,a2,a3) {
	a1 = this.as(a1).replace(a3 || /^\s+|\s+$/g, '');
	a1 = this.as(a1).replace(a3 || /\s{2,}/g, ' ');
	return a2 && a1.length > a2 ? a1.substr(0,a2-1) + '\u2026' : a1; 
},
trim2:function(a1,a2,a3) {
	a1 = this.as(a1).replace(a3 || /\s{2,}/g, ' ');
	return a2 && a1.length > a2 ? a1.substr(0,a2-1) + '\u2026' : a1; 
},
line:function(a1) {
	var OS = navigator.platform, NL = OS.indexOf('Mac') != -1
		&& '\r' || OS.indexOf('Win') != -1
		&& '\r\n' || '\n';
	return this.as(a1) + NL;
},
code:function(a1) { return (a1=this.as(a1)) ? "unescape('"+escape(a1)+"')" : "''" }
}