//	Browser d-tect
var w3c = (document.getElementById) ? true : false;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

var cursor_type = (document.all) ? 'hand' : 'pointer';


/*
if (w3c) {
	document.write('<style type="text/css">#flashContent { visibility: hidden; height: 450px; } </style>');
}
*/

//	Init function
function init() {
	setPopUps();
	
}

//	If browser is good, run onload function
if (w3c) { window.onload=init; }





function setPopUps() {
	var all_links = document.getElementsByTagName('A');
	
	for (var aa=0; aa<all_links.length; aa++) {
		features = null;
		if (all_links[aa].rel.toLowerCase() == 'resourcelink') {
			all_links[aa].onclick = function() {
				popupWindow(this.href, this.rel);
				return false;
			}
		}
		if (all_links[aa].rel.toLowerCase() == 'previewproject') {
			all_links[aa].onclick = function() {
				popupWindow(this.href, this.rel);
				return false;
			}
		}
		if (all_links[aa].rel.toLowerCase() == 'previewproject5') {
			all_links[aa].onclick = function() {
				popupWindow(this.href, this.rel, 'menubar=yes,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=790,height=530');
				return false;
			}
		}
	}
}








//	Print code
function doPrint() {
	if (window.print) {
		window.print();
	} else {
		alert('To print this page, click on the File menu and choose Print \nor press Cntrl + P on your keyboard.');
	}
}


function setCookie(cookie_name,cookie_value) {
	
	//format expiry date
	cookie_date = new Date();
	cookie_date.setTime(cookie_date.getTime() + ( 365 *24*60*60*1000));

	document.cookie = cookie_name + '=' + cookie_value
		+ '; expires=' + cookie_date.toGMTString() 
		+ '; path=/';
}


function getCookie(cookie_name) {
	this_cookie = null;	
	
	if (document.cookie && document.cookie.indexOf(cookie_name) != -1) {
		this_cookie = document.cookie.split(cookie_name+'=');
		this_cookie = this_cookie[1].split(';');
	}
	// alert(font_cookie);
	
	return this_cookie;
}

function setFramesetPreview() {
	var all_links = document.getElementsByTagName('A');
	
	for (var aa=0; aa<all_links.length; aa++) {		
		if (all_links[aa].target.toLowerCase() == 'previewbusiness') {
			all_links[aa].onclick = function() {
				jumpToFrameset(this);
				return false;
			}
		}
	}
}



function jumpToFrameset(bottom_frame) {
	//	this.target = '_top';
	this_location = location.href;
	location.href = site_root + 'frame_format.html?' + bottom_frame + '~' + this_location;
}


function setFrameFormat() {
	//top.document.getElementById('companyFrame').name;	//	use to access tag attributes
	//top.companyFrame.location.href;	//	use to access frame document properties
	
	var tila_index = location.search.indexOf('~');
	var previous_page = top.location.search.substring(tila_index+1);
	var business_page = location.search.substring(1,tila_index);
	
	var top_frame_document = top.bannerFrame.document;
	
	var company_frame_tag = top.document.getElementById('companyFrame');
	
	//alert('business_page = '+business_page+ '\n' +'previous_page = '+previous_page);
	
	company_frame_tag.src = business_page;
	
	top_frame_document.getElementById('backToList').href = previous_page;	
	top_frame_document.getElementById('removeFrame').href = business_page;
}





//	Popup window code
function popupWindow(url, target, features) {
	var page_position = (parseInt(navigator.appVersion) > 3) ? 'left=0,top=0,screenX=0,screenY=0,' : "";
	var popup_features = 'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=790,height=560';

	if (isUndefined(features)) {
		features = popup_features;
	}
	if (isUndefined(target)) {
		target = '_blank';
	}
	var the_window = window.open(url, target, page_position+features);
	the_window.focus();
	return the_window;
}

function linkPopup(src, features) {
	return popupWindow(src.getAttribute('href'),src.getAttribute('rel') || '_blank',features);
}

//	Utility function [currently used in popupWindow()]
function isUndefined(v) { 
	//	Returns true if [v] is not defined, false otherwise
	//	IE 5.0 does not support the undefined keyword, so we cannot 
	//	do a direct comparison such as v===undefined.
	var undef;
	return v===undef;
}
//	End Popup window code



var preload_slides = new Array('new_images/businesscard.jpg','new_images/coupon.jpg','new_images/coupon2.jpg','new_images/enjoy.jpg','new_images/holiday.jpg','new_images/holiday_postcard.jpg','new_images/infocard.jpg','new_images/october.jpg','new_images/poolad.jpg','new_images/referral_postcard.jpg','new_images/rewards.jpg','new_images/september.jpg','new_images/sidestation.jpg','new_images/thanksgiving.jpg','new_images/cspa.jpg','new_images/socaldinners.jpg','new_images/entreesbyyou.jpg','new_images/acacinvite.jpg');
var img_objects = new Array;
if (document.images) {
	for (var zz=0; zz<preload_slides.length; zz++) {
		img_objects[zz] = new Image();
		img_objects[zz].src = preload_slides[zz];
	}		
}
var slide_number = 0;
function changeSlide(neg_pos) {
	if (neg_pos == -1 && slide_number==0) slide_number = preload_slides.length;
	if (neg_pos == 1 && slide_number==(preload_slides.length-1)) slide_number = -1;
	document.images['slide_show'].src = preload_slides[slide_number+neg_pos];
	slide_number = slide_number + neg_pos;
}

function skipto(pic_num) {
	document.images['slide_show'].src = preload_slides[pic_num];
	slide_number = pic_num;
	}