/*
if($.browser.msie && jQuery.browser.version.substr(0,1)=="6"){
   	$('body').prepend('<div class="ie6Message">We have detected that you are currently using Internet Explorer version 6 as your web browser.  This browser is no longer supported by Microsoft, and therefore poses a security risk to your computer.  It will not display this website as intended.<br />We recommend either installing <a href="http://www.mozilla.com/firefox/" target="_blank">Mozilla Firefox</a>, or upgrading to a recent version of <a target="_blank" href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a>, both of which are free to use.</div>');
}
*/

$(window).load(function() {
	$('#slideshow').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:false, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:1, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
});

applyCorners();

//styling of ol and ul lists
$("#main-grey .col-twothird-grey-right ol li, #main-grey .col-twothird-grey-right ul li").wrapInner("<span>");
$("#main-grey .col-twothird-grey-right ol, #main-grey .col-twothird-grey-right ul").css("visibility","visible");

$(document).ready(function(){
	
	if(typeof window.initialize == 'function') initialize();
	
	//replace all rel externals with targets
	$("a[rel='external']").attr("target","_blank");
	
	//hide title tags
	$("a:not(.colorbox)").attr("title","");	
	
	
	//input, textarea fields clear default text
	$("input[type=text],input[type=email],input[type=tel], textarea").each(function() {
		//save all original field values
		$.data($(this)[0],"origVal",$(this).val());
		$.data($(this)[0],"origCol",$(this).css("color"));
		//replace default value in all form text fields
		$(this).focus(function() {		
			if($(this).val() == $.data($(this)[0],"origVal")){
				$(this).val("");
				$(this).css("color","#000000");
			}
		});
		//restore default value if empty
		$(this).blur(function() {
			if($(this).val() == ""){
				$(this).val($.data($(this)[0],"origVal"));
				$(this).css("color",$.data($(this)[0],"origCol"));
			}
		});
	});
	
	//form links
	$(".jFormSubmit").each(function(){
		$(this).click(function(event){
			$(this).parents("form").submit();
			event.preventDefault();
		});
	});
	
	//colorbox
	$("a[rel='colorbox_video']").colorbox({iframe:true, innerWidth:640, innerHeight:360, opacity:.75});
	$(".colorbox").colorbox({transition:'fade', speed:500, opacity:.75, innerWidth:640, innerHeight:480});
	
	//Dropdown
	$('.topnav').droppy();

	//corners
	applyCorners();
	
	//newsletter
	//if($(".newsletterSuccess:contains('signup successful')")[0]) $("#specialsForm").hide();
	
	$(":checkbox").each(function(){
		//log($(this).next("span").html());
		product = $.getUrlVar("product");
		
		if(product == 'q-f-and-i') product = 'q-f&i';
		
		if($(this).next("span:containsi('"+product+"')").html()) $(this).attr("checked","checked");
	});
	

});

function formSubmit(form,target){
	$(form).submit();	
	setTimeout(function(){showPage(target)},2000);
}

function showPage(url){
	//log("/"+url);
	window.location = "/"+url;
	//log(window.location);
}

function applyCorners(){
	if(!($.browser.msie && jQuery.browser.version.substr(0,1)=="6")){
		//no rouded goodness for IE6
		$(".topnav, #container-slideshow, .button").corner("5px");
		//sidebar elements
		$(".custombox, .custombox-grey, #saleschat, #techchat, #main-grey #news").corner("5px");
		$(".topnav > li > a.first").corner("5px tl bl");
		$(".topnav > li > a.last").corner("5px tr br");	
		$(".subnav").corner("5px br bl");
		
		//side nav background
		$("nav#side ul li.active").prev().addClass("no-bg");
		$("nav#side ul li:last-child, nav#related ul li:last-child").not(".active").addClass("no-bg");
	}
	
	if($.browser.msie){
		$("article:last-child").addClass("last-child");
			
	}
}

