/*
	Javascript Included Files
*/






	function rowBGColor(row, color) {
		if (document.getElementById) {
			row.style.backgroundColor = color;
		}
	}
	
	
	
	function objClass(obj, className) {
		if (obj) {
			obj.className = className;
		}
	}
	
	
	
	
	
	function btnOn(btn) {
		if (document.getElementById) {
			btn.className = 'submt_on';
		}
	}
	
	function btnOff(btn) {
		if (document.getElementById) {
			btn.className = 'submt';
		}
	}
	
	
	
	function hideShow(objID) {
	
		if (document.getElementById) {
			var curObj = document.getElementById(objID);
			var curStatus = curObj.style.display;
			
			if (curStatus == 'block') curObj.style.display = 'none';
			else curObj.style.display = 'block';
		}
	}



	function strpad (str, length2be, paddding, direction) {
		/*
			str - the string to be 
				if str is not set, the original string is returned

			length2be - the length of the resultant (padded) string
				if length2be is not set, the original string is returned
			
			padding - what to pad the string with
				defaults to underscore if not set
			
			direction - which side of the string to place the padding
				defaults to left if not set
		*/
		
	
	
		if (!str || str == '' || !length2be || length2be == '') return str;
		if (!paddding || paddding == '') paddding = '_';
		if (!direction || direction == '') direction = 'l';
	
		while(str.length < length2be)
			if (direction == 'l') str = paddding + str;
			else str = str + paddding;
			
		return str;
	}



	function validateMailingListEntry(fld) {
		if (!validEmail(fld.value)) {
			alert('Enter a valid email address.');
			fld.focus();
			fld.select();
			return false;
		}
		else return true;
	}
	
	
	
	
	
	
	


	
	function portfolioPopper(info, thumbnail) {
		var w = screen.width - 200;
		var h = screen.height - 150;
		var t = 10;
		var l = 10;
		
		if (thumbnail == undefined) thumbnail='';
	
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		if (document.all) {
			//var top = (screen.height - h)/2;
			var top = 10;
			
			var left = (screen.width- w)/2;
			params += ",left="+ left +",top="+ top ;
		}
	
	
		thisWindow = window.open(
			'/popups/portfolio.php?info='+info+'&thumbnail='+thumbnail,
			"portfolio",
			params
		);
	
		thisWindow.focus();
	}



	
	
	
	function popupVendor(vendor_id) {
		var w = 600;
		var h = 500;
		var t = 10;
		var l = 10;
		
		var params = "scrollbars=1,resizable=1,status=0,location=0,width="+ w +",height="+ h;
	
		if (document.all) {
			//var top = (screen.height - h)/2;
			var top = 10;
			
			var left = (screen.width- w)/2;
			params += ",left="+ left +",top="+ top ;
		}
	
	
		thisWindow = window.open(
			'/popups/vendor.php?vendor_id='+vendor_id,
			"vendor",
			params
		);
	
		thisWindow.focus();
	}
	





	
	

//=========== FORM VALIDATION FUNCTIONS



function stripSpaces(str) {
	//wrapper for a legacy function
	return trim(str);
}//stripSpaces


function trim(str) {
	return str.replace(/^\s*|\s*$/g,"");
}

function validEmail(str) {
	emailEXP = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$/;


	if (!emailEXP.test(str)) {
		return false;
	} else {
		return true;
	}
}

function validZipCode(str) {
	numEXP = /^\d{5}(-\d{4})?$/;

	if (!numEXP.test(str)) {
		return false;
	} else {
		return true;
	}
}

function validPhoneNumber(str) {
	phoneEXP = /^(\d{3}\-\d{3}\-\d{4}$|\d{3}\.\d{3}\.\d{4}$|\d{3}\ \d{3}\ \d{4}$|\d{10}$)/

	if (!phoneEXP.test(str)) {
		return false;
	} else {
		return true;
	}
}

function validURL(str) {
	exp = /^((ht|f)tp(s?))\:\/\/([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\S*)?$/

	if (!exp.test(str)) {
		return false;
	} else {
		return true;
	}
}



