// JavaScript Document
$(document).ready(function(){
// preload
	//$(".m-content img, .m-content img a, .m-txt img, .m-txt a, .m-txt-work a, .m-txt-work img").preload();
// favorites
	$(".addtofav").jFav();
// dropdown country choose
	$("div.t-toolbar-l-cntry").hover(function(){
			$(".t-toolbar-l-cntry-dd").show();
		},
		function(){
			$(".t-toolbar-l-cntry-dd").hide();
	});

// update dialog
	$("div.m-dialog-update").hover(
		function(){$(this).addClass("m-dialog-update-action");},
		function(){$(this).removeClass("m-dialog-update-action");}
	);
// on main work favorites
	$("div.m-favorites li").hover(
		function(){$(this).addClass("active");},
		function(){$(this).removeClass("active");}
	);
	
	$("div.m-favorites ul li a img, div.m-portl-list-bytype ul li a img").hover(
		function(){
			$(this).animate({opacity: 0.6}, 200 );
		},
		function(){
			$(this).animate({opacity: 1}, 200 );
		}
	);
	//$("div.m-favorites ul li a img").hover(
	//	function(){
	//		$(this).animate({width: "88px", margin: "-4px"}, 200 );
	//	},
	//	function(){
	//		$(this).animate({width: "78px", margin: "0"}, 200 );
	//	}
	//);

	//$(".m-dialog-update").click(function(){
	//	$("#dialog-us").load('trash/dialogs/');
	//});
	
	$(".m-dialog-update").click(function(){
		$.ajax({
		  url: "trash/dialogs/",
		  cache: false,
		  success: function(html){
			$("#dialog-us").html(html);
		  }
		});
	});
	
    // Tabs
    $('#portfolioshow').tabs();
	$('#tabs').tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	
		$(".ui-tabs-nav li a").click(
		function(){
			$(this).animate({opacity: 0}, 200 ).animate({opacity: 1}, 1000 );
		});
		
		$(".ui-tabs-panel").hover(
		function(){
			$(".ui-tabs-panel-hover").css({display:"block", opacity: 0}).animate({opacity: 0.7}, 200 );
		},
		function(){
			$(".ui-tabs-panel-hover").css({display:"none"});
		}
		);
		
	// web img show
	$("div.cont-img").hover(function() { 
		$(this).find("div.cont-txt").fadeIn();
	},function() { 
		$(this).find("div.cont-txt").fadeOut();
	}
	);
	
	// img show
	$(".m-content img").animate({opacity: 0}).animate({opacity: 1}, 1000 );
	
	// work img show big
		var imgAlt = $(".m-work-img-list li:first").find('img').attr("alt"); //Get Alt Tag of Image
        var imgTitle = $(".m-work-img-list li:first").find('img').attr("rel"); //Get Main Image URL
				$("div.m-work-img-big img").attr({ src: imgTitle  });
				$("div.m-work-img-big span").text(imgAlt);
				
                //Click and Hover events for thumbnail list
				$(".m-work-img-list li:first").addClass('active');
				$(".m-work-img-list li.active img").animate({opacity: 0.5}, 500 );
                $(".m-work-img-list li").click(function(){ 
                        //Set Variables
                        var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
                        var imgTitle = $(this).find('img').attr("rel"); //Get Main Image URL
							$("div.m-work-img-big img").removeAttr("src").removeAttr("alt");
							$("div.m-work-img-big img").animate({opacity: 0}, 100 ).animate({opacity: 1}, 800 ).attr({ src: imgTitle  });
							$("div.m-work-img-big span").text(imgAlt);
							
								$(".m-work-img-list li img").animate({opacity: 1}, 100 )
								$(".m-work-img-list li").removeClass('active'); //Remove class of 'active' on all lists
								$(this).addClass('active');  //add class of 'active' on this list only
								$(".m-work-img-list li.active img").animate({opacity: 0.5}, 500 );
								return false;
                });
				
	// execute your scripts when the DOM is ready. this is a good habit 
	$(function() { 
	 
		// assign a click event to the exposed element, using normal jQuery coding 
		$(".m-work-img-big2").hover(function() { 
	 
			// perform exposing for the clicked element 
			$(this).expose({api: true}).load(); 
	 
		},
		function() { 
	 
			// perform exposing for the clicked element 
			$(this).expose({api: false}).close();
	 
		}
		); 
	});
});