/**
* @fileoverview ProductDetail.js: A module used for client specific functionality
*
* This module defines a single symbol named "Venda.ebiz"
* all ebiz utility functions are stored as properties of this namespace
* functions that are spacific this site shoudl be added to this file only.
*/

//declare namespace for ebiz
Venda.namespace("ProductDetail");

//declare object property
Venda.ProductDetail.jq = jQuery;


/**
 * Stub function is used to support JSDoc.
 * @class Venda.
 * @constructor
 */
 
/**
*  Alternate Views
*/
Venda.ProductDetail.allImages = new Array();

Venda.ProductDetail.configObjArea = {
	objDefaultImage: null,
	objProduct: null,
	objMediumArea: null,
	objLinkArea: null,
	objAlternateViewArea: null
};

Venda.ProductDetail.configDefault = {
	productName: "",
	mediumAltText: "",
	mediumTitleText: "",
	viewLargeTitle: "",
	viewLargeText: "",
	largeNotAvailText: "",
	largeNotAvailAltText: "",
	loadingImage: "",
	noImage: ""
};

Venda.ProductDetail.configImageware = {
	enableImageware: "",
	zoomableText: "",
	zoomableImagelink: "",
	zoomableTextlink: ""
};

Venda.ProductDetail.configAlternateView = {
	alternateViewPagedStyle: "",
	alternateViewBehavior: "",
	alternateViewAltText: "",
	alternateViewTitleText: "",
	alternateViewHeaderText: ""
};

Venda.ProductDetail.configPopupPanel = {
	popupHeader: "",
	loadingHeader: "",
	loadingPanel: "",	
	closePanel: "",
	closePanelTitle: "",
	closeTextLink: ""
};

/**
* Sets the config values to each config type
* @param {string} configType this is an configuration type name
* @param {array} settings this is the value of each configuration type
*/
Venda.ProductDetail.init = function(configType,settings) {
	for (var eachProp in settings) {
		this[configType][eachProp] = settings[eachProp];
	}
};

Venda.ProductDetail.loadImage = function(attValue,imgSources) {
	this.allImages[attValue] = imgSources;
};
/**
* Change
* @param {string} attValue - attribute 1 (color) value
*/
Venda.ProductDetail.changeSet = function(attValue) {
if (this.allImages[attValue]) {
		this.changeMainImage({attValue:attValue});
		this.changeViewLargeLink({attValue:attValue,no:0});
		this.changeAlternateViewSet({attValue:attValue,no:0});
	}
};

/**
* Puts loading image during the time that main image is loaded to show
* @param {object} imgObj - 
* @returns {function} imgTag - HTMLCollection of an image tag
*/
Venda.ProductDetail.showMainImage = {
	imgObj: null,
	doIt: function() {
		setTimeout("Venda.ProductDetail.showMainImage.hideLoading()", 1500);
	},
	hideLoading: function() {
		if (document.getElementById("loadingMain")) {
			document.getElementById("loadingMain").style.display = "none";
		}	
		Venda.ProductDetail.showMainImage.imgObj.style.display = "block";
	},
	setImg: function(imgObj) {
		this.imgObj = imgObj;
	}
};

