// Cookie functionality from http://www.quirksmode.org/js/cookies.html

var myAds=new Array();												// Declaring Ad Array
var myLinks=new Array();											// Declaring Ad Array
var myText=new Array();												// Declaring Ad Array

// Defining values for both arrays
myAds[0]='../images/Galatoires.gif';
myLinks[0]='http://www.galatoires.com/';
myText[0]='Above all others, Galatoire’s rich tradition of serving authentic French Creole cuisine at a level that raises consistency to an art form. Even after 100 years, ageless New Orleans favorites grace her menu just as they did in 1905.';

myAds[1]='../images/marigny_brass.gif';
myLinks[1]='http://www.marignybrasserie.com/';
myText[1]='"The new Marigny Brasserie&#39;s French doors opening onto Frenchmen Street across from Washington Square park with its warm interior make this restaurant a casually-chic place to dine. It is a favorite among locals, foodies, and the well-informed tourist!"';

var count = readCookie('counter');									// Retrieve count from cookie


if (count == null) {
	count = 0;
	createCookie('counter', count, 0);								// save count into counter cookie
}

var numberofads = myAds.length;										// How many swf files are you rotating?

// Output the image
document.write('<center><a href ="');
document.write(myLinks[count]);
document.write('"target="_blank"><img src="');
document.write(myAds[count]);										// Output the image location
document.write('" /></a>');
document.write('<div class="quote">');
document.write(myText[count]);
document.write('</div></center>');

count++;															// Increment count
// If count is higher than the number of sfw files reset
if (count > (numberofads - 1)) {
	count=0;
}

createCookie('counter', count, 0);									// save count into counter cookie

/*
 *             Functions                                               
*/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
