// JavaScript Document

var DOMmode = new Array(3);
DOMmode[0] = false;
DOMmode[1] = false;
DOMmode[2] = false;

if (document.getElementById) {
	DOMmode[0] = true;
} else if (document.all) {
	DOMmode[1] = true;
} else if (document.layers) {
	DOMmode[2] = true;
}

function getObj( name ) {
	var obj;
	if (DOMmode[0]) {
  		obj = document.getElementById(name);
	} else if (DOMmode[1]) {
		obj = document.all[name];
	} else if (DOMmode[2]) {
   		obj = document.layers[name];
	}
  	return obj;
}

var imgs = [];
var thumbs = [];
var largeBox, listBox;
var imageServer = "http://www.willcarder.com/template/";

function loadImgs( largeImgBox, thImgBox, images ) {

	var imgSrcArray = images.split(',');
	var i, div;
	
	largeBox = getObj(largeImgBox);
	listBox = getObj(thImgBox);

	for(i=0;i<imgSrcArray.length;i++) {
		
		imgs[i] = new Image(400, 300);
		imgs[i].id = "img"+i;
		imgs[i].src = imageServer + "prop_img/" + imgSrcArray[i];
		
		thumbs[i] = new Image(100, 75);
		thumbs[i].id = "th_img"+i;
		thumbs[i].src = imageServer + "prop_img/th_" + imgSrcArray[i];
		
		if(i == 0) {
			largeBox.appendChild(imgs[i]);
		}
		
		div = document.createElement("div");
		div.id = "___"+i;
		div.className = "thumbPropImg";
		div.onmouseover = function() {
			this.className = "thumbPropImgOver";
		}
		div.onmouseout = function () {
			this.className = "thumbPropImg";
		}
		div.onclick = function () {
			
			largeBox.removeChild(largeBox.firstChild);
			largeBox.appendChild(imgs[parseInt(this.id.substr(3, this.id.length))]);
			
		}
		div.appendChild(thumbs[i]);
		
		listBox.appendChild(div);
		
	}
}

function loadSMImgs( largeImgBox, thImgBox, images ) {

	var imgSrcArray = images.split(',');
	var i, div;
	
	largeBox = getObj(largeImgBox);
	listBox = getObj(thImgBox);

	for(i=0;i<imgSrcArray.length;i++) {
		
		imgs[i] = new Image(400, 268);
		imgs[i].id = "img"+i;
		imgs[i].src = imageServer + "prop_img/" + imgSrcArray[i];
		
		thumbs[i] = new Image(100, 75);
		thumbs[i].id = "th_img"+i;
		thumbs[i].src = imageServer + "prop_img/th_" + imgSrcArray[i];
		
		if(i == 0) {
			largeBox.appendChild(imgs[i]);
		}
		
		div = document.createElement("div");
		div.id = "___"+i;
		div.className = "thumbPropImg";
		div.onmouseover = function() {
			this.className = "thumbPropImgOver";
		}
		div.onmouseout = function () {
			this.className = "thumbPropImg";
		}
		div.onclick = function () {
			
			largeBox.removeChild(largeBox.firstChild);
			largeBox.appendChild(imgs[parseInt(this.id.substr(3, this.id.length))]);
			
		}
		div.appendChild(thumbs[i]);
		
		listBox.appendChild(div);
		
	}
}

function loadMapWithMarker( lat, long, html ) {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		var point = new GLatLng(lat, long);
		
		map.addControl(new GLargeMapControl());
		var mapControl = new GMapTypeControl();
		map.addControl(mapControl);
		map.setCenter(point, 12); 
		
		var mrk = new GMarker(point);
		map.addOverlay(mrk);
		mrk.openInfoWindowHtml(html);
	}
}
