//image preloader
$(function () {
			$('img').hide();//hide all the images on the page
		});
		
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			var int = setInterval("doThis(i)",500);//500 is the fade in speed in milliseconds
		});

		function doThis() {
			var imgs = $('img').length;//count the number of images on the page
			if (i >= imgs) {// Loop the images
				clearInterval(int);//When it reaches the last image the loop ends
			}
			$('img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
			i++;//add 1 to the count
		}
		//image preloader ends
		
//menu hover effect	
$(document).ready(function(){ 
	
	$("#social-menu li a").css({"opacity" : 0}).hover(function(){
		$(this).stop().animate({"opacity" : 1}, 400); //Change fade-in speed
	
		}, function(){
		$(this).stop().animate({"opacity" : 0}, 100);//Change fade-out speed
	
	});
	
});	//menu hover effect	ends

//selection styling
(function($){
 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="dropdown fidiz-contact "><span class="SelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){
				// selectBoxSpanInner.text($(this).val()).parent().addClass('changed');   This was not ideal
			selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
				// Thanks to Juarez Filho & PaddyMurphy
			});
			
	  });
	  }
	}
 });
})(jQuery);

$(document).ready(function(){
	$('.dropdown').customStyle();
});//selection styling ends


//switch stylesheet
$("document").ready(function() {
	var colors = new Array;

	// Disable all .switch stylesheets and build array of colours
	$(".switch[rel='stylesheet']").each(function() {
		$(this).attr("disabled", "true");
		colors.push($(this).css("background-image"));
	});
	
	
	$(colors).each(function(index, el) {
		$("#sheetswitch").append("<a class='swatch' style='background-image:" + el + ";'></a>");
	});
	
	$("#sheetswitch").append("<a href='#' class='sheetswitch_next'>next</a>");
	
	$(".swatch").click(function() {
		$(".swatch").removeClass("swatch_hi");
		$(this).addClass("swatch_hi");
		var index = $(".swatch").index(this);
		$(".switch[rel='stylesheet']").attr("disabled", "true");
		$(".switch[rel='stylesheet']").eq(index).attr("disabled", "");
		$.cookie('mysite_sheetswitch_idx', index, {expires: 7});
	});
	
	$(".sheetswitch_next").click(function() {
		var selected = $(".switch[rel='stylesheet']").filter(function () { return $(this).attr("disabled") == false; });
		var current_idx = $(".switch[rel='stylesheet']").index($(selected));
		var length = $(".switch[rel='stylesheet']").size();
		
		if (current_idx >= 0) {
			var next = current_idx + 1;
			if (next > (length - 1)) next = 0;
			
			$(".switch[rel='stylesheet']").attr("disabled", "true");
			$(".switch[rel='stylesheet']").eq(next).attr("disabled", "");
			
			$(".swatch").removeClass("swatch_hi");
			$(".swatch").eq(next).addClass("swatch_hi");
			
			$.cookie('mysite_sheetswitch_idx', next, {expires: 7});
		}
		
		return false;
	});
	
	$(".sheetswitch_prev").click(function() {
		var selected = $(".switch[rel='stylesheet']").filter(function () { return $(this).attr("disabled") == false; });
		var current_idx = $(".switch[rel='stylesheet']").index($(selected));
		var length = $(".switch[rel='stylesheet']").size();
		
		if (current_idx >= 0) {
			var next = current_idx - 1;
			if (next == -1) next = (length - 1);
			
			$(".switch[rel='stylesheet']").attr("disabled", "true");
			$(".switch[rel='stylesheet']").eq(next).attr("disabled", "");
			
			$(".swatch").removeClass("swatch_hi");
			$(".swatch").eq(next).addClass("swatch_hi");
			
			$.cookie('mysite_sheetswitch_idx', next, {expires: 7});
		}
		
		return false;
	});
	
	if ($.cookie('mysite_sheetswitch_idx')) {
		var idx = $.cookie('mysite_sheetswitch_idx');
		$(".switch[rel='stylesheet']").eq(idx).attr("disabled", "");
		$(".swatch").eq(idx).addClass("swatch_hi");
	}
});
//switch stylesheet ends
//tabs
$(document).ready(function() {

			$.featureList(
				$("#tabs li a"),
				$("#output li"), {
					start_item	:0
				}
			);			
		});
;(function($) {
	$.fn.featureList = function(options) {
		var tabs	= $(this);
		var output	= $(options.output);

		new jQuery.featureList(tabs, output, options);

		return this;	
	};

	$.featureList = function(tabs, output, options) {
		function slide(nr) {
			if (typeof nr == "undefined") {
				nr = visible_item + 1;
				nr = nr >= total_items ? 0 : nr;
			}

			tabs.removeClass('current').filter(":eq(" + nr + ")").addClass('current');

			output.stop(true, true).filter(":visible").fadeOut();
			output.filter(":eq(" + nr + ")").fadeIn(function() {
				visible_item = nr;	
			});
		}

		var options			= options || {}; 
		var total_items		= tabs.length;
		var visible_item	= options.start_item || 0;

		options.pause_on_hover		= options.pause_on_hover		|| true;
		options.transition_interval	= options.transition_interval	|| 0;

		output.hide().eq( visible_item ).show();
		tabs.eq( visible_item ).addClass('current');

		tabs.click(function() {
			if ($(this).hasClass('current')) {
				return false;	
			}

			slide( tabs.index( this) );
		});

		if (options.transition_interval > 0) {
			var timer = setInterval(function () {
				slide();
			}, options.transition_interval);

			if (options.pause_on_hover) {
				tabs.mouseenter(function() {
					clearInterval( timer );

				}).mouseleave(function() {
					clearInterval( timer );
					timer = setInterval(function () {
						slide();
					}, options.transition_interval);
				});
			}
		}
	};
})(jQuery);
//tabs ends
//html 5 in IE
// For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(',');for(var i=0;i<e.length;i++){document.createElement(e[i])}})()

//html 5 in IE
