/**
* @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");

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

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

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

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

Venda.ProductDetail.configAlternateView = {
	alternateViewPagedStyle: "",
	alternateViewBehavior: "",
	alternateViewMax: null,
	alternateViewAltText: "",
	alternateViewTitleText: "",
	alternateViewHeaderText: "",
	alternateNext: "",
	alternatePrev: "",
	alternateNextOff: "",
	alternatePrevOff: ""
};

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});
		// if not tick imageware then use script to change link
		if(this.configImageware["enableImageware"] == ""){this.changeViewLargeLink({attValue:attValue,no:0});}
		this.changeAlternateViewSet({attValue:attValue,no:0});
		this.changeDropdown(attValue);
	}
};
/**
* 
* Not change image
*/
Venda.ProductDetail.changeSet_NotImage = function(attValue) {
if (this.allImages[attValue]) {
		this.changeDropdown(attValue);
	}
};

/**
* 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()", 1000);
	},
	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 = ">";}
	
		if (mappingData.currentImage == 0) {
			imgTag = "<div class=\"altFirst\"><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); Venda.ProductDetail.createPrevNext('"+mappingData.attValue+"',"+mappingData.currentImage+"); return false;\" title=\""+mappingData.imgTitle+"\""+imgTagSuffix+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a></div>";
		
		} else if ((mappingData.countData+1) == this.configAlternateView["alternateViewMax"]) {
			imgTag = "<div class=\"altLast\"><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); Venda.ProductDetail.createPrevNext('"+mappingData.attValue+"',"+mappingData.currentImage+"); return false;\" title=\""+mappingData.imgTitle+"\""+imgTagSuffix+"<img src=\""+mappingData.imgSource+"\" alt=\""+mappingData.imgAlt+"\"></a></div>";
		
		} else {
			imgTag = "<div class=\"altView"+(mappingData.currentImage+1)+"\"><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); Venda.ProductDetail.createPrevNext('"+mappingData.attValue+"',"+mappingData.currentImage+"); 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 {
			//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=\""+mappingData.imgAlt+"\" style=\"display:none\" onload=\"Venda.ProductDetail.showMainImage.setImg(this); Venda.ProductDetail.showMainImage.doIt();\">";				
				}
			}
		}
	}

	return imgTag;
};

/**
* Sets the image HTML tag
* @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
* @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 {
	 	// 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 = "<span class=\"largeNotAvail\">"+this.configDefault["viewLargeText"]+"</span>";
		}
	}

	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 iSeq = 0;
	var j = 0;
	var completeAltview = "";

	//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] != "") {
		var isLastImage = (this.allImages[attValue].setxsalt[i+1]) ? false : true;
		completeAltview = completeAltview + this.getImageTag({
														currentImage: i,
														imgSource: this.allImages[attValue].setxsalt[i],
														imgChange: this.allImages[attValue].setmalt[i],
														attValue: attValue,
														imgAlt: imgAlt + (iSeq+1),
														imgTitle: imgAlt + (iSeq+1),
														countData: iSeq, // To find a real number of data that available to view (must have both 'xsalt' and 'malt' image key)
														isAltImage: true
												});
			iSeq++;
		} 
	}
	
	// will be hide by using CSS (class="oneItem") to hide if there has one image in alternative view area
	if (iSeq <= 1) {
		this.configObjArea["objAlternateViewArea"].className = "oneItem";
	} else {
		this.configObjArea["objAlternateViewArea"].className = "";
	}
	
	this.configObjArea["objAlternateViewArea"].innerHTML = "<p class=\"altviewHeader\">"+this.configAlternateView["alternateViewHeaderText"]+"</p>"+completeAltview;
	this.createPrevNext(attValue,currentImage);
	if (this.allImages[attValue].setmalt[0] != "" ) {this.doHighLight(this.configObjArea["objAlternateViewArea"],'');}
};

/**
* 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) {
	$(parentId).find("a").removeClass("selected");
	$(objLink).addClass("selected");
};

/**
* Create Previous and Next link to view an image as other choices
* @param {string} attValue - attribute 1 (color) value
* @param {interger} number - A number of alternative images
*/
Venda.ProductDetail.createPrevNext = function(attValue,number) {
	var nextNumber = -1;
	var prevNumber = -1;
	var i = number;
	var found = false;
	
	while ((i < this.allImages[attValue].setmalt.length) && found == false) {
		if (i + 1 < this.allImages[attValue].setmalt.length) {
			if ((this.allImages[attValue].setmalt[i+1] != "") && (this.allImages[attValue].setxsalt[i+1] != "")) {
				nextNumber = i+1;
				found = true;
			}	
		}
		i++;
	}
	
	var i = number;
	var found = false;
	while ((i > 0) && found == false) {
		if (i - 1 >= 0) {
			if ((this.allImages[attValue].setmalt[i-1] != "") && (this.allImages[attValue].setxsalt[i-1] != "")) { 
				prevNumber = i-1;
				found = true;
			}
		}		
		i--;
	}
	
	if (nextNumber == -1) {
		nextLink = "<span class=\"nextOff\">"+this.configAlternateView["alternateNextOff"]+"</span>";	
	} else {
		nextLink = "<a href=\"#\" onclick=\"Venda.ProductDetail.changeMainImage({attValue: '"+attValue+"', no:"+nextNumber+"}); Venda.ProductDetail.changeViewLargeLink({attValue: '"+attValue+"', no: "+nextNumber+"}); Venda.ProductDetail.createPrevNext('"+attValue+"',"+nextNumber+"); Venda.ProductDetail.doHighLight('#productdetail-altview',true); return false;\">"+this.configAlternateView["alternateNext"]+"</a>";	
	}
	if (prevNumber == -1) {
		prevLink = "<span class=\"prevOff\">"+this.configAlternateView["alternatePrevOff"]+"</span>";
	} else {
		prevLink = "<a href=\"#\" onclick=\"Venda.ProductDetail.changeMainImage({attValue: '"+attValue+"', no:"+prevNumber+"}); Venda.ProductDetail.changeViewLargeLink({attValue: '"+attValue+"', no: "+prevNumber+"}); Venda.ProductDetail.createPrevNext('"+attValue+"',"+prevNumber+"); Venda.ProductDetail.doHighLight('#productdetail-altview',false); return false;\">"+this.configAlternateView["alternatePrev"]+"</a>";			
	}

	this.configObjArea["objPrevNextArea"].innerHTML = "<div id=\"prevImage\">"+prevLink+"</div><div id=\"nextImage\">"+nextLink+"</div>";
};

