jQuery.fn.toggleVal = function() {
	this.each(function() { $(this).focus(function() { if($(this).val() == this.defaultValue) { $(this).val(""); $(this).removeClass("toggleVal"); } }).blur(function() {if($(this).val() == "") { $(this).val(this.defaultValue); $(this).addClass("toggleVal"); }}); });
}
$(function() {

	if(jQuery.fn.defuscate) { $(".obfuscated").defuscate(); }

	if(jQuery.fn.toggleVal) { $(".togvalue").toggleVal(); }
	if(jQuery.fn.tooltip) { $(".tool_page").tooltip({ track: true, delay: 0, showURL: false, showBody: " - ", fade: 250 }); }
		
	$("a.favorite").click(function() {
		if (document.all) { window.external.AddFavorite(location.href, document.title); } 
		else if (window.sidebar) { window.sidebar.addPanel(document.title, location.href, ""); }
		return false;
	});

	$("a[@href^='#']").click(function() { var $tr = $(this.hash); $tr = $tr.length && $tr || $('[name=' + this.hash.slice(1) +']');
		if ($tr.length) { $('html,body').animate({scrollTop: $tr.offset().top}, 1000, 'bounceout'); /*, 'bounceout'*/ return false; } });
	
	$(".Lmenu, .LmenuSm").lavaLamp({ fx: "backout", speed: 600, overcolor: {color: '#ffffff'},outcolor: {color: '#000000'}, speedcolor:400 });
	$(".catulpp").lavaLamp({ fx: "backout", speed: 600, overcolor: {color: '#ffffff'},outcolor: {color: '#000000'}, speedcolor:400, click: function(e){
		e.preventDefault();
		var el = $(this).parent().parent().parent().parent();
		$(".projectinfo", el).hide();
		var rel = $("a", this).attr("rel");
		$("."+rel, el).fadeIn("slow");
	} });

	$(".Lmenu_sp").lavaLamp({ fx: "backout", speed: 600, overcolor: {color: '#ffffff'},outcolor: {color: '#4f4f4f'}, speedcolor:400, click: function(e){
		e.preventDefault();
		var el = $(this).parent().parent().parent().parent();
		actual_slide = parseInt($("a", this).text());
		$(".lastprojectimg, .nameproject, .detailproject").fadeOut(2000);
		$(".rel_"+actual_slide).fadeIn(2000);
		clearTimeout(timeout_slide);
		timeout_slide = setTimeout("main_page_animate();", 15000);
	} });
	var ellmenu = $(".Lmenu_sp").html();
	if(ellmenu != "" && ellmenu != null && ellmenu != "undefined") timeout_slide = setTimeout("main_page_animate();", 6000);

	$(".allphoto").hover(function(){$(this).addClass("allphotoh");},function(){$(this).removeClass("allphotoh");});

	$(".section").mouseover(function() {$(this).addClass("poshover"); $("a", this).addClass("poswhite"); }).mouseout(function() {$(this).removeClass("poshover"); $("a", this).removeClass("poswhite"); });

	$(".naviPrevON, .naviNextON").mouseover(function() { $(".naviNextONE, .naviPrevONE", this).stop().animate({'opacity': 0 }); }).mouseout(function() { $(".naviNextONE, .naviPrevONE", this).stop().animate({'opacity': 1 }); });
	$("a.fancybox").fancybox({'fancy':true,'speed':750,'overlayShow':true, 'overlayOpacity':0.73});

	//fontSize
	var cl = ".only_highlight"; var fSmin = 9; var fSmax = 15;
	var oFS = $(cl).css('font-size');
    $('.FontZ').click(function(){ $(cl).css('font-size', oFS); });
	$('.FontP').click(function(){ var size = parseInt($(cl).css('font-size')); if(size < fSmax) $(cl).css('font-size', (size+1)); });
	$('.FontM').click(function(){ var size = parseInt($(cl).css('font-size')); if(size > fSmin) $(cl).css('font-size', (size-1)); });

	$("a.bl_").attr({"target":"_blank"});

	$(".tags a").each(function() { $(this).css({'font-size':$(this).attr("rel")+"%" }).removeAttr("rel").attr({"href":public_root_path+"/search.html?tags="+$(this).attr("title")}).attr({"title":$(this).text()})   });
	
	if(jQuery.fn.pngFix) {
		$(document).not(".google").pngFix();
	};
	
	if(jQuery.fn.sifr) {
		$.sifr({path:'fonts'});
		$('.alexa').sifr({font:'alexa'});
		$('.myriad').sifr({font:'myriad'});
	};

	$(".gcms_loading").fadeOut("slow");
	$(cl).focus(function() { return false; }).noContext().rightClick(function() { return false; }).disableTextSelect();


	$('.projectsnew').click(function() { window.location.href = public_root_path + '/' + $(this).attr("rel"); });

	$('.fileDescription').css('opacity', 0.7);

	$("div.scrollable").scrollable({ size: 4, next: 'div.scrollnext', prev: 'div.scrollprev', navi: 'div.scrollnavi' });

});

function setActionQuick(action) { document.contactformQuick.actionQuick.value=action; document.contactformQuick.submit(); }
function AcceptAlertQuick(text) { return confirm(text); }