/* this prevents dom flickering, needs to be outside of dom.ready event: */
document.documentElement.className += 'js_active';
/*end dom flickering =) */

// -------------------------------------------------------------------------------------------
// cufon
// -------------------------------------------------------------------------------------------

			Cufon.replace('h1, h2, h3, h4, h5, h6', {
					hover: 'true'
				});
			Cufon.replace('span.small_title');
			Cufon.replace('.column .box h3', {
					textShadow: '#f4a9b4 .5px 1px'
				});

// -------------------------------------------------------------------------------------------
// news ticker
// -------------------------------------------------------------------------------------------

	      $(document).ready(
	      	function(){ 
			$('.news').innerfade({ 
					animationtype: 'fade',
					speed: 600,
					timeout: 3500,
					type: 'sequence'
				});
			 });



// -------------------------------------------------------------------------------------------
// featured
// -------------------------------------------------------------------------------------------							
							
//nivo slider

$(window).load(function() {
	setTimeout(function(){
		$('#slider').nivoSlider({
			slices: '18',
			effect:'random',
			animSpeed:800,
			pauseTime:8000,
			startSlide:5,
			directionNav:false,
			controlNav:true,
			keyboardNav:false,
			pauseOnHover:true,
			manualAdvance: false
		});
	}, 1000);
});
							

