// JavaScript Document

var currindex=0;
if (readCookie('currindex')){
	currindex=parseInt(readCookie('currindex'));
}

var imagesondisplay=6;
var imagepath="/images/sites/slidethumbnails/";
var anchorpath="/houses/";
var imageext=".gif";

var thumbnails=new Array();
thumbnails[0]='classical1000';
thumbnails[1]='moroccan750';
thumbnails[2]='modern500';
thumbnails[3]='tropical350';
thumbnails[4]='classical350';
thumbnails[5]='moroccan350';
thumbnails[6]='classical750';
thumbnails[7]='modern350';
thumbnails[8]='modern250';
thumbnails[9]='tropical250';
thumbnails[10]='classical150';
thumbnails[11]='modern150';
thumbnails[12]='moroccan150';
thumbnails[13]='tropical150';
thumbnails[14]='classical250';
thumbnails[15]='moroccan250';

//preload images
if (document.images)
{
	for(i=0; i<thumbnails.length; i++){
	pic1=new Image();
	pic1.src=imagepath + thumbnails[i] + imageext;
	}
}


function moveleft(){
	currindex++;
	createCookie('currindex',currindex,100);
	setimage();

}

function moveright(){
	currindex--;
	createCookie('currindex',currindex,100);	
	setimage();

}

function setimage(){
	for(i=0; i<imagesondisplay; i++){
		currimage='image' + i;
		curranchor='anchor' + i;
		document.getElementById(currimage).src=imagepath + thumbnails[currindex+i] + imageext;
//		document.getElementById(curranchor).href="/houses/" + thumbnails[currindex+i] + "/index.html";
		document.getElementById(curranchor).href="/houses.php?house=" + thumbnails[currindex+i] ;		
	}
	if(currindex + imagesondisplay >= thumbnails.length){
		document.getElementById('rightarrow').style.visibility='hidden';
	}else{
		document.getElementById('rightarrow').style.visibility='visible';
	}
	if(currindex <= 0){
		document.getElementById('leftarrow').style.visibility='hidden';
	}else{
		document.getElementById('leftarrow').style.visibility='visible';
	}
}


function showframe(flag){
if (flag){
document.getElementById('sp_frame').style.display="block";
document.getElementById('sp_image').style.display="none";
}else{
document.getElementById('sp_frame').style.display="none";
document.getElementById('sp_image').style.display="block";
}
}
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);
}

