//s.function
function scrollto(vari) {
	
	
	$('html, body').animate({scrollTop: $('.'+vari).offset().top}, 1200);
	
	
}

function add_title(vari) {

	$("#GetCurrentUrl").animate({opacity: 0.5}, function() {
		
		$(this).html(' » '+vari).animate({opacity: 1});
		
	});
	
}

function remove_loading(){
	var targelem=$('#loading_effect');
	targelem.animate({opacity:'hide'},1200);
	
};
//c.panel
$(function(){
	
	
// main menu
	
	
		
	$(".content #box .title_box:first").addClass("current_title_box");
	$(".content #box .content_box:first").show();
	
	
	$(".call_jquery").click(function(){
		
			
	$(".content #box .title_box").removeClass("current_title_box");	
	
		var	$rel_to_id = $(this).attr("rel");		
		
		$('#'+$rel_to_id).addClass("current_title_box");
			
			
		$('#'+$rel_to_id).next(".content_box").slideDown("slow").siblings(".content_box:visible").slideUp("slow");
		
		scrollto("path");
		
		var $assign_title = $(this).attr('title');
		
		add_title($assign_title);
		
	});
	

	$(".content #box .title_box").click(function(){
		
		
		$(this).next(".content_box").slideToggle("slow").siblings(".content_box:visible").slideUp("slow");
		
		
		
		$(this).toggleClass("current_title_box");
		
		scrollto("path");		
		
		var $assign_title = $(this).find('h2,h3,h4').html();
		
		add_title($assign_title)
		
		$(this).siblings(".title_box").removeClass("current_title_box");
		
		
	
});
	
});
// m.menu
/*
$(function(){
	
	$('#menu li').removeClass('current');
	$('#menu li:eq(0)').addClass('current');
	
$('#menu li').css( {backgroundPosition: "50% 120%"} ).mouseover(function(){
				
			$(this).stop().animate({backgroundPosition:"(50% 0%)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(50% 120%)"}, {duration:500, complete:function(){
				
				$(this).css({backgroundPosition: "50% 120%"});
			}});
	
});		
	

});
*/
// b.loading

$("body").append("<div id=\"loading_effect\">&nbsp;</div>");



$(document).ready(function(){	

//functions require document ready

	$("input,textarea").attr('autocomplete','off');
	
	$("a[class='a_zoom']").colorbox();	
	
	$("#login_form_popup").colorbox({iframe:true, innerWidth:450, innerHeight:250});
	
	
	$('#login, #password').autoclear();

//tags
	
if ((screen.width<=1152)) {
	
     $("#tagsphere_js").tagSphere({
        height: 150,
        width: 150,
        slower: 0.65,
        radius: 45,
        timer: 50
      });
	  
		}	else {	
		
     $("#tagsphere_js").tagSphere({
        height: 250,
        width: 250,
        slower: 0.65,
        radius: 75,
        timer: 50
      });
		
}

//load content via ajax
						   
	$.ajaxSetup({cache: false});
	
	$(".ajax_load").click(function() {	
		
	$('#menu li').removeClass('current');
		
	$(this).parent('li').addClass('current');
	
	var include_page_url = $(this).attr('rel');	
		
	//$("#loading_effect").fadeIn("fast");
	$("#content").html("<div class=\"loading\">Please wait...</div>");
		
	$("#content").load(include_page_url, function() {
			
	$(".loading").fadeOut("slow");
	$('html, body').animate({scrollTop: $('html').offset().top}, 900);
	
	  
	});
		return false;
		
	});
});