// -------------------------------------------------------------------------------------------
// mini navigation
// -------------------------------------------------------------------------------------------

							
var menu=function(){
	var t=25,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();


// -------------------------------------------------------------------------------------------
// kwicks navigation
// -------------------------------------------------------------------------------------------

$().ready(function() {
	$('.kwicks').kwicks({
		max : 200,
		duration: 800,  
		easing: 'easeOutQuint'
	});
});


// -------------------------------------------------------------------------------------------
// show list spy effect
// -------------------------------------------------------------------------------------------							
							

//sidebar show list spy effect

$(function () {
	    $('.sidebar_box ul.spy_sidebar').simpleSpy_sidebar();
	});

(function ($) {
    
	$.fn.simpleSpy_sidebar = function (limit, interval) {
	    limit = limit || 4;	//number of posts appear
	    interval = interval || 4000;	//delay of sliding
	    
	    return this.each(function () {
		// 1. setup
		    // capture a cache of all the list items
		    // chomp the list down to limit li elements
		var $list = $(this),
		    items = [], // uninitialised
		    currentItem = limit,
		    total = 0, // initialise later on
		    height = $list.find('> li:first').height();
		    
		// capture the cache
		$list.find('> li').each(function () {
		    items.push('<li>' + $(this).html() + '</li>');
		});
		
		total = items.length;
		
		$list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
		
		$list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();
	
		// 2. effect        
		function spy() {
		    // insert a new item with opacity and height of zero
		    var $insert = $(items[currentItem]).css({
			height : 0,
			opacity : 0,
			display : 'none'
		    }).prependTo($list);
				
		    // fade the LAST item out
		    $list.find('> li:last').animate({ opacity : 0}, 500, function () {
			// increase the height of the NEW first item
			$insert.animate({ height : height }, 500).animate({ opacity : 1 }, 500);
			
			// AND at the same time - decrease the height of the LAST item
			// $(this).animate({ height : 0 }, 1000, function () {
			    // finally fade the first item in (and we can remove the last)
			    $(this).remove();
			// });
		    });
		    
		    currentItem++;
		    if (currentItem >= total) {
			currentItem = 0;
		    }
		    
		    setTimeout(spy, interval)
		}
		
		spy();
	    });
	};
    
})(jQuery);


//footer show list spy effect

$(function () {
	    $('.column2 .box ul.spy_footer').simpleSpy_footer();
	});

(function ($) {
    
	$.fn.simpleSpy_footer = function (limit, interval) {
	    limit = limit || 3;	//number of posts appear
	    interval = interval || 4000;	//delay of sliding
	    
	    return this.each(function () {
		// 1. setup
		    // capture a cache of all the list items
		    // chomp the list down to limit li elements
		var $list = $(this),
		    items = [], // uninitialised
		    currentItem = limit,
		    total = 0, // initialise later on
		    height = $list.find('> li:first').height();
		    
		// capture the cache
		$list.find('> li').each(function () {
		    items.push('<li>' + $(this).html() + '</li>');
		});
		
		total = items.length;
		
		$list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
		
		$list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();
	
		// 2. effect        
		function spy() {
		    // insert a new item with opacity and height of zero
		    var $insert = $(items[currentItem]).css({
			height : 0,
			opacity : 0,
			display : 'none'
		    }).prependTo($list);
				
		    // fade the LAST item out
		    $list.find('> li:last').animate({ opacity : 0}, 500, function () {
			// increase the height of the NEW first item
			$insert.animate({ height : height }, 500).animate({ opacity : 1 }, 500);
			
			// AND at the same time - decrease the height of the LAST item
			// $(this).animate({ height : 0 }, 1000, function () {
			    // finally fade the first item in (and we can remove the last)
			    $(this).remove();
			// });
		    });
		    
		    currentItem++;
		    if (currentItem >= total) {
			currentItem = 0;
		    }
		    
		    setTimeout(spy, interval)
		}
		
		spy();
	    });
	};
    
})(jQuery);

							
// -------------------------------------------------------------------------------------------
// sidebar
// -------------------------------------------------------------------------------------------

//menu links effects							
							
$(document).ready(function(){

	      $('.sidebar_box ul.menu_sidebar li a').hover(function() {
	        $(this).stop().animate({ paddingLeft: '31px', backgroundPosition: '10px' }, 300);
	      }, function() {
	        $(this).stop().animate({ paddingLeft: '21px', backgroundPosition: '0px' }, 300);           
	      });

		
});


							
// -------------------------------------------------------------------------------------------
// lightbox image effect
// -------------------------------------------------------------------------------------------							
							
							
$(document).ready(function(){

	      $('.entry a.lightbox_image span.preloading, .entry a.lightbox_video span.preloading').hover(function() {
	        $(this).stop().animate({ opacity: '.6' }, 400);
	      }, function() {
	        $(this).stop().animate({ opacity: '1' }, 400);           
	      });

		
});


// -------------------------------------------------------------------------------------------
// form elements
// -------------------------------------------------------------------------------------------							

//search form

$(document).ready(function() {
	$('.search ul li input[type="text"]').focus(function() {
	    if (this.value == this.defaultValue){ 
		this.value = '';
			}
			if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('.search ul li input[type="text"]').blur(function() {
	    if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
			}
	});
});			


// -------------------------------------------------------------------------------------------
// IE6 png fix
// -------------------------------------------------------------------------------------------							

DD_belatedPNG.fix(
'.logo a, #headers_and_featured, ul.menu .sub, .kwicks li a, .nivoSlider, a.nivo-nextNav, a.nivo-prevNav, #slider .nivo-controlNav a,  						 #slider .nivo-controlNav a.active, ul.icons li a, ul.icons li a img, .sidebar_box ul.menu_sidebar li a, #wrapper_footer, .column1 .box ul li, .column .box h3, .column1 .box ul li a, .column2 .box ul.show_list li, #wrapper_mini_footer, .entry .shadow_effect_910px, .entry 		   .shadow_effect_630px, .entry .shadow_effect_443x,.entry .shadow_effect_288px, .entry .shadow_effect_210px, .entry .shadow_effect_194px, 		.entry .shadow_effect_303px,.entry a.lightbox_image, .entry a.lightbox_video, .search ul li input.submit, ul.get_in_touch li.site_info, ul.get_in_touch li.contact_phone, ul.get_in_touch li.contact_support, .featured_4boxes img, .featured_heading, .featured_heading .featured_button a');




