//"Gallery" object definition.

Gallery.SHOWS = new Array();
Gallery.PATH = '/DSN/wwwseaislandpropcom/Asset/AssetFiles/';

function Gallery(sObjName, sID, sName)
{
	this.ID = sID;
	this.Name = sName;
	this.Handle = sObjName;
	this.DivID = sObjName + 'Div';
	this.Photos = new Array();
	this.Window = null;
	this.CurIdx = 0;
	
	Gallery.SHOWS.push({Handle:sObjName, Name:sName});
}
Gallery.prototype.addPhoto = function(obj)
{
	if(obj instanceof Photo)
		this.Photos.push(obj);
}
Gallery.prototype.Display = function()
{
	var myWin = window.open('about:blank', this.Handle + 'Win', 'width=525,height=465,status=no,scrollbars=auto,resizable=no');
	myWin.document.write('<html>\n<head>\n<title>' + this.Name + '</title>\n' +
		'<link rel="StyleSheet" type="text/css" href="/DSN/wwwseaislandpropcom/Style/Public_wwwseaislandpropcom.css">\n' +
		'<scr' + 'ipt language="javascript" src="/vlInclude/global.js"></' + 'script>\n' +
		'<scr' + 'ipt language="javascript" src="/DSN/wwwseaislandpropcom/Content/JavaScript/functions.js"></' + 'script>\n' +
		'<scr' + 'ipt language="javascript">\nvar ' + this.Handle + ' = window.opener.' + this.Handle + ';\n' +
		'</scr' + 'ipt>\n</head>\n<body style="margin:0px;text-align:center;">' +
		'<div id="' + this.DivID + '">' + this.getHTML() + '</div></body>\n</html>');
	this.Window = myWin;
}
Gallery.prototype.Draw = function()
{
	if(this.Window != null)
		this.Window.GetTag(this.DivID).innerHTML = this.getHTML();
}
Gallery.prototype.getHTML = function()
{
	var aHTML = new Array();
	var Photos = this.Photos;
	var idx = this.CurIdx;
	
	aHTML.push('<div class="PopUpGalleryHeader">' + this.Name + '</div>');
	aHTML.push('<div align="center"><div style="width:468px;">');
	aHTML.push('<img src="' + Gallery.PATH + Photos[idx].File + '" width="468" alt="' + Photos[idx].Name + '" border="0">');
	aHTML.push('<div align="right"><table id="PopUpGalleryControls"><tr>');
	
	if(idx != 0 || true)
		aHTML.push('<td><a href="javascript:void(' + this.Handle + '.Prev());"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/TourArrowLeft.jpg" border="0"></a></td>');
	else
		aHTML.push('<td><img src="/DSN/wwwseaislandpropcom/Content/Images/default/TourArrowLeft.jpg" border="0"></td>');
	
	aHTML.push('<td>' + (idx + 1) + ' of ' + Photos.length + '</td>');
	
	if(idx != Photos.length - 1 || true)
		aHTML.push('<td><a href="javascript:void(' + this.Handle + '.Next());"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/TourArrowRt.jpg" border="0"></a></td>');
	else
		aHTML.push('<td><img src="/DSN/wwwseaislandpropcom/Content/Images/default/TourArrowRt.jpg" border="0"></td>');
	
	aHTML.push('</tr></table></div>');
	aHTML.push('<div align="left">' + Photos[idx].Description + '</div>');
	aHTML.push('</div></div>');
	
	return aHTML.join('\n');
}
Gallery.prototype.Prev = function()
{
	this.CurIdx--;
	if(this.CurIdx < 0) this.CurIdx = this.Photos.length - 1;
	this.Draw();
}
Gallery.prototype.Next = function()
{
	this.CurIdx++;
	if(this.CurIdx >= this.Photos.length) this.CurIdx = 0;
	this.Draw();
}
Gallery.prototype.Preload = function()
{
	var str = '<div style="display:none;">';
	
	for(var i=0; i<this.Photos.length; i++)
		str += '<img src="' + Gallery.PATH + this.Photos[i].File +'">';
		
	str += '</div>';
	
	document.body.innerHTML += str;
}

Gallery.prototype.toString = function()
{
	return this.Name;
}

//"Photo" object definition.

function Photo(iID, sName, sDesc, sFile, sKeywords)
{
	this.ID = iID;
	this.Name = sName;
	this.Description = sDesc;
	this.Keywords = sKeywords;
	this.File = sFile;
	this.SortBy = sName.toLowerCase();
}
Photo.prototype.toString = function()
{
	return this.Name;
}


//"BigGallery" object definition

BigGallery.SHOWS = new Array();

