$(function(){

// Accordion
$("#accordion").accordion({ header: "h3" });
	
// Tabs
$('#tabs').tabs();

// Dialog	
$('#dialog').dialog({
	autoOpen: false,
	width: 600,
	buttons: {
"Ok": function() { 
	$(this).dialog("close"); 
}, 
"Cancel": function() { 
	$(this).dialog("close"); 
} 
	}
});

// Dialog Link
$('#dialog_link').click(function(){
	$('#dialog').dialog('open');
	return false;
});

// Datepicker
$('#datepicker').datepicker({
	inline: true
});

// Slider
$('#slider').slider({
	range: true,
	values: [17, 67]
});

// Progressbar
$("#progressbar").progressbar({
	value: 20 
});

//hover states on the static widgets
$('#dialog_link, ul#icons li').hover(
	function() { $(this).addClass('ui-state-hover'); }, 
	function() { $(this).removeClass('ui-state-hover'); }
);

});


$(document).ready(function() {	
 
 
  //Get all the LI from the #tabMenu UL
  $('#tabMenu > li').click(function(){
        
    //remove the selected class from all LI    
    $('#tabMenu > li').removeClass('selected');
    
    //Reassign the LI
    $(this).addClass('selected');
    
    //Hide all the DIV in .boxBody
    $('.boxBody div').slideUp('1500');
    
    //Look for the right DIV in boxBody according to the Navigation UL index, therefore, the arrangement is very important.
    $('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');
    
  }).mouseover(function() {
 
    //Add and remove class, Personally I dont think this is the right way to do it, anyone please suggest    
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout');   
    
  }).mouseout(function() {
    
    //Add and remove class
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
    
  });
 
  //Mouseover with animate Effect for Category menu list
  $('.boxBody #category li').mouseover(function() {
 
    //Change background color and animate the padding
    $(this).css('backgroundColor','#888');
    $(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
  }).mouseout(function() {
    
    //Change background color and animate the padding
    $(this).css('backgroundColor','');
    $(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});
  });  
	
  //Mouseover effect for Posts, Comments, Famous Posts and Random Posts menu list.
  $('.boxBody li').click(function(){
    window.location = $(this).find("a").attr("href");
  }).mouseover(function() {
    $(this).css('backgroundColor','#888');
  }).mouseout(function() {
    $(this).css('backgroundColor','');
  });  	
	
});

//--------------------------------------------------------------------------------------------
$(function() {

			var $tabs = $('#tabsPRNews').tabs();
	
		});
//---------------------------------------------------------------------------------------------
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		document.cookie=c_name+ "=" +encodeURIComponent(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+";path=/;");
	}else{
		document.cookie=c_name+ "=" +encodeURI(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+";path=/;");
	}
}
function createLoginCookie(id_check,id_user,id_pass){
		if(document.getElementById(id_check).checked==true){
			setCookie(id_user+"_cookie",document.getElementById(id_user).value,30);
			setCookie(id_pass+"_cookie",document.getElementById(id_pass).value,30);
		}else{
			setCookie(id_user+"_cookie","",30);
			setCookie(id_pass+"_cookie","",30);
		}
}
var timer;
var lastID=1;
function showdoLeftMenuOver(id,actionIframe){
	clearTimeout(timer);
	document.getElementById('listLeftMenuButtonBg'+id).className='listLeftMenuButtonBgHover';
	timer = setTimeout('doLeftMenuOver('+id+','+actionIframe+')', 1200);
}
function doLeftMenuOver(id,actionIframe){		
	doLeftMenuClose(lastID);
	lastID = id;
	document.getElementById('leftMenuDetail'+id).style.display='block';
	document.getElementById('listLeftMenuButtonBg'+id).className='listLeftMenuButtonBgHoverActive';
	if(actionIframe){	
		document.getElementById('iframeLeftMenu'+id).src='http://www.quinl.com/layout_showCategoriesDetail.php?category_id='+id;
	}
}
function doLeftMenuClose(id){		
	clearTimeout(timer);
				document.getElementById('leftMenuDetail'+id).style.display='none';
				document.getElementById('listLeftMenuButtonBg'+id).className='listLeftMenuButtonBg';
}
function doLeftMenuOut(id){		
	clearTimeout(timer);
				document.getElementById('listLeftMenuButtonBg'+id).className='listLeftMenuButtonBg';
}

(function($){
	var initLayout = function() {
		var hash = window.location.hash.replace('#', '');
		
		$('a.customGal').zoomimage({
			controlsTrigger: 'mouseover',
			className: 'custom',
			shadow: 40,
			controls: false,
			opacity: 1,
			beforeZoomIn: function(boxID) {
				$('#' + boxID)
					.find('img')
					.css('opacity', 0)
					.animate(
						{'opacity':1},
						{ duration: 500, queue: false }
					);
			},
			beforeZoomOut: function(boxID) {
				$('#' + boxID)
					.find('img')
					.css('opacity', 1)
					.animate(
						{'opacity':0},
						{ duration: 500, queue: false }
					);
			}
		});
	};
	
	
	EYE.register(initLayout, 'init');
})(jQuery)