var puzzle = {
    popupWin : '',
	book : {
		open : function(bookcode,base_url){
			if(!base_url) base_url='';
			try{
				var screenwidth = window.screen.width;
				var screenheight = window.screen.height;
			}catch(e){
				var screenwidth = screen.availWidth;
				var screenheight = screen.availHeight;
			}
			var pWidth = screenwidth - 10;
			var pHeight = screenheight - 80;		
			
			var status = "width="+pWidth+",height="+pHeight+",screenX=0,left=0,screenY=0,top=0,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=no,location=no,directories=no";
			var ebook = window.open( base_url+'/Viewer/'+bookcode,Math.round(Math.random() * 100),status );
			ebook.focus();
		},
		error_log : function(bookcode,base_url){
			try{
				var screenwidth = window.screen.width;
				var screenheight = window.screen.height;
			}catch(e){
				var screenwidth = screen.availWidth;
				var screenheight = screen.availHeight;
			}
			var pWidth = 500;
			var pHeight = 500;
			var left = (screenwidth - pWidth) /2;
			var top = (screenheight - (pHeight+100)) /2;
			var status = "width="+pWidth+",height="+pHeight+",screenX=0,left="+left+",screenY=0,top="+top+",resizable=yes,toolbar=no,status=false,menubar=no,scrollbars=yes";
			
			var popupWin = window.open(base_url+"popup/error_log/"+bookcode,popupWin,status );
			popupWin.focus();
		}
	},
	category : {
		all_list : function(){
			categoryAll();
		},
		afterClick : function(categoryId,parentId){
			categorySub(categoryId);
			//puzzle.class_id = categoryId;
			//puzzle.display.list.ajax_booklist(puzzle.outcnt,1);
		}
	},
    my_category : {
		all_list : function(){
			categoryAll();
		},
		afterClick : function(categoryId,parentId){
			categorySub(categoryId);
			//puzzle.class_id = categoryId;
			//puzzle.display.list.ajax_booklist(puzzle.outcnt,1);
		}
	},

	mymenu : {
		select : function(val,base_url,bookcode,cnt)
		{
			if(cnt)
			{
				var obj = "#my_menu_"+cnt;
				$(obj)[0].selectedIndex = 0;
			}
			
			switch(val)
			{
				case "email" :  
					if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=470,height=570,statusbar=no,scrollbars=no,toolbar=no';
					puzzle.popupWin = window.open(base_url+'popup/mail/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
					break;
				case "link" :
					if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=680,height=630,statusbar=no,scrollbars=yes,toolbar=no,resizable=no';
					puzzle.popupWin = window.open(base_url+'popup/linkinfo/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
					break;
				case "thumbnails" :
					if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=890,height=600,statusbar=no,scrollbars=yes,toolbar=no,resizable=no';
					puzzle.popupWin = window.open(base_url+'popup/thumbnails/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
                    break;
                    /*
                    $.nyroModalManual({
						url : base_url+'popup/thumbnails/'+bookcode,
						width: 900, // default Width If null, will be calculate automatically
						height: 600, // default Height If null, will be calculate automatically
						minWidth: null, // Minimum width
						minHeight: null, // Minimum height
						endRemove: function() {}
					});
					break;
                    */
				case "index" :
                    if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=490,height=500,statusbar=no,scrollbars=yes,toolbar=no,resizable=no';
					puzzle.popupWin = window.open(base_url+'popup/index/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
					break;
                    /*
					$.nyroModalManual({
						url : base_url+'popup/index/'+bookcode,
						width: 500, // default Width If null, will be calculate automatically
						height: 400, // default Height If null, will be calculate automatically
						minWidth: null, // Minimum width
						minHeight: null, // Minimum height
						endRemove: function() {}
					});
					break;
                    */
				case "change" :
                    if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=680,height=680,statusbar=no,scrollbars=yes,toolbar=no,resizable=no';
					puzzle.popupWin = window.open(base_url+'popup/bookcode_change/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
					break;
				case "modify" :
                    if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=690,height=750,statusbar=no,scrollbars=yes,toolbar=no,resizable=no';
					puzzle.popupWin = window.open(base_url+'popup/book_modify/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
					break;
                    /*
					$.nyroModalManual({
						url : base_url+'popup/book_modify/'+bookcode,
						width: 690, // default Width If null, will be calculate automatically
						height: 590, // default Height If null, will be calculate automatically
						minWidth: null, // Minimum width
						minHeight: null, // Minimum height
						endRemove: function() {}
					});
					break;
                    */
				case "append" :
					location.href = base_url+'make/append/'+bookcode;
					break;
				case "download" :
					if(puzzle.popupWin) puzzle.popupWin.close();
                    var status = 'width=460,height=470,statusbar=no,scrollbars=yes,toolbar=no,resizable=no';
					puzzle.popupWin = window.open(base_url+'popup/download/'+bookcode,'popupWin',status);
					puzzle.popupWin.focus();
					break;
                    /*
                    $.nyroModalManual({
						url : base_url+'popup/download/'+bookcode,
						width: 460, // default Width If null, will be calculate automatically
						height: 470, // default Height If null, will be calculate automatically
						minWidth: null, // Minimum width
						minHeight: null, // Minimum height
						endRemove: function() {}
					});
					break;
                    */
				case "delete" :
					$.nyroModalManual({
						url : base_url+'popup/delete/'+bookcode,
						width: 390, // default Width If null, will be calculate automatically
						height: 130, // default Height If null, will be calculate automatically
						minWidth: null, // Minimum width
						minHeight: null, // Minimum height
						endRemove: function() {/*window.location.reload()*/}
					});
					break;
				case "error_delete" :
					$.nyroModalManual({
						url : base_url+'popup/error_delete/'+bookcode,
						width: 390, // default Width If null, will be calculate automatically
						height: 130, // default Height If null, will be calculate automatically
						minWidth: null, // Minimum width
						minHeight: null, // Minimum height
						endRemove: function() {/*window.location.reload()*/}
					});
					break;
				default :
					break;
			}
			
			
		}
	}
}
