﻿// JScript File

$(document).ready(function(){
	    
	    $(".pop_up_head").hover(
		  function () {
             setTimeout(function(){
               $('.on_hover_head').css({'display' : 'block'});
			   $('.off_hover_head').css({'display' : 'none'});
			   $('div.pop_up_footer').css({'clear' : 'both', 'height' : '480px'});
             }, 2500 );
		  }, 
		  function () {
			 $(this).find('.on_hover_head').css('display','none');
			 $(this).find('.off_hover_head').css('display','block');
			 $('div.pop_up_footer').css({'clear' : 'both', 'height' : '50px'});
		  }
		);
		
		$(".pop_up_top").hover(
		  function () {
			$(this).find('.on_hover').css('display','block');
			 $(this).find('.off_hover').css('display','none');
		  }, 
		  function () {
			 $(this).find('.on_hover').css('display','none');
			  $(this).find('.off_hover').css('display','block');
		  }
		);
		var checkScreenSizeWidth	=	screen.width;
		var checkDocument = $(document).width();
		var checkwindow = $(window).width();
 
	
	
	if (checkDocument > 1270 ){
		
		$('.content_ad').css('display','block');
		}
		window.onresize = resize;
 
		function resize()
		{
			var checkwindow = $(window).width();
		 if (checkwindow < 1270 ){
		
		$('.content_ad').css('display','none');
		
		}
		 else{
		
		$('.content_ad').css('display','block');
		
		}
	}
	
	 $('#pane2').jScrollPane({showArrows:true, scrollbarMargin:10});
	 $('.box_feature .items:last').addClass('last');
	 $(".main_img .desc").show(); //Show Banner
	 $(".main_img .des").animate({ opacity: 0.7 }, 1 ); //Set Opacity 	
			
	 $(".list-info-1 ul li:first").addClass('active');
	 
	 function select_slide(){
		 var _article_img_src	= $('.list-info-1 li.active').find('.img_small').attr('lang');
		 var _article_title	= $('.list-info-1 li.active').find('h2 a').text();
		 var _article_title_href_first	= $('.list-info-1 li.active').attr("href");
		 var _article_desc	=	$('.list-info-1 li.active').find('p').attr("href");	 
		 if (_article_img_src!==''){
			$('.main_img img').attr('src',_article_img_src);
			$('.main_img h2 a').text(_article_title);
			$('.main_img p').text(_article_desc);
			$('.main_img h2 a').attr('href',_article_title_href_first);
			$('.link_main_img').attr('href',_article_title_href_first);
		 }
	 }
	
	 select_slide();
	 
	$('.list-info-1 ul li').hover(function(){
			//Set Variables
		//	 var imgAlt = $(this).find('img').attr("alt"); //Get Altt Tag of Image
			 var imgTitle = $(this).find('.img_small').attr("lang"); //Get Main Image URL
			 var imgDesc = $(this).find('p').text(); //Get HTML of block
			var _title_href = $(this).find('h2 a').attr("href");
			var _article_title_hover	=	$(this).find('h2 a').text();
			 $('.main_img img').attr('src',imgTitle);
			 $('.main_img h2 a').text(_article_title_hover);
			 $('.main_img p').text(imgDesc);
		 	 $('.main_img h2 a').attr('href',_title_href);
			 $('.main_img .link_main_img').attr('href',_title_href);
		 });
		 
		$('.list-info-1 li').hover(
		  function () {
			 $('.list-info-1 li').each(function(){
			 $(this).removeClass("active")
			 }) 
			$(this).addClass('hover');
		  }, 
		  function () {
			$(this).removeClass('hover');
			$(this).addClass('active');
		  }
		);
 
		$('li.scrollable').scrollable({  	
		    size: 3 	 
		});
 
		var __img_first	=	$('.items_2 a:first').attr('lang');
		var __img_first_title	=	$('.items_2 a:first').attr('title');
		var __img_first_link = $('.items_2 a:first').attr('rel');
		if (__img_first!==''){
			var strImg		=	__img_first;
			var fullImg		=	strImg.replace('medium/','');
			$('.img-photo img').attr('src',__img_first);
			$('.img-photo .des-photo').text(__img_first_title)	;
			$('.img-photo .des-photo').attr("href",__img_first_link);
			$('.link-photo').attr("href",__img_first_link);
			$('.img-photo img').attr('width',324);
			$('.img_main img').attr('height',127);		
		}
		
		$('.items_2 a').click(function(){		
		var __img_item	=	$(this).attr('lang');
		var __img_item_title	=	$(this).attr('title');
		var __img_link	=	$(this).attr('rel');
		var strImg		=	__img_item;
		var fullImg		=	strImg.replace('medium/','');						 
		$('.img-photo img').attr('src',__img_item);		
		$('.img-photo img').attr('width',324);
		$('.img_main img').attr('height',127);	
		$('.img-photo .des-photo').text(__img_item_title);	
		$('.img-photo .des-photo').attr("href",__img_link);
		$('.link-photo').attr("href",__img_link);
		
		});
		
		 $(window).scroll(function(){
		    if  ($(window).scrollTop() > $(".a").offset({ scroll: false }).top){
		       $(".content_ad").css("position", "fixed");
		       $(".content_ad").css("top", "0");
		    }
    		
		    if  ($(window).scrollTop() <= $(".a").offset({ scroll: false }).top){
		       $(".content_ad").css("position", "relative");
		       $(".content_ad").css("top", $(".a").offset);
		    }
	    }); 
	
	 $(document).pngFix(); 
	
	});
	function slideSwitch() {
	
    var $active = $('.list-info-1 ul li.active');
 
    if ( $active.length == 0 ) $active = $('.list-info-1 ul li:last');
 
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('.list-info-1 ul li:first');
	 $active.addClass('last-active');
     $next.css({opacity: 1.0})
        .addClass('active')
        .animate({opacity: 1.0}, 0, function() {
            $active.removeClass('active last-active');
       });
	 var _article_title_href_first	=	$('.list-info-1 li.active').find('h2 a').attr("href");
	 var _article_img_src	=	$('.list-info-1 li.active').find('.img_small').attr('lang');
	 var _article_title	=	$('.list-info-1 li.active').find('h2 a').text();
	 var _article_desc	=	$('.list-info-1 li.active').find('p').text();	 
	 if (_article_img_src!==''){
	 	$('.main_img img').attr('src',_article_img_src);
		$('.main_img h2 a').text(_article_title);
		$('.main_img p').text(_article_desc);
		$('.main_img h2 a').attr('href',_article_title_href_first);
	 	$('.link_main_img').attr('href',_article_title_href_first);
	 }	
	
	
}
$(function() {
    setInterval( "slideSwitch()", 5000 );
});	
	$(function() {
			$("#tabs").tabs({
				collapsible: true
			});
			$("#tab-b").tabs({
				collapsible: true
			});
			
		});