/**
* Gets the image HTML tag
* @param {object} mappingData - properties collection of each image
* @returns {string} imgTag - HTMLCollection of an image tag
*/
Venda.ProductDetail.getImageTag = function(mappingData) {
	var imgTag = "";
	var imgTagSuffix = "";
	
	// get image tag for 'Alternative images'
	if (mappingData.isAltImage && mappingData.imgChange) {
		if (this.configAlternateView["alternateViewBehavior"] == "onmouseover") { imgTagSuffix = " onclick=\"return false;\">"; } else { imgTagSuffix = ">";}
		
		// define classname for each image
		if (mappingData.countData == 0) {
			imgTag = "<div class=\"isFirst\"><a href=\""+mappingData.imgChange+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changeMainImage({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.changeViewLargeLink({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.highlightAltView('#productdetail-altview',this); return false;\" title=\""+mappingData.imgTitle+"\""+imgTagSuffix+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a></div>";
		
		} else if (mappingData.isLastImage == "") {
			imgTag = "<div class=\"isLast\"><a href=\""+mappingData.imgChange+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changeMainImage({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.changeViewLargeLink({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.highlightAltView('#productdetail-altview',this); return false;\" title=\""+mappingData.imgTitle+"\""+imgTagSuffix+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a></div>";
		
		} else if ((mappingData.countData%2) == 0) {
			imgTag = "<div class=\"isOdd\"><a href=\""+mappingData.imgChange+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changeMainImage({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.changeViewLargeLink({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.highlightAltView('#productdetail-altview',this); return false;\" title=\""+mappingData.imgTitle+"\""+imgTagSuffix+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a></div>";			
		
		} else {
			imgTag = "<div class=\"isEven\"><a href=\""+mappingData.imgChange+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changeMainImage({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.changeViewLargeLink({attValue: '"+mappingData.attValue+"', no: "+mappingData.currentImage+"}); Venda.ProductDetail.highlightAltView('#productdetail-altview',this); return false;\" title=\""+mappingData.imgTitle+"\""+imgTagSuffix+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a></div>";			
		}
	}
	
	// get image tag for 'Main images'
	if (mappingData.isMainImage) {
		// if 'no image' is shown at the 1st page load when user click any places and back to the main image it should be the same result as 1st time
		if ((mappingData.imgSource == "") && (mappingData.noImage != "")) {
			mappingData.imgSource = mappingData.noImage;
		}
		
		if (this.configImageware["enableImageware"] != "") {
			//use imageware
			if (this.allImages[mappingData.attValue].clicked[mappingData.currentImage] == true) {
				imgTag = this.configImageware["zoomableImagelink"]+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a>";
			} else {
				imgTag =  this.configImageware["zoomableImagelink"]+this.configDefault["loadingImage"]+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\" style=\"display:none\" onload=\"Venda.ProductDetail.showMainImage.setImg(this); Venda.ProductDetail.showMainImage.doIt();\"></a>";				
			}
		} else {
			//does not use imageware
			if (mappingData.imgPopup != "") {
				if (this.allImages[mappingData.attValue].clicked[mappingData.currentImage] == true) {
					imgTag = "<a href=\""+mappingData.imgPopup+"\" onclick=\"Venda.ProductDetail.doPopup('"+mappingData.attValue+"',this.href, "+mappingData.currentImage+"); return false;\" title=\""+mappingData.imgTitle+"\"><img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a>";					
				} else {
					imgTag = this.configDefault["loadingImage"]+"<a href=\""+mappingData.imgPopup+"\" onclick=\"Venda.ProductDetail.doPopup('"+mappingData.attValue+"',this.href, "+mappingData.currentImage+"); return false;\" title=\""+mappingData.imgTitle+"\"><img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\" style=\"display:none\" onload=\"Venda.ProductDetail.showMainImage.setImg(this); Venda.ProductDetail.showMainImage.doIt();\"></a>";	
				}
			} else {
				if (this.allImages[mappingData.attValue].clicked[mappingData.currentImage] == true) {
					imgTag = "<img src=\""+mappingData.imgSource+"\" alt=\""+this.configDefault["largeNotAvailAltText"]+"\">";
				} else {
					imgTag = this.configDefault["loadingImage"]+"<img src=\""+mappingData.imgSource+"\" alt=\""+this.configDefault["largeNotAvailAltText"]+"\" style=\"display:none\" onload=\"Venda.ProductDetail.showMainImage.setImg(this); Venda.ProductDetail.showMainImage.doIt();\">";				
				}
			}
		}
	}

	return imgTag;
};

/**
* Sets the image HTML tag and update main image
* @param {object} mappingData - properties collection of each image
* 
*/
Venda.ProductDetail.changeMainImage = function(mappingData) {
	var attValue = mappingData.attValue;
	var currentImage = mappingData.no | 0;
	var imgSource = this.allImages[attValue].setmalt[currentImage];
	var imgPopup = this.allImages[attValue].setlalt[currentImage];
	
	var mainImage = this.getImageTag({
										noImage: this.configDefault["noImage"]["medium"],
										imgSource: imgSource,
										imgPopup: imgPopup,
										attValue: attValue,
										imgAlt: this.configDefault["mediumAltText"],
										imgTitle: this.configDefault["mediumTitleText"],
										currentImage: currentImage,
										isMainImage: true
									});
									
	this.configObjArea["objMediumArea"].innerHTML = mainImage;
	this.allImages[attValue].clicked[mappingData.no] = true;
	if (this.configImageware["enableImageware"] != "") {YAHOO.util.Event.addListener(["zoom_img2"],"click", Venda.Widget.Lightbox.showImageware);}
};

/**
* Sets the image HTML tag to view large link
* @param {object} mappingData - properties collection of each image
*/
Venda.ProductDetail.changeViewLargeLink = function(mappingData) {
	var viewLarge = "";
	var attValue = mappingData.attValue;
	var currentImage = mappingData.no || 0;
	var imgPopup = this.allImages[attValue].setlalt[mappingData.no];

	if (this.configImageware["enableImageware"] != "") {
	 	// use imageware to see large image
	 	viewLarge = this.configImageware["zoomableTextlink"]+this.configImageware["zoomableText"]+"</a>";
	} else {
	 	// does not use imageware to see large image
		if (imgPopup != "") {
		 	viewLarge = "<a href=\""+imgPopup+"\" onclick=\"Venda.ProductDetail.doPopup('"+attValue+"',this.href, "+currentImage+"); return false;\" title=\""+this.configDefault["viewLargeTitle"]+"\">"+this.configDefault["viewLargeText"]+"</a>";
	 	} else {
			viewLarge = "&nbsp;";
		}
	}
	
	this.configObjArea["objLinkArea"].innerHTML = viewLarge;
	if (this.configImageware["enableImageware"] != "") {YAHOO.util.Event.addListener(["zoom_link2"],"click", Venda.Widget.Lightbox.showImageware);}
};

/**
* Generate entire images inside alternative view area
* @param {string} attValue - attribute 1 (color) value
* 
*/
Venda.ProductDetail.changeAlternateViewSet = function(mappingData) {
	var attValue = mappingData.attValue;
	var currentImage = mappingData.no | 0;
	var altviewData = "";
	var isLastImage = "";
	var iNum = 0;
	
	//product name - attribute value (if it does) - Additional view [no.]  is used to define a short description of the image in 'alt' and 'title' attribute
	var imgAlt = (attValue) ? this.configDefault["productName"] + " - " + attValue + " - " + this.configAlternateView["alternateViewAltText"] : this.configDefault["productName"] + " - " + this.configAlternateView["alternateViewAltText"];

	for (var i = 0; i < this.allImages[attValue].setmalt.length; i++) {
		if (this.allImages[attValue].setxsalt[i] != "" && this.allImages[attValue].setmalt[i] != "") {
			altviewData = altviewData + this.getImageTag({
															currentImage: i,
															imgSource: this.allImages[attValue].setxsalt[i],
															imgChange: this.allImages[attValue].setmalt[i],
															isLastImage: this.allImages[attValue].setxsalt[i+1],
															attValue: attValue,
															imgAlt: imgAlt + (iNum+1),
															imgTitle: imgAlt + (iNum+1),
															countData: iNum, // To find a real number of data that available to view (must have both 'xsalt' and 'malt' image key)
															isAltImage: true
														});
				iNum++;
		} 
	}
	
	if (iNum != 0) {
		altviewData = "<p class=\"altviewHeader\">"+this.configAlternateView["alternateViewHeaderText"]+"</p>" + altviewData;
	} 
	if (iNum == 1) {
		// add class if there is only 1 alternate image.
		this.configObjArea["objAlternateViewArea"].className = "isOne";
	}
	
	this.configObjArea["objAlternateViewArea"].innerHTML = altviewData;
};

/**
* Hightlight current image to make user know which one is viewing
* @param {object} objLink - An element id (or object) representing the list of items in the alternative images
* @param {string} parentId - An element id to specific alternative images area
*/
Venda.ProductDetail.highlightAltView = function (parentId,objLink) {
	Venda.ProductDetail.jq(parentId).find("a").removeClass("selected");
	Venda.ProductDetail.jq(objLink).addClass("selected");
};

/**
* Generate group of alternate views
* @param {string} attValue - attribute 1 (color) value
* @param {interger} number - A number of current image by ordering
* @returns {string} alternateView - HTMLCollection of Alternative view images
*/
Venda.ProductDetail.createPopupPage = function(attValue,number) {
	var newDataLarge = new Array();
	var	newDataXSmall = new Array();
	var countData = 0;
	var alternateView = "";	// define entire images as pagination style
	// product name - attribute value (if it does) - Additional view [no.]  is used to define a short description of the image in 'alt' attribute
	var imgAlt = (attValue) ? this.configDefault["productName"] + " - " + attValue + " - " + this.configAlternateView["alternateViewAltText"] : this.configDefault["productName"] + " - " + this.configAlternateView["alternateViewAltText"];

	if (this.configAlternateView["alternateViewPagedStyle"] != "") {
		for (var i = 0; i < this.allImages[attValue].setxsalt.length; i++) {
			if (this.allImages[attValue].setxsalt[i] != "" && this.allImages[attValue].setlalt[i] != "") {
				if (this.configAlternateView["alternateViewPagedStyle"] == "image") {
					// Start image list
					if (i == number) {
						alternateView = alternateView + "<a href=\""+this.allImages[attValue].setlalt[i]+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changePopup(this); Venda.ProductDetail.highlightAltView('#alternateViewList',this); return false;\" class=\"selected\" title=\""+imgAlt + (i+1)+"\""; 								
					} else {
						alternateView = alternateView + "<a href=\""+this.allImages[attValue].setlalt[i]+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changePopup(this); Venda.ProductDetail.highlightAltView('#alternateViewList',this); return false;\" title=\""+imgAlt + (i+1)+"\"";	
					}
					if (this.configAlternateView["alternateViewBehavior"] == "onmouseover") {alternateView = alternateView + " onclick=\"return false;\"><img src=\""+this.allImages[attValue].setxsalt[i]+"\" alt=\""+imgAlt + (i+1)+"\"></a>";} else {alternateView = alternateView + "><img src=\""+this.allImages[attValue].setxsalt[i]+"\" alt=\""+imgAlt + (i+1)+"\"></a>";}
					// End image list
				} else {
					// Start number list
					if (i == number) {
						alternateView = alternateView + "<a href=\""+this.allImages[attValue].setlalt[i]+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changePopup(this); Venda.ProductDetail.highlightAltView('#alternateViewList',this); return false;\" class=\"selected\" title=\""+imgAlt + (i+1)+"\"";
					} else {
						alternateView = alternateView + "<a href=\""+this.allImages[attValue].setlalt[i]+"\" "+this.configAlternateView["alternateViewBehavior"]+"=\"Venda.ProductDetail.changePopup(this); Venda.ProductDetail.highlightAltView('#alternateViewList',this); return false;\" title=\""+imgAlt + (i+1)+"\"";
					}
					if (this.configAlternateView["alternateViewBehavior"] == "onmouseover") { alternateView = alternateView + " onclick=\"return false;\"><span>"+((i+1))+"</span></a>"; } else { alternateView = alternateView + "><span>"+(i+1)+"</span></a>";}
					// End number list
				}
				countData++;
			}
		}
	}
	
	if (countData != 0 && countData != 1) {
		alternateView = "<div id=\"alternateViewList\"><p class=\"altviewHeader\">"+this.configAlternateView["alternateViewHeaderText"]+"</p>"+alternateView+"</div>";
	}
	if (countData == 1) {
		// add class if there is only 1 alternate image.
		alternateView = "<div id=\"alternateViewList\" class=\"isOne\"><p class=\"altviewHeader\">"+this.configAlternateView["alternateViewHeaderText"]+"</p>"+alternateView+"</div>";
	}
	return alternateView;
};

/**
* Represent the lightbox for large image also displays the available xsmall thumbs to choose. 
* @param {string} attValue - attribute 1 (color) value
* @param {string} sLink - URLs to the current Large key size image of selected alt-img
* @param {interger} number - A number of current image by ordering
*/
Venda.ProductDetail.doPopup = function(attValue,sLink,number) {
	var alternateView = this.createPopupPage(attValue,number);
	
	// Main image in 'popupContents' area
	var mainImage = "<div id=\"mainImage\"><a onclick=\"Venda.ProductDetail.enlargePanel.hide(); return false;\" href=\"#\" title=\""+this.configPopupPanel["closePanelTitle"]+"\"><img src=\""+sLink+"\" id=\"enlargedpopup\" name=\"enlargedpopup\" onload=\"Venda.ProductDetail.setWidthPanel(Venda.ProductDetail.enlargePanel, this); Venda.ProductDetail.loadingPanel.hide(); Venda.ProductDetail.enlargePanel.show();\"></a></div>";
	var strCloseText = "<div id=\"closeWindow\"><a href=\"#\" onclick=\"Venda.ProductDetail.enlargePanel.hide(); return false;\">"+this.configPopupPanel["closeTextLink"]+"</a></div>";
	Venda.ProductDetail.loadingPanel.setHeader("<div class=\"tl\"></div><span>"+Venda.ProductDetail.configPopupPanel.loadingHeader+"</span><div class=\"tr\"></div>");
	Venda.ProductDetail.loadingPanel.setBody("<img src=\""+Venda.ProductDetail.configPopupPanel.loadingPanel+"\"/>");
	Venda.ProductDetail.loadingPanel.render(document.body);
	Venda.ProductDetail.loadingPanel.show();

	Venda.ProductDetail.enlargePanel.setHeader("<div class=\"tl\"></div><span>"+Venda.ProductDetail.configPopupPanel.popupHeader+"</span><div class=\"tr\"></div>");
	Venda.ProductDetail.enlargePanel.setBody( "<div class=\"popupContents\">"+mainImage + alternateView + strCloseText+"</div>");
	Venda.ProductDetail.enlargePanel.render(document.body);
};

/**
* Change
* @param {string} objLink - URLs to the current Large key size image of selected alt-img
*/
Venda.ProductDetail.changePopup = function(objLink) {
	Venda.ProductDetail.jq("#enlargedpopup").attr({src:objLink.href});
};

/**
* Set panel dimension
* @param {object} panel - 
* @param {object} objImage - 
*/
Venda.ProductDetail.setWidthPanel = function (panel,objImage) {
	document.getElementById("tag-invtname").style.display = "inline";
	var widthValue = (objImage.width > (document.getElementById("tag-invtname").offsetWidth + 100)) ? objImage.width + 20: document.getElementById("tag-invtname").offsetWidth + 130;
	panel.cfg.setProperty("width", widthValue + "px");
	document.getElementById("tag-invtname").style.display = "none";
};

var xPosition = (document.documentElement.clientWidth - 550) / 2;
//var yPosition = document.documentElement.scrollTop;
Venda.ProductDetail.loadingPanel = new YAHOO.widget.Panel("loading_panel",  
														{ 
															width:"240px", 
															fixedcenter:true, 
															close:true, 
															draggable:false,
															zindex:3,
															modal:true,
															visible:false,
															x:xPosition,
															y:10
														}
													);
Venda.ProductDetail.loadingPanel.showMaskEvent.unsubscribe();
Venda.ProductDetail.loadingPanel.hideMaskEvent.unsubscribe();

Venda.ProductDetail.enlargePanel = new YAHOO.widget.Panel("enlarge_panel",  
														{ 
															fade: 0.24,			
															fixedcenter:false,
															draggable: true,
															zindex:4,
															modal:true,
															visible:false,
															x:xPosition,
															y:10
														}
													);
Venda.ProductDetail.enlargePanel.showMaskEvent.unsubscribe();
Venda.ProductDetail.enlargePanel.hideMaskEvent.unsubscribe();

Venda.Ebiz.setLightboxVDO = function(divId){
    YAHOO.util.Event.addListener(divId, "click", Venda.Ebiz.showVDO);
    YAHOO.util.Event.addListener(window, "load", Venda.Ebiz.doPopupVDO);
};

Venda.Ebiz.showVDO = function(){
	// Globals
	// Major version of Flash required
	var requiredMajorVersion = 8;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor version of Flash required
	var requiredRevision = 0;

	var vdoName = document.getElementById('vdoview').innerHTML;
	//var vdoView = '<script src="<venda_ebizurl>/content/ebiz/<venda_bsref>/resources/js/AC_RunActiveContent2.js" language="javascript"></script><script language="javascript">AC_FL_RunContent("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0","width", "360","height", "264","src", "'+ vdoName +'","quality", "high","pluginspage", "http://www.macromedia.com/go/getflashplayer","align", "middle","play", "true","loop", "true","scale", "showall","wmode", "window","devicefont", "false","id", "slideshow","bgcolor", "#000000","name", "med","menu", "true","allowFullScreen", "true","allowScriptAccess","sameDomain","movie", "'+ vdoName +'","base",".","salign", "");</script>';
	//var vdoView = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="360" height="264"><param name="flashvars" value="file=http://www.walkernews.net/wp-content/uploads/2008/01/LionLove.flv&image=http://www.walkernews.net/wp-content/uploads/2008/01/Lion-Hug-Rescuer.JPG" /><param name="movie" value="http://www.walkernews.net/mediaplayer.swf" /><embed src="http://www.walkernews.net/mediaplayer.swf" width="360" height="264" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="file=http://www.walkernews.net/wp-content/uploads/2008/01/LionLove.flv&image=http://www.walkernews.net/wp-content/uploads/2008/01/Lion-Hug-Rescuer.JPG" /></object>';
	var vdoView = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="360" height="264" id="med" align="left"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="base" value="." /><param name="movie" value="'+ vdoName +'.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />    <embed src="'+ vdoName +'.swf" quality="high" bgcolor="#000000" width="360" height="264" name="med" base="." align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	
	Venda.Ebiz.loadingPanel.setHeader('<div class="tl"></div><span>'+document.getElementById('tag-lightboxloadmessage').innerHTML+'</span><div class="tr"></div>');
	Venda.Ebiz.loadingPanel.setBody('<span id="loadPanelImg" class="loadPanelImgExtra"></span>');														
	Venda.Ebiz.loadingPanel.render(document.body);
	Venda.Ebiz.loadingPanel.show();
	
	Venda.Ebiz.vdoPanel.setHeader('<div class="tl"></div><span>'+document.getElementById('tag-invtname').innerHTML+'</span><span id="closelightbox" class="container-close"></span><div class="tr"></div>');		
	
	// Version check based upon the values entered above in "Globals"
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	// Check to see if the version meets the requirements for playback
	if (hasReqestedVersion) {
		Venda.Ebiz.vdoPanel.setBody("<div id='vdo'> "+ vdoView +"</div>");
	} else {  // flash is too old or we can't detect the plugin
		Venda.Ebiz.vdoPanel.setBody("<div id='vdo_noplugin'> </div>");
		ajaxFunction('/page/installflash?layout=noheaders','vdo_noplugin',null,null);
	}
	
	Venda.Ebiz.loadingPanel.hide();
	Venda.Ebiz.vdoPanel.show();
	Venda.Ebiz.vdoPanel.render(document.body);
	YAHOO.util.Event.addListener('closelightbox', 'click', Venda.Ebiz.lightboxHide);
};

Venda.Ebiz.doPopupVDO = function(){
	Venda.Ebiz.vdoPanel = new YAHOO.widget.Panel("vdocontent_panel",  
		{ 
			fade: 0.24,															
			close:false, 
			fixedcenter:true,
			draggable: true,
			zindex:4,
			modal:true,
			visible:false
		} 
	);
	Venda.Ebiz.loadingPanel = new YAHOO.widget.Panel("wait_panel",  
		{ 
			width:"240px", 
			fixedcenter:true, 
			close:false, 
			draggable:false, 
			zindex:3,
			modal:true,
			visible:false
		} 
	);
	Venda.Ebiz.vdoPanel.setBody("<div id='vdo'> </div>");
	Venda.Ebiz.vdoPanel.render(document.body);
};

/**
 * Hide lightbox popup and clean up
 */
Venda.Ebiz.lightboxHide = function() {
	Venda.Ebiz.cleanUp();
};

/**
 * Clean up
 * Remove eventListener and other clean up tasks
 */
Venda.Ebiz.cleanUp = function() {
	YAHOO.util.Event.removeListener('closelightbox', 'click');
	Venda.Ebiz.vdoPanel.setBody("<div id='vdo'> </div>");
	Venda.Ebiz.vdoPanel.hide();
};

