/* IntroPanel Class */

var _Panels = [0, 0, 0, 0, 0, 0, 0, 0, 0];
var _PanelTypes = new Array();
_PanelTypes[0] = [1,1];
_PanelTypes[1] = [2,1];
_PanelTypes[2] = [3,1];
_PanelTypes[3] = [1,2];
_PanelTypes[4] = [1,3];
_PanelTypes[5] = [2,2];

var _PanelSize = [248,154];

function IntroPanel() {

	// ** public properties **
	
	this.type = null; // (1-6)
	this.cell = null; // (1-9)
	
	this.title = "";
	this.subtitle = "";
	
	this.image = "";   // <img>
	this.imageSize = 'Standard';  // Standard : Large
	this.imageIsLink = true;
	this.imageIsSWF = false;
	
	this.isVideo = false;
	this.videoXML = null; // ".xml"
	this.videoSummary = null;
	
	this.isGallery = false;
	this.galleryXML = null; // ".xml"
	
	this.content = ""; // <p>
	
	this.hideLine = false;
	this.footer = "";
	this.href = "";
	
	
	
	// ** public method **
	
	this.draw = function(mode) {
		
		if(mode != false) {
			_Panels[(this.cell - 1)] = this;
			this._HOLDER = document.getElementById("PanelHolder_" + this.cell);
			this._DIVCELL = document.getElementById("Cell_" + this.cell);
			var T = this._DIVCELL.offsetTop;
			var L = this._DIVCELL.offsetLeft;
		}
		mode != false ? this._DRAWMODE = true : this._DRAWMODE = false;
		
		var htmlString = "";
		
		if(mode == false) {
			htmlString += "<div style='width:" + (_PanelSize[0] * _PanelTypes[(this.type-1)][0]) + "px;'>";
		}
		
		if(this.type != 6) {
		
		htmlString += "<div class='PanelBack'>";
		htmlString += "<div class='PanelTitle'>";
		htmlString += this.title;
		if(this.subtitle != "") {
			htmlString += " > <span class='PanelSubTitle'>" + this.subtitle + "</span>";
		}
		htmlString += "</div>";
		
		if(this.hideLine == false) {
			htmlString += "<div class='PanelContent" + this.type + "'>";
		} else {
			htmlString += "<div class='PanelContent" + this.type + "' style='border-bottom:1px solid #CAC2B8;'>";
		}
		if(this.image != "") {
			var imgType = "";
			this.imageSize == 'Standard' ? imgType = "" : imgType = "_" + this.imageSize;
			if(this.imageIsLink == true) {
				if(this.href != "") {
					htmlString += "<div class='PanelImage" + this.type + imgType + "'><a href='" + this.href + "'>" + this.image + "</a></div>";
				} else {
					htmlString += "<div class='PanelImage" + this.type + imgType + "'>" + this.image + "</div>";
				}
			} else {
				htmlString += "<div class='PanelImage" + this.type + imgType + "'>" + this.image + "</div>";
			}
		}
		var AddContent = true;
		if(this.imageSize != 'Standard') {
			if(this.type == 1 || this.type == 2 || this.type == 4) {
				AddContent = false;
			}
		}
		if(AddContent == true) {
		
		// Video
		if(this.isVideo != false) {
			//if(this.href != "") {
				if(this.type < 4) {
					if(this.image != "") {
						htmlString += "<a href='#PlayVideo' onClick='btnOFF(this.childNodes[0]);PlayVideo(\"" + this.videoXML + "\",\"" + escape(this.videoSummary) + "\");'><img src='images/PlayVid1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='0' vspace='0' style='margin-top:7px;'></a>";
					} else {
						htmlString += "<a href='#PlayVideo' onClick='btnOFF(this.childNodes[0]);PlayVideo(\"" + this.videoXML + "\",\"" + escape(this.videoSummary) + "\");'><img src='images/PlayVid1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='10' vspace='0' style='margin-top:7px;'></a>";
					}
				} else {
					if(this.image != "") {
						htmlString += "<a href='#PlayVideo' onClick='btnOFF(this.childNodes[0]);PlayVideo(\"" + this.videoXML + "\",\"" + escape(this.videoSummary) + "\");'><img src='images/PlayVid1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='10' vspace='2'></a>";
					} else {
						htmlString += "<a href='#PlayVideo' onClick='btnOFF(this.childNodes[0]);PlayVideo(\"" + this.videoXML + "\",\"" + escape(this.videoSummary) + "\");'><img src='images/PlayVid1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='10' vspace='0' style='margin-top:7px;'></a>";
					}
				}
			//}
		}
		
		// Gallery
		if(this.isGallery != false) {
			//if(this.href != "") {
				if(this.type < 4) {
					if(this.image != "") {
						htmlString += "<a href='#ViewGallery' onClick='btnOFF(this.childNodes[0]);ViewGallery(\"" + this.galleryXML + "\");'><img src='images/ViewGallery1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='0' vspace='0' style='margin-top:7px;'></a>";
					} else {
						htmlString += "<a href='#ViewGallery' onClick='btnOFF(this.childNodes[0]);ViewGallery(\"" + this.galleryXML + "\");'><img src='images/ViewGallery1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='10' vspace='0' style='margin-top:7px;'></a>";
					}
				} else {
					if(this.image != "") {
						htmlString += "<a href='#ViewGallery' onClick='btnOFF(this.childNodes[0]);ViewGallery(\"" + this.galleryXML + "\");'><img src='images/ViewGallery1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='10' vspace='2'></a>";
					} else {
						htmlString += "<a href='#ViewGallery' onClick='btnOFF(this.childNodes[0]);ViewGallery(\"" + this.galleryXML + "\");'><img src='images/ViewGallery1.gif' onMouseOver='btnON(this);' onMouseOut='btnOFF(this);' alt='' border='0' hspace='10' vspace='0' style='margin-top:7px;'></a>";
					}
				}
			//}
		}
		
		htmlString += this.content;
		}
		htmlString += "</div>";
		htmlString += "</div>";
		
		htmlString += "<div class='PanelFooter" + this.type + "'>";
		if(this.footer != "") {
			if(this.href != "") {
				htmlString += "<div class='FooterLink'><a href='" + this.href + "'>" + this.footer + "</a></div>";
			} else {
				htmlString += "<div class='FooterLink'>" + this.footer + "</div>";
			}
		}
		htmlString += "</div>";
		} else {
			
			// *********** TYPE 6
			
			htmlString += "<div class='PanelContent" + this.type + "'>";
			htmlString += this.content;
			htmlString += "</div>";
		}
		if(mode == false) {
			htmlString += "</div>";
		}
		if(mode != false) {
			this._HOLDER.innerHTML = htmlString;
			this._HOLDER.style.margin = 0;
			this._HOLDER.style.padding = 0;
			this._HOLDER.style.width = (_PanelSize[0] * _PanelTypes[(this.type-1)][0]) + 'px';
			this._HOLDER.style.position = 'absolute';
			this._HOLDER.style.top = T + 'px';
			this._HOLDER.style.left = L + 'px';
			this._HOLDER.style.display = 'block';
		} else {
			document.open();
			document.write(htmlString);
			document.close();
		}
	};
	
	// ** private properties **
	this._HOLDER = null;
	this._DIVCELL = null;
	this._DRAWMODE = false;
	
	// ** private method **
	this.snap = function() {
		if(this._DRAWMODE == true) {
			var T = this._DIVCELL.offsetTop;
			var L = this._DIVCELL.offsetLeft;
			this._HOLDER.style.top = T + 'px';
			this._HOLDER.style.left = L + 'px';
		}
	};
}
if (!document.defaultView) {
	window.onresize = function() {
		if(!_STANDALONE) {
			// IE reposition menu snaps!
			var MenuBase = MMG_JSMenu.MenuData[0]._base;
			for(var j=0;j<MenuBase.childNodes.length;j++) {
				if(MenuBase.childNodes[j].nodeName == "LI") {
					MMG_JSMenu.AddPosObj(MenuBase.childNodes[j]);
				}
			}
		}
	
		for(var i=0;i<_Panels.length;i++) {
			if(_Panels[i] != 0) {
				if(_Panels[i]._DRAWMODE == true) {
					_Panels[i].snap();
				}
			}
		}
	};
} else {
	window.onresize = function() {
		for(var i=0;i<_Panels.length;i++) {
			if(_Panels[i] != 0) {
				if(_Panels[i]._DRAWMODE == true) {
					_Panels[i].snap();
				}
			}
		}
	};
}

//
// ...swap btn on rollOver...
// ...assumes naming convention : OFF name1.gif/name2.gif ON...

function btnON(n)	{
	r = n.src.toString();
	x = ".gif"
	y = r.indexOf(x) - 1;
	z = r.substring(0,y);
	z += "2.gif"
	n.src = z;
}


// ...swap btn on rollOut...

function btnOFF(n)	{
	r = n.src.toString();
	x = ".gif"
	y = r.indexOf(x) - 1;
	z = r.substring(0,y);
	z += "1.gif"
	n.src = z;
}

