(function(){
GupShup.html.picLib.popupId = 'picGalleryPopUp';;

GupShup.html.picLib.showPostPopUp = function(ref,imgId, forGreeting){
	var popup = 'mainPopUp';
	
	if(forGreeting == true)
		popup = 'mainPopUpForGreeting';

	var obj=document.getElementById(popup);
	var pos = GupShup.html.util.getElementPosition(ref);
	var objW = obj.offsetWidth;
	if(typeof GupShup.html.picLib[popup] == 'undefined')
	{
		GupShup.html.picLib[popup] = new YAHOO.widget.Menu(popup,{ position: "dynamic", x : (pos.x) , y : (pos.y + pos.h + 5) , clicktohide: true });
		GupShup.html.picLib[popup].render();
	}
	else
	{
		GupShup.html.picLib[popup].cfg.setProperty("x", (pos.x));
		GupShup.html.picLib[popup].cfg.setProperty("y", (pos.y + pos.h + 5));
	}
	GupShup.html.picLib[popup].show();
	GupShup.html.picLib.setActiveId(imgId);
}

GupShup.html.picLib.showRhtBarPostPopUp = function(ref,imgId, iframeId){
	var obj=document.getElementById('sidePopUp');
	var pos = GupShup.html.util.getElementPosition(ref);
	
	//Add IFRAME POS  w.r.t DOM,  useful in case we need to move popup over element present in IFRAME
	if(typeof iframeId == "string")
	{
		var iframe = GupShup.html.util.getElementPosition(document.getElementById(iframeId));
		pos.x += iframe.x;
		pos.y += iframe.y;
	}
	
	var objW = obj.offsetWidth;
	if(typeof GupShup.html.picLib.sidePopup == 'undefined')
	{
		GupShup.html.picLib.sidePopup = new YAHOO.widget.Menu("sidePopUp",{ position: "dynamic", x : (pos.x) , y : (pos.y + pos.h + 5) , clicktohide: true });
		GupShup.html.picLib.sidePopup.render();
	}
	else
	{
		GupShup.html.picLib.sidePopup.cfg.setProperty("x", (pos.x));
		GupShup.html.picLib.sidePopup.cfg.setProperty("y", (pos.y + pos.h + 5));
	}
	GupShup.html.picLib.sidePopup.show();
	GupShup.html.picLib.setActiveId(imgId);
}

GupShup.html.picLib.closePicGallery = function(location){
	if(GupShup.html.picLib.activeId > 0)
	{
		var del = "?";
		if(location.indexOf("?") > 0)
			del = "&";
		GupShup.html.actions.pageReload(location + del +"picId=" + GupShup.html.picLib.activeId);
	}
}

GupShup.html.picLib.sendPicPendingAction = function(params){
	GupShup.html.pendingAction.sendPicPendingAction(params + GupShup.html.picLib.activeId);
	GupShup.html.util.hideElement(GupShup.html.picLib.popupId);
}

})();
