// Beach Bumz Tanning custom javascript functions
// All works copyright Lee Crabtree of Beach Bumz Tanning & Gear


<!-- Begin random image display - Lee Crabtree
// Set up the image files to be used.
var theImages = new Array()


theImages[0] = 'images/banner_0.jpg'
theImages[1] = 'images/banner_1.jpg'
theImages[2] = 'images/banner_2.jpg'
theImages[3] = 'images/banner_3.jpg'
theImages[4] = 'images/banner_4.jpg'


var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));

function showImage(){
	document.write('<img src="'+theImages[whichImage]+'" border="0" alt="Goldsboro tanning salon posters - copyright Beach Bumz">');
}

//  End -->






<!-- //  Custom cookie functions - Lee Crabtree
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
//-->

<!--

// create an instance of the Date object
var now = new Date();
// fix the bug in Navigator 2.0, Macintosh
fixDate(now);

/*
cookie expires in one year (actually, 365 days)
365 days in a year
24 hours in a day
60 minutes in an hour
60 seconds in a minute
1000 milliseconds in a second
*/

now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
var visits = getCookie("counter");
// if the cookie wasn't found, this is your first visit
if (!visits) {
  visits = 1; // the value for the new cookie
  document.write("By the way, this is your first time here.");
} else {
  // increment the counter
  visits = parseInt(visits) + 1;
  document.write("By the way, you have been here " + visits + " times.");
}
// set the new cookie
setCookie("counter", visits, now);

// -->






function checkCookie()
{
	username=getCookie('username');
	flashviewed = getCookie('flashviewed');
	lastvisit = getCookie('lastvisit');
	visits = getCookie('counter');
	visitdate = getCookie('lastvisit');
	firstvisit = getCookie('firstvisit');
	
	var ip = '<!--#echo var="REMOTE_ADDR"-->';
	var refer = document.referrer;
	
	// if (java && java.net)
	// ip = ''+java.net.InetAddress.getLocalHost().getHostAddress();
	// else ip = 'unknown';
	
	
	if (flashviewed!=null && flashviewed!="")
		{
			// setCookie('firstvisit',now,365);
		}
	else 
		{
			setCookie('flashviewed','yes',1);
		} 
	
	
	if (firstvisit=="")
		{
			setCookie('firstvisit',now,365);
		}
		
		
	if (!visits) {
		  visits = 1; // the value for the new cookie
		} else {
		  visits = parseInt(visits) + 1; // increment the counter
		}
		
		setCookie('counter', visits, now);
		setCookie('lastvisit',now,365);
		setCookie('ipaddress',ip,365);
		setCookie('referrer',document.referrer,365);
		
		firsttime = getCookie('firstvisit');
		
		document.write("You have visited this site "+visits+" times. Welcome back!");
		

}


/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 *
 */

function clickclear(thisfield, defaulttext, color) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
		if (!color) {
			color = "000000";
		}
		thisfield.style.color = "#" + color;
	}
}
function clickrecall(thisfield, defaulttext, color) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
		if (!color) {
			color = "cccccc";
		}
		thisfield.style.color = "#" + color;
	}
}


<!--
function popitup(url,height,width) {
	newwindow=window.open(url,'name','height='+height+',width='+width+',status=no');
	if (window.focus) {newwindow.focus()}
}

// -->
