 $(document).ready(function(){
	//alert('test');
	
/* --------------------------- fading images on homepage ------------------------------- */						
	$('ul#fade').innerfade({
		speed: 1000,
		timeout: 4000,
		type: 'sequence',
		containerheight: '337px'
	});
	
/* -------------------------- move the menu for smaller resolutions from the peel corner ---------- */
$winwidth = $(window).width();
if ($winwidth < 1120)
	{
	if ($winwidth < 990)
		{
		$moveTo = (55 - (($winwidth - 990)) );
		}
	else
		{
		$moveTo = (55 - (($winwidth - 990) / 2) );
		}
	if ($moveTo > 0)
		$("#topnav").css("right", $moveTo + "px");
	}
	
window.onresize = function(event) {
	$winwidth = $(window).width();
	if ($winwidth < 1120)
		{
		if ($winwidth < 990)
			{
			$moveTo = (55 - (($winwidth - 990)) );
			}
		else
			{
			$moveTo = (55 - (($winwidth - 990) / 2) );
			}
		if ($moveTo > 0)
			$("#topnav").css("right", $moveTo + "px");
		}
	else {
		$("#topnav").css("right", "0px");
		}
}
	
/* --------------------------- lightbox ------------------------------- */	
	 $(function() {
        $('.lightbox').lightBox();
    });	
	 
/* --------------------- clearing text input fields on focus ------------------------- */
var clearMePrevious = "";

// clear input on focus
$(".textfld").focus(function()
	{
	if($(this).val()==$(this).attr("title"))
		{
		clearMePrevious = $(this).val();
		$(this).val("");
		}
	});

// if field is empty afterward, add text again
$(".textfld").blur(function()
	{
	if($(this).val()=="")
	{
	$(this).val(clearMePrevious);
	}
	});

// clear input on focus
$("textarea").focus(function()
	{
	if($(this).val()==$(this).attr("title"))
		{
		clearMePrevious = $(this).val();
		$(this).val("");
		}
	});

// if field is empty afterward, add text again
$("textarea").blur(function()
	{
	if($(this).val()=="")
	{
	$(this).val(clearMePrevious);
	}
	});

/* ---------------------------------- tabs ---------------------------- */
	/*
	$(".tab_content").each(function(){
		//$(this).attr("rel",($(this).children(".text").height() + 180+ "px"));
		//$(this).css("height", "400px");
		$texth = ($(this).children(".text").height() + "px");
		$(this).attr("rel", $texth);
		$(this).children(".text").css("height", "200px");
		
	});
	*/
	
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	

/*	
	$(".tab_content img").click(function() {
		$realh = $(this).parents(".tab_content").attr("rel") ;
		alert($realh);
//		$(this).parents(".tab_content").animate({  "height": $realh}, "slow");
		$(this).parents(".tab_content").children(".text").animate({  "height": $realh}, "slow");
//		$(this).parents(".tab_content").css("height",$realh);
	});
*/	

/* Drop down menu */
ddsmoothmenu.init({
	mainmenuid: "ddsmoothmenu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})


});