Venda.ProductDetail.doHighLight = function (parentId,isNext) {
	var curActive = 0;
	var totalElements = 0;
	
	$(parentId).find("a").each(function (index) {
		if ($(this).hasClass("selected")) {
			$(this).removeClass("selected");
			curActive = index;
		} 
		totalElements++;
	});
	
	if (isNext == true) {
		if (curActive < totalElements) {
			curActive++;
		}
	} if (isNext == false) {
		if (curActive > 0) {
			curActive--;
		}
	} 
	$(parentId).find("a").eq(curActive).addClass("selected");
};


/**
* Change attribute dropdown
* @param {string} attValue - attribute 1 (color) value
*/
Venda.ProductDetail.changeDropdown = function(attValue) {
	for (var i = 0; i < this.configObjArea["objDropdown"].options.length; i++) {
		if (this.configObjArea["objDropdown"].options[i].value == attValue) {
			this.configObjArea["objDropdown"].selectedIndex = i;
		}
	}
	this.configObjArea["objProduct"].changeAttributes(this.configObjArea["objDropdown"]);
};

/**
* Change
* @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
* @returns {boolean} isShowAltview - return false if there has one image
*/
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"] != "") {
		alternateView = alternateView + "<div id=\"alternateViewList\">";
		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++;
			}
		}
		alternateView = alternateView + "</div>";
	}
	return [alternateView,countData];
};

/**
* Show enlarge popup window
* @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 allData = this.createPopupPage(attValue,number);
	var completeAltview = "";
	var isShowAltview = allData[1];
	
	//Rearrange alternative view images
	completeAltview = "<div id=\"alternateViewHeader\">"+this.configAlternateView["alternateViewHeaderText"]+"</div>" + allData[0];

	// Alternative View Images area
	if (isShowAltview <= 1) {
		completeAltview = "<div id=\"alternateView\" class=\"forOneItem\">"+completeAltview+"</div>";
	} else {
		completeAltview = "<div id=\"alternateView\">"+completeAltview+"</div>";
	}
	
	// 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+"<div id=\"prevnext\"></div>"+ completeAltview + 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) {
	$("#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.enlargePanel = new YAHOO.widget.Panel("enlarge_panel",  
														{ 
															fade: 0.24,			
															fixedcenter:false,
															draggable: true,
															zindex:4,
															modal:true,
															visible:false,
															x:xPosition,
															y:10
														}
													);