Cufon.replace('.content-top h2,.content-txt > h2,.download-list h3,#baner h3 ',{fontFamily: 'TheSerif'}); 


function tellFrend(){
	$('#tta_polec').click(
			function(event) {
				event.preventDefault();
				var heiG = $('body').height();
				$('#tell_friend_overlay').css('height',heiG);
				$('#tell_friend_overlay').removeClass('n-active');
				$('#tell_friend_popup').removeClass('n-active');
			}
	);
	$('.jqmClose').click(
			function(event){
				event.preventDefault();
				$('#tell_friend_overlay').addClass('n-active');
				$('#tell_friend_popup').addClass('n-active');
			}
	);
}


function sBox(){
	$('#sub .nav-news-list li').each(function () {
		var _this = $(this);
		var cnt = _this.find('div');
		var source = _this.attr('data-source');
		var first = true;
		
		_this.hover(function() {
			cnt.show();
			if (first) {
				cnt.addClass('loading');
				first = false;
				$.get(source, {}, function(data) {
					cnt.html(data).removeClass('loading');
				}, 'html');
			}
		}, function () {
			cnt.hide();
		});
	});
}

function up(){
	$('#up').click(function() {
		$.scrollTo($("#sub"), 1000);
		return false;
	});
}

function initBack() {
	$("#back").click(function() {
		history.back();
		return false;
	});
}


function sGaleryHome(){
	
	var _active = $('.box-image').find('div.active');
	if( _active.next().length > 0) {_next = _active.next();}
	else {_next = $('.box-image div:first');}
	_active.fadeTo(500,0).removeClass('active');
	_next.fadeTo(1000,1).addClass('active');

	
}



function initInputLabelFromInput(input_id) {
	var text = $(input_id).val(); 
	$(input_id).val(text);
	$(input_id).focus( function() {
		if ($(this).val() == text) {
			$(this).val("");
		}
	} );
	  $(input_id).blur( function() {
		if ($(this).val() == '') {
			$(this).val(text);
		}
	} );
}

function initInputLabelFromLabel(input_id,label_id) {
	var text = $(label_id).text(); 
	$(input_id).val(text);
	$(input_id).focus( function() {
		if ($(this).val() == text) {
			$(this).val("");
		}
	} );
	  $(input_id).blur( function() {
		if ($(this).val() == '') {
			$(this).val(text);
		}
	} );
}


function initPrint() {
	$("#print").click(function() {
		window.print();
		return false;
	});
}

function targetB() {
	$('.a_ee').attr('target','_blank');
	$('#sub.links .list-team li a').attr('target','_blank');
	$('.footer-link a').attr('target','_blank');
	$('.baner-bottom a').attr('target','_blank');
}

function fixSelect(){
	if($.browser.msie){
		
		$(".form-r select")	
	    .live('focus',(function(){
	        $(this)
	        	.data("origWidth", $(this).attr("offsetWidth"))
	        	.css("width", "auto");
	        if($(this).data("origWidth") > $(this).attr("offsetWidth")){
	        	$(this).css("width", $(this).data("origWidth"));
	        }else{
	        	$(this).css("position", "absolute")
	            .css("width", "auto")
	            .css("overflow", "hidden");
	        }
	    }))
	    .live('blur',(function(){
	        $(this).css("width", $(this).data("origWidth")).css("position", "static");
	    }))		
	    .live('change',(function(){
	        $(this).css("width", $(this).data("origWidth")).css("position", "static");
	    }));		
	}


}

function initialize() {
	initInputLabelFromLabel("#s-query","#s-query-l");
	tellFrend();
	up();
	sBox();
	targetB();
	initPrint();
	initBack();
	targetB();
	fixSelect();
	$('.gallery-box a').lightBox();
	setInterval("sGaleryHome()", 3000);
}
$(document).ready(initialize);

