// JavaScript Document
//initialize menu
ddsmoothmenu.init({
 mainmenuid: "menuWrapper", //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"]
})

if (jQuery.browser.msie)
        $('img[src$=".png"]').each(function() { // must have quotes around .png
            this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+this.src+",sizingMethod='scale')";
        });

//preload images
jQuery.preloadImages = function() {   
     for(var i = 0; i<arguments.length; i++)   
    {
          jQuery("<img>").attr("src", arguments[i]);   
    }
}

//accolades slideshow
//show a new image every 1500 ms to start
	var id1  = setInterval("show1()", 3500);//fade in featured
	var id2  = setInterval("show2()", 7500);//fade out featured
	
	var id3  = setInterval("show3()", 9500);//fade in top 10
	var id4  = setInterval("show4()", 13500);//fade out top 10
	
	var id5  = setInterval("show5()", 15500); //fade in promotion world
	var id6  = setInterval("show6()", 19500);//fade out promotion world
	
	var id7  = setInterval("show7()", 21500);//fade in inc 5000
	var id8  = setInterval("show8()", 25500);//fade out inc 5000
	
	var id9  = setInterval("show9()", 27500);// fade in services list
	var id10 = setInterval("show10()", 31500);// fade out services list
	
	var id11 = setInterval("show11()", 33500);
	var id12 = setInterval("show12()", 37500);
	
	var id13 = setInterval("show13()", 38000);//last slide = show form
	
//show featured
	function show1()
	{
		$(".slide:eq(0)").fadeIn("slow");
		clearInterval(id1);
	}
//hide featured
	function show2()
	{
		$(".slide:eq(0)").fadeOut ("slow");
		clearInterval(id2);
	}
//show top 10
	function show3()
	{
		$(".slide:eq(1)").fadeIn ("slow");
		clearInterval(id3);
	}	
//hide top 10
	function show4() 
	{
		$(".slide:eq(1)").fadeOut ("slow");
		clearInterval(id4);
	}
//show promotion world
	function show5()
	{
		$(".slide:eq(2)").fadeIn ("slow");
		clearInterval(id5);
	}
//hide promotion world
	function show6()
	{
		$(".slide:eq(2)").fadeOut ("slow");
		clearInterval(id6);
	}
	//show inc 5000
	function show7()
	{
		$(".slide:eq(3)").fadeIn ("slow");
		clearInterval(id7);
	}
//hide inc5000
	function show8()
	{
		$(".slide:eq(3)").fadeOut ("slow");
		clearInterval(id8);
	}
		//show services list
	function show9()
	{
		$(".slide:eq(4)").fadeIn ("slow");
		clearInterval(id9);
	}
//hide services list
	function show10()
	{
		$(".slide:eq(4)").fadeOut ("slow");
		clearInterval(id10);
	}	
	function show11()
	{
		$(".slide:eq(5)").fadeIn ("slow");
		clearInterval(id11);
	}
//hide services list
	function show12()
	{
		$(".slide:eq(5)").fadeOut ("slow");
		clearInterval(id12);
	}
	//showform
	function show13()
	{
		$('#introlist').fadeOut("fast");
			$('#get-started').hide();
			if (jQuery.browser.msie) {
			  if(parseInt(jQuery.browser.version) == 7) {
				  $('#form').show("fast");
			  }
			  else {
				  $('#form').show("slide", { direction: "left" }, 500);
			  }
			}
			else {
				$('#form').show("slide", { direction: "left" }, 500);
			}
		clearInterval(id13);
	}
	
	
	$(document).ready(function() {
//= fix pngs in ie
			var i;
			for (i in document.images) {
			if (document.images[i].src) {
			var imgSrc = document.images[i].src;
			if (imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.png') {
				document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
					}
				}
			}		

//= get slideshow
			function slideshow() {
				var id1;
				var id2;
				var id3;
				var id4;
				var id5;
				var id6;	
				var id7;
			}

//= get rss feed ready
			//options here: http://www.zazar.net/developers/zrssfeed/default.html#instructions
			$('#rssfeed').rssfeed('http://www.customermagnetism.com/seoblog/feed/', {
				limit: 4,
				//content: true,
				header: false
			  });
			
			//= turn on form validation
			$("#qcform").validate();
			slideshow();
			$('#form').hide();
		
//= form/get started functionality
		function callback() {
			$('#get-started').show("slide", { direction: "left" }, 500);
			$('#introlist').fadeIn("7000");
				$('#introlist #head').css('display','none');
				$('.img li').css('display','none');
				$('#introlist #services').css('display','block');
			return false;
		};						   
		
		//show on click
		$('a#getform').click(function() {
			clearInterval(id1);
			clearInterval(id2);
			clearInterval(id3);
			clearInterval(id4);
			clearInterval(id5);
			clearInterval(id6);
			$('#introlist').fadeOut("fast");
			$('#get-started').hide();
			if (jQuery.browser.msie) {
			  if(parseInt(jQuery.browser.version) == 7) {
				  $('#form').show("fast");
			  }
			  else {
				  $('#form').show("slide", { direction: "left" }, 500);
			  }
			}
			else {
				$('#form').show("slide", { direction: "left" }, 500);
			}
			return false;
		  });
		$('a#getintro').click(function() {
			if (jQuery.browser.msie) {
			  if(parseInt(jQuery.browser.version) == 7) {
				  $('#form').hide("fast", callback);
			  }
			  else {
				  $('#form').hide("slide", { direction: "left" }, 500, callback);
			  }
			}
			else {
				$('#form').hide("slide", { direction: "left" }, 500, callback);
			}
			return false;
		  });
	});
