var icema = {}; // init namespace
icema.getPage = function(url,selector){
	var speed = 100;
	if(!selector){
		selector = "#content-ajax";
	}
	$(selector).fadeOut(speed,function(){
		tinggi = $(selector).height();
		$(selector).css("height",tinggi+"px");
		$(selector).attr('innerHTML',"<br /><br /><br /><br />");
		$(selector).addClass("my-load-ajax");
		$(selector).fadeIn(speed);
		$.post(
			url, 
			{'t' : 't'}, 
			function(data){
				$(selector).fadeOut(speed,function(){
					$(selector).removeClass("my-load-ajax");
					$(selector).attr('innerHTML',data);
					$(selector).fadeIn(speed);
				});
			}
		);
	});
};
function mBoxInfo(msg){
		$.modal('<div class="help">'+ msg +'</div><br /><div><input type="button" value="Tutup" onclick="$.modal.close()" class="button left" /><div>', {});
		return false;
	}
	
	function mBoxInfoReload(msg){
		$.modal('<div class="help">'+ msg +'</div><br /><div><input type="button" value="Tutup" onclick="lShow();document.location.reload(true);" class="button left btnreset" /><div>', {});
		return false;
	}
	
	function mBoxConf(msg,uri){
		$.modal('<div>'+ msg +'</div><br /><div><input type="button" value="Tidak" onclick="$.modal.close()" class="button left btnreset" /><input type="button" value="Ya" onclick="document.location=uri" class="button right btnreset" /><div>', {});
		return false;
	}
	function mBoxConfReturn(msg){
		$.modal('<div>'+ msg +'</div><br /><div><input type="button" value="Tidak" onclick="$.modal.close()" class="button left btnreset" /><input type="button" value="Ya" onclick="return true" class="button right btnreset" /><div>', {});
		return false;
	}
	function getCaptcha(id){
		$.post(MOD_URL+"get-captcha",function(o){$('#'+id).html(o);});
	}

   	$(document).ready(function(){
		$(".picker").datepicker();
		//$('.south').tipsy({gravity: 's',fade:true,html:true});
		$('.west').tipsy({gravity: 'w',fade:true,html:true});
		$('.north').tipsy({gravity: 'n',fade:true,html:true});
		$('.east').tipsy({gravity: 'e',fade:true,html:true});
		
		mainmenu();
		
		$("input,option,select").focus(function(){
			$(this).css("background-color","#FFFABF");										  
		}).blur(function(){
			$(this).css("background-color","#fff");		
		});
		
		$(".data tr").hover(
		  function () {
			$(this).css("background-color","#FEFF9F");
		  }, 
		  function () {
			$(this).css("background-color","#fff");	
		  }
		);
			
		$('.confirm').each(function(){
			$(this).click(function(){
				msg=$(this).attr('rel');uri=$(this).attr('href');				
				mBoxConf(msg,uri);	
				return false;		
			});
		});
		
		$('a.help').each(function(){ 
			$(this).click(function(){
				msg=$(this).attr('rel');				
				mBoxInfo(msg);
				return false;						
			});
		});
		
		$('.simple').each(function(){
			$(this).click(function(){			
				if($(this).attr('href').split("")[0]=="#"){				
					$($(this).attr('href')).modal('',{onOpen: function (dialog) {
						dialog.overlay.fadeIn('medium',function () {
							dialog.data.fadeIn("medium",function(){
								dialog.container.fadeIn('slow');
							});
						});				
					},
						onClose: function (dialog) {
							dialog.container.fadeOut('slow', function () {
								dialog.overlay.fadeOut('slow',function(){
									$.modal.close();
								});
						});
					},opacity:10
					});
				}else{	
					width = ($(this).attr('rel').split(",")[0] == '')?600:$(this).attr('rel').split(",")[0];
					height = (typeof $(this).attr('rel').split(",")[1] == 'undefined')?400:$(this).attr('rel').split(",")[1];
					$.modal('<iframe src="' + $(this).attr('href') + '" height="'+height+'" width="'+width+'" style="border:0">', {});
					return false;
				}
				
			});
		});	
		
	});
	
function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