function BigGallery(sObjName, oConfig)
{
	this.CurIdx = 0;
	this.Handle = sObjName;
	this.Photos = new Array();
	this.Image1ID = oConfig.Image1ID;
	this.Image2ID = oConfig.Image2ID;
	this.DetailsDivID = oConfig.DetailsDivID;
	this.DivID = sObjName + 'Div';
	this.ActiveIMG = oConfig.Image2ID;
	this.DormantIMG = oConfig.Image1ID;
	
	BigGallery.SHOWS.push(sObjName);
}
BigGallery.prototype.addPhoto = function(obj)
{
	if(obj instanceof Photo)
		this.Photos.push(obj);
}
BigGallery.prototype.Init = function()
{	
	GetTag("TableWrapper").innerHTML += '<div id="' + this.DivID + '" style="overflow:hidden;padding:5px;">&nbsp;</div>';

	GetTag(this.DivID).style.position = 'absolute';
	GetTag(this.DivID).style.top = GetTag(this.DetailsDivID).offsetTop + 'px';
	GetTag(this.DivID).style.left = GetTag(this.DetailsDivID).offsetLeft + 'px';
	
	if(document.all) {
		GetTag(this.DivID).style.width = GetTag(this.DetailsDivID).offsetWidth + 'px';
		GetTag(this.DivID).style.height = GetTag(this.DetailsDivID).offsetHeight + 'px';
	} else {
		GetTag(this.DivID).style.width = (GetTag(this.DetailsDivID).offsetWidth - 10) + 'px';
		GetTag(this.DivID).style.height = (GetTag(this.DetailsDivID).offsetHeight - 10) + 'px';
	}

	this.Preload();	
}
BigGallery.prototype.Draw = function()
{
	var aHTML = new Array();
	var Photos = this.Photos;
	var idx = this.CurIdx;
	
	if(this.DormantIMG == this.Image1ID) {
		this.ActiveIMG = this.Image1ID;
		this.DormantIMG = this.Image2ID;		
	} else {
		this.ActiveIMG = this.Image2ID;
		this.DormantIMG = this.Image1ID;	
	}
	
	//set & swap images
	GetTag(this.DormantIMG).src = Gallery.PATH + Photos[idx].File;
	opacity(this.ActiveIMG, 100, 0, 500);
	opacity(this.DormantIMG, 0, 100, 500);
	
	aHTML.push('<div align="center"><div id="GalleryControls">');
	aHTML.push('<table width="100%" cellspacing="0" cellpadding="0" border="0">');
	aHTML.push('<tr>');
	
	if(idx == 0 && false)
		aHTML.push('<td width="16"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/pixel.gif" class="BlockIMG" height="17" width="17"></td>');
	else
		aHTML.push('<td width="16"><a href="javascript:void(' + this.Handle + '.Prev());"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/pixel.gif" class="BlockIMG" height="17" width="17"></a></td>');
		
	aHTML.push('<td align="center"><span style="color:#644F25;">' + (idx + 1) + '</span>');
	aHTML.push('<span style="color:#4e635d;">of</span>');
	aHTML.push('<span style="color:#644F25;">' + Photos.length + '</span></td>');
			
	if(idx <= (Photos.length - 1) || true)
		aHTML.push('<td width="16"><a href="javascript:void(' + this.Handle + '.Next());"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/pixel.gif" class="BlockIMG" height="17" width="15"></a></td>');
	else
		aHTML.push('<td width="16"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/pixel.gif" class="BlockIMG" height="17" width="15"></td>');
		
	aHTML.push('</tr>');
	aHTML.push('</table>');
	aHTML.push('</div></div>');
	
	aHTML.push('<div class="Text">' + Photos[idx].Description + '</div>');
	
	GetTag(this.DivID).innerHTML = aHTML.join('\n');
}
BigGallery.prototype.Prev = function()
{
	this.CurIdx--;
	if(this.CurIdx < 0) this.CurIdx = this.Photos.length - 1;
	this.Draw();
}
BigGallery.prototype.Next = function()
{
	this.CurIdx++;
        if(this.CurIdx >= this.Photos.length) this.CurIdx = 0;
	this.Draw();
}
BigGallery.prototype.Preload = function()
{
	var str = '<div style="display:none;">';
	str += '<img src="' + Gallery.PATH + this.Photos[0].File +'" onload="BigGallery.StartUp(' + this.Handle + ');">';
	
	for(var i=1; i<this.Photos.length; i++)
		str += '<img src="' + Gallery.PATH + this.Photos[i].File +'">';
		
	str += '</div>';
	
	document.body.innerHTML += str;
}
BigGallery.prototype.sortPhotos = function()
{	
	this.Photos.sort(BigGallery.sortThis);
}
BigGallery.sortThis = function(a, b)
{
	if(a['SortBy'] < b['SortBy']) return -1;
	if(a['SortBy'] > b['SortBy']) return 1;
	return 0;
}
BigGallery.StartUp = function(obj)
{
	obj.Draw();
}