Cufon.replace('#menu .item .name, .stylish', { fontFamily: 'TitilliumMaps29L', hover: true });

Cufon.replace('#sub .slogan', { fontFamily: 'TitilliumText22L', hover: true });





function simple_tooltip(target_items, name){

 $(target_items).each(function(i){

		$("#page-container").append("<div class='"+name+"' id='"+name+i+"'>"+$(this).attr('title')+"</div>");

		var my_tooltip = $("#"+name+i);



		if($(this).attr("title") != "" && $(this).attr("title") != "undefined" ){



		$(this).removeAttr("title").mouseover(function(){

					my_tooltip.css({display:"none"}).fadeIn(400);

		}).mousemove(function(kmouse){

				var border_top = $(window).scrollTop();

				var border_right = $(window).width();

				var left_pos;

				var top_pos;

				var offset = 15;

				if(border_right - (offset *2) >= my_tooltip.width() + kmouse.pageX){

					left_pos = kmouse.pageX+offset;

					} else{

					left_pos = border_right-my_tooltip.width()-offset;

					}



				if(border_top + (offset *2)>= kmouse.pageY - my_tooltip.height()){

					top_pos = border_top +offset;

					} else{

					top_pos = kmouse.pageY-my_tooltip.height()+(offset*2);

					}



				my_tooltip.css({left:left_pos, top:top_pos});

		}).mouseout(function(){

				my_tooltip.css({left:"-9999px"});

		});



		}



	});

}



$(document).ready(function () {

simple_tooltip(".tooltip","tooltip-cloud");	





/* stylization of some xhtml/css elements - extortion for browsers compatibility */



$("#whats-new ul li:first-child").addClass("noborder-top");

$("#whats-new ul li:last-child").addClass("noborder-bottom");

$("#footer ul li:first-child").addClass("noborder-left");

$(".list-rotator .item:nth-child(2n)").addClass("remove");

$("#content table tr:nth-child(2n) td").addClass("color");







$(".apply-corners").append("<span class='corner corner-top-left'></span><span class='corner corner-top-right'></span><span class='corner corner-bottom-left'></span><span class='corner corner-bottom-right'></span>");



$(".apply-shadows-oval, .apply-shadows-square").append("<span class='shadow-left'></span><span class='shadow-right'></span>");





/* widgets specific interactions */



/* whats new behavior on mouseenter */



$("#whats-new ul li .short, .popular-posts a, .newest-comments a").mouseenter(function() {

	$("img", this).animate({ "margin-left": "7px" }, 300)

}).mouseleave(function() {

	$("img", this).animate({ "margin-left": "0px" }, 300);

});



/* clients arrows behavior */

$("#clients .arrow").mousedown(function(){

$(this).css("margin-top","1px");

}).mouseup(function() {

   $(this).css("margin-top", "0px");

});





/* main menu sliding sub items */

	$("#menu .item .name").mouseenter(function(){

		$(".sub-items").hide();

		$(this).addClass("subcurrent");

		$(this).parent().find(".sub-items").animate({

												height: "toggle"

												}, 200)	

	});

	

	$("#menu .item").mouseleave(function(){

		$(".name", this).removeClass("subcurrent");

		$(".sub-items").hide();

	});







/* autoclear function for inputs */

	$('.autoclear').click(

	function() {

	if (this.value == this.defaultValue) {

	this.value = '';

	}

	}

	);

	$('.autoclear').blur(

	function() {

	if (this.value == '') {

	this.value = this.defaultValue;

	}

	}

	);

	



/* clients widget rotator - jquery cycle plugin */



$('#main-rotator ul').cycle({ 

	fx:     'fade', 

	speed:  300, 

	timeout: 5000, 

	pager:   '.controls'

}); 





$('#clients ul').cycle({ 

	fx:     'fade', 

	speed:  300, 

	timeout: 0, 

	next:   '#clients a.next', 

	prev:	'#clients a.prev'

}); 





$( ".rotate" ).each(

	function( intIndex ){

		$(this).cycle({

			fx:     'fade', 

			speed:  300, 

			timeout: 0, 

			pager: ".controls"+intIndex

			});

});



$(".rotate").each(

	function( intIndex ){

		$(this).addClass('rotate'+intIndex);

		$('.rotate'+intIndex+' a.lightme').lightBox();

});



});




