$(document).ready( function() { 
	// enable stylish select
	//$('select').sSelect( {ddMaxHeight: '300px'} );
	
	// enable jfontsizer
	$('#fontsizer').jfontsizer({
		//applyTo: "#contentarea",
		applyTo: "#content",
		changesmall: '2',
		changelarge: '2',
		 expire: 30
	 });
	 
	// handle popup windows
	$('.popup').click( function() { 
		// get the screen height and width 
    	var maskHeight = $(document).height(); 
    	var maskWidth = $(window).width();
	
		// calculate the values for center alignment
    	//var dialogTop =  (maskHeight/3) - ( $("#" + $(this).attr("rel") ).height() ); 
		var dialogTop = $(window).scrollTop() +40;
    	var dialogLeft = (maskWidth/2) -  ( $("#" + $(this).attr("rel") ).width()/2);
		
		$("#" + $(this).attr("rel") ).css({top:dialogTop, left:dialogLeft}).show();
    	return false;
	});
	
	// popups
	 $('.popupcontent').click(function () {    
        $('.popupcontent').hide();      
        return false;
    });
	
	// pricepopups
	$('.pricepopup').hover( function() {
		$(this).find( ".innerprice").show();
	}, function () {
   		 $(this).find( ".innerprice").hide();
  	} );
	
	// accordian items display
	$('.item .readmore').click( function() { 
		alt = $(this).attr( "rel" );
		$(this).attr( "rel",  $(this).text() );
		$(this).text( alt );
		$(this).next( ".accordianitem").animate({ opacity: 'toggle', height: 'toggle' }, "slow");
	});
	
	//opacity buttons
	$('.button').mouseenter( function(){ 
		$(this).stop().animate({ opacity: 0.7 }, 200); 
	}).mouseleave( function(){ 
		$(this).stop().animate({ opacity: 1.0 }, 200);
	});
	$('.changesubmit').change( function() { 
		$(this).closest( 'form').submit();
	});
	
	/* Sliding Banner Code */
	var upd =0;
	$('#slideContainer').click( function() { clearInterval( upd ); })
	$('#thumbPages li').click( function() { rotate(  $(this).attr( "id").replace( "Slider", "" )  ) });
	if ( $("#slideContainer").length ) {
		upd = setInterval ( function() { 
			rotate ( $('#thumbPages li:last').hasClass( "active" ) ? 0 : parseInt( $('#thumbPages li.active').attr( "id" ).replace( "Slider",""  )  ) + 1 );
		}, 6000 );
	}
	function rotate( id ) {
		$('#thumbPages li').removeClass( "active" );
		$('#thumbPages #Slider' + id  ).addClass( "active" );	
		pos = ( id * 725 ) *-1;
		$('#bannerSlider').stop().animate(  {left: pos }, 500 );
	}
	
}); 




