/** 
 * @fileoverview This page is used for loading gallery details through ajax
*/

/**
 * Select the current Gallery and load the current page Gallery details.
 * @throws Shows the current page Gallery details.
 */
/** 
 * vMenu is used for menu index 
 * @type string
 * pmId is used for selected menu index 
 * @type int
 * pmMenuCount is used for total menu count 
 * @type int
 * vIndex is used for looping 
 * @type int
 * vUrl is used for ajax gallery page path
 * @type string
 * pmOrderBy is used for smilebook listing display order type 
 * @type int
 * pmCurPage is used for current page no 
 * @type int
 * pmTotalCnt is used for total smilebook count 
 * @type int
 * pmPhotobookId is specify the smilebook id  
 * @type int
 */
var vMenu=0;
var vFlag = 0;
var pmCurPage = 0;
function loadgallerydata(pmId,pmMenuCount,pmCurPage,pmOrderBy,pmTotalCnt,pmPhotobookId)
{
	if(pmCurPage == 'NULL')
	{
		if(document.getElementById('menu_'+pmId).className=='cartMenuItemSelected')
		return false;
	}
	for(vIndex=0;vIndex<=pmMenuCount;vIndex++)
	{
		vMenu 		=	'menu_'+vIndex;
		document.getElementById(vMenu).className='cartMenuItems1';
	}
	vMenu 		=	'menu_'+pmId;
	document.getElementById(vMenu).className='cartMenuItemSelected';
	vUrl="comp/cmp_gallery/web/gallerylist_ajax.php?id="+pmId+"&vCurPage="+pmCurPage+'&orderby='+pmOrderBy+'&totalcnt='+escape(pmTotalCnt)+'&photobookid='+pmPhotobookId;
		document.getElementById("loadinnerpage").innerHTML="<table align='left' width='100'><tr><td></td></tr><tr><td><span class='loading'>Loading...</span></td><tr></table>";
			document.getElementById("orderby").style.visibility='visible';
		ajaxrequest(vUrl,"displaygalleryPage",document.getElementById("loadinnerpage"),0);
		
}
/**
 * Select the current Gallery and load the current category Gallery details.
 * @throws Shows the current page Gallery details.
 */
function loadmenudata(pmId,pmMenuCount)
{
	pmOrderBy = document.getElementById("hidorderby").value;
	loadgallerydata(pmId,pmMenuCount,'NULL',pmOrderBy,'NULL');
}
/**
 * Get the gallery details from Ajax Request and assign the value to Div.
 * @throws Shows the current page Gallery details.
 */
 /**
 * txt is used recieving content from ajax request
 * @type string
  * obj is used for div object
 * @type object
 */
function displaygalleryPage(txt,obj)
{	
	obj.innerHTML= txt;
}
/**
 * Load the Flash for Book Preview.
 */
 /**
 * QryString is used query string value for flash
 * @type string
  * pmId is specify the smilebook id.
 * @type int
 */
function displayBookPreview(QryString,pmId)
{
		vFlag = 1;
		var requiredMajorVersion = 9;
		var vFlashObj = "";
		var requiredMinorVersion = 0;
		var requiredRevision = 124;
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		if(hasProductInstall && !hasRequestedVersion) 
		{
			var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
			var MMredirectURL = window.location;
			document.title = document.title.slice(0, 47) + " - Flash Player Installation";
			var MMdoctitle = document.title;
			AC_FL_RunContent
			(
				"src", "comp/cmp_photobook/interface/playerProductInstall.swf",
				"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
				"width", "100%",
				"height", "100%",
				"align", "middle",
				"id", "CPBPhotoBook",
				"quality", " high",
				"transparency"," true",
				"name", " CPBPhotoBook",
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				"pluginspage", "http://www.adobe.com/go/getflashplayer",
				"allowFullScreen", "true" 
			)
		}
		else if (hasRequestedVersion) 
		{
		vFlashObj = '<object align="middle" id="CPBPhotoBook" name="CPBPhotoBook" type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="500px">' +
							'<param name="movie" value="comp/cmp_photobook/interface/PhotobookPreview.swf?'+QryString+'&random='+ escape(Math.random())+'>' +
							'<param name="quality" value="high">' +
							'<param name="menu" value="false">'+
							'<param name="swLiveConnect" value="true">'+
							'<param name="FlashVars" value="en">'+
							'<param name="allowScriptAccess" value="always">'+
							'<param name="bgcolor" value="#eff4f8">'+
							'<embed src="comp/cmp_photobook/interface/PhotobookPreview.swf?'+QryString+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="500px" bgcolor="#eff4f8"></embed>' + 
							'</object>';
				//document.getElementById("loadinnerpage").style.height = "500px";
				document.getElementById("loadinnerpage").innerHTML = vFlashObj;
				
		} 
		else 
		{  
			var alternateContent = '<div align="center" style="padding:50px" class="textGreyNormal">To view this page you need the latest version of Adobe flash player. <br>Click the link to get the latest Adobe flash player. '
			+ '<a class="greyLink" href=http://www.adobe.com/go/getflash/>Get Flash</a></div>';
			document.getElementById("loadinnerpage").innerHTML=alternateContent; 
		}
		//document.title = "SmileBooks Online";
		document.getElementById("orderby").style.visibility = "hidden";
		if(pmId)
		{
		vMenu 		=	'menu_'+pmId;
		document.getElementById(vMenu).className='cartMenuItemSelected';
		}
}
/**
 * Remove own photobook from gallery.
 */
 /**
 * pmCurpage is used current page no
 * @type int
  * pmCount is specify the smilebook count.
 * @type int
 */
function removebook(pmCurpage,pmCount)
{
	var pmPhotobookId = new Array();
	var Index = 0;
	for (var vLoop=0; vLoop < pmCount; vLoop++)
	{
		var chkBook ="chkBook_"+vLoop
		if(document.getElementById(chkBook))
		{
			var hidBookid ="hidbook_"+vLoop
			if(document.getElementById(chkBook).checked==true)
			{
				if(document.getElementById(hidBookid).value)
				{
					pmPhotobookId[Index] = document.getElementById(hidBookid).value
					Index += 1;
				}
			}
		}
	}
	if(Index>0)
		ProductPaging(pmCurpage,pmPhotobookId);
	else
	{
		alert("<?=cfLngAlertselectBook?>")
		return false;
	}
}
/**
 * Book Preview in Full screen.
 */
 /**
 * bookID specify smilebookid
 * @type int
 */

function windowOpen(bookID)
{
	nwin=window.open ("comp/cmp_photobook/web/book_preview.php"+'?photobookid='+bookID+'&mode=GALLERY&displayType=2',"mywindow","fullscreen=yes,location=0,status=0,scrollbars=1")
	nwin.focus();
} 