

/*
	[Apptix] scripts (utilizing jQuery 1.3.2)
	Developed by Foamcube
*/

/* --- Initialize page --- */
$(document).ready(function(){

	// content top area
	//$("#content-wrapper>#content").insertBefore("<div id='content-wrapper-top'></div>");

	// Stripe row colors
	$("table.data tr:nth-child(even)").not(".even").not(".odd").addClass("even");
	

	// Insert document icons
	/*$("a[href$=pdf]:not(:has(img))").append('<img class="icon" src="images/icon_pdf.gif" width="14" height="14" alt=" (PDF)">');
	$("a[href$=doc]:not(:has(img)), a[href$=docx]:not(:has(img))").append('<img class="icon" src="images/icon_word.gif" width="14" height="14" alt=" (Word Document)">');
	$("a[href$=xls]:not(:has(img)), a[href$=xlsx]:not(:has(img))").append('<img class="icon" src="images/icon_excel.gif" width="14" height="14" alt=" (Excel Spreadsheet)">');
	$("a[href$=ppt]:not(:has(img)), a[href$=pptx]:not(:has(img))").append('<img class="icon" src="images/icon_powerpoint.gif" width="14" height="14" alt=" (Powerpoint Presentation)">');*/

	// Column childs CSS3 fix
	$(".columns .col:last-child").addClass("last-child");
	$(".columns .col:first-child").addClass("first-child");
	$(".columns.three .col:eq(1)").addClass("middle-child");


$("#footer .columns a").each(function(){
   $(this).attr("title", $(this).text());
});


//collapses the quote box on page load if set

if (customQuoteBox == "off") {
	//console.log (customQuoteBox);
	$("#quoteform").css("display","none"); 
	$("#get-a-quote3").removeClass("qactive");
}

else {
	
	}



/*
Form Field Value Swap
*/

    swapValues = [];
    $(".swap_value").each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });
/*
 tabbed box
*/
$(".tabbed-box>ul>li:last-child").addClass("last");
$(".tabbed-box>ul>li:first-child").addClass("first");
$(".tabbed-box>ul>li").each(function(){
var newclass = $(this).children("a").attr("rel");
   $(this).addClass(newclass);// give the list item a classname that matches the 'rel' attribute of it's child a tag
   $(this).attr("title", $(this).text());// inject a title attribute that matches the contents
});

$(".tabbed-box>ul>li").addClass("tabbed-box-li");
// When a link is clicked
		$(".tabbed-box>ul>li>a").click(function () {
			
			// switch all tabs off
			$(".tabbed-box>ul>li.active").removeClass("active");
			
			// switch this tab on
			$(this).parent().addClass("active");
			
			// slide all elements with the class 'tabbed-content' up
			$(".tabbed-content").hide();
			
			// Now figure out what the 'rel' attribute value is and find the element with that id.  Then slide that down.
			var content_show = $(this).attr("rel");
			$("#"+content_show).fadeIn();
		  return false;
		});


/*
--tabbed table box--
*/
$(".tabbed-table-wrap>div:first-child, .tabbed-table-wrap ul.table-tabs>li:first-child").addClass("first");
$(".tabbed-table-wrap>div:last-child, .tabbed-table-wrap ul.table-tabs>li:last-child").addClass("last");

$("ul.table-tabs>li>a").click(function () {
	var content_show = $(this).attr("rel");
			// switch this tab on
			$("ul.table-tabs>li>a.active").removeClass("active");
			$(this).parent().parent().siblings(".tabbed-table-content").hide();
			// switch this tab on
			$(this).addClass("active");
			$("#"+content_show).fadeIn();
			
		  return false;
		});


//$("table.package-data tr.details").after("<tr><td></td></tr>");
//stripe the rows
$("table.package-data tr:nth-child(even)").not(".even").not(".odd").addClass("even");

$("table.package-data tr td:first-child").addClass("first");

$("tr.with-details>td").hover(function(){
				$(this).addClass("hover");
			}, function(){
				$(this).removeClass("hover");
			});
$("tr.with-details>td").click(function () {
var theDetails = $(this).parents().children().children(".details")
if (theDetails.is(":hidden")){
		$(theDetails).show();
		$(this).parents("tr").addClass('showing');
}
else {
		$(theDetails).hide();
		$(this).parents("tr").removeClass('showing');
}
		  return false;
});

/*
show/hide more-text
*/

$("a.show-toggle").click(function () {
		$(this).parents().next(".more-text").toggle();
		return false;
});


$("a.show-more").click(function () {
		$(this).parents().next(".more-text").show();
		return false;
});

$("a.hide-more").click(function () {
		$(this).parents(".more-text").hide();
		return false;
});

/*
tooltip
*/
$('a.tipper').qtip({
style: {
name: 'blue'
}
});

$('a.tipper2').gtip({
style: { 
      width: 270,
      padding: 16,
      background: '#102647',
      color: '#ffffff',
      textAlign: 'left',
	  dropshadow: 'true',
      border: {
         width: 5,
         radius: 3,
         color: '#e9e9e9'
      },	  
      target: 'topleft',
      tooltip: 'topLeft',
      name: 'dark' // Inherit the rest of the attributes from the preset dark style
   }
});

$('a.right-tipper').qtip({
style: { 
      width: 200,
      padding: 5,
      background: '#102647',
      color: 'black',
      textAlign: 'center',
      border: {
         width: 3,
         radius: 5,
         color: '#ffffff'
      },
      target: 'bottomRight',
      tooltip: 'topLeft',
      name: 'dark' // Inherit the rest of the attributes from the preset dark style
   }
});

/*
Side column Quote form
*/

$("a#get-a-quote3").click(function() {
if ($(this).is(".qactive")){
$('#quoteform').hide('slow');
$(this).removeClass("qactive");
}
else {
$(this).addClass("qactive");
$('#quoteform').show('slow');
}    
    return false;
  });

/*
4.) cycle box call. conditional for IE6 to remove boxes 2-3 & not cycle
*/
if (document.getElementById("home")) {

	if ($.browser.msie && $.browser.version < 6) {
	$('#top-photo-area1, #top-photo-area3').remove();
	}
	else{
		/* Homepage cycle box */
		$('#cyclewrap')
			.wrap('<div id="dblwrap"></div>')
			.after('<div id="cyclenumbers">')
			.cycle({
				fx: 'fade',
				speed: '900',
				timeout: 5000,
				pause: true,
				pager: '#cyclenumbers'
			});
		//$("div#cyclenumbers").append('<div class="white"></div>');
	}



/*
5.) mozilla hacks
*/
if ($.browser.mozilla && document.getElementById("home")) {
    $("#contact-strip ul").addClass("bumpit");
 }

		
		// IE6 helper functions
		if ($.browser.msie && $.browser.version < 7) {
	
		// Navigation hover
			$("#navigation>li").hover(function(){
				$(this).addClass("hover");
			}, function(){
				$(this).removeClass("hover");
			});
	
			// PNG fix
			iepngfix();
		}
}
});




/* --- IE6 foreground PNG fix --- */
function iepngfix() {

	// IE 5.5 and 6.0 PNG filter support (derived from youngpup.net)
	$("img[src$=png]").each(function(){
		var src = this.src;
		var div = document.createElement("div");

		// Set replacement div properties
		div.id = this.id;
		div.className = this.className;
		div.title = this.title || this.alt;
		div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizing='scale')";
		div.style.width = this.width + "px";
		div.style.height = this.height + "px";

		// Replace image with transparent div
		this.replaceNode(div);
	});
}