/*
	National Interest Security Company scripts (utilizing jQuery 1.2.6)
	Developed by Saforian
*/

/* --- Initialize page --- */
$(document).ready(function(){

	// 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");

	//layout application of the above
	$(".content_withleftside .col:last-child").addClass("last-child");
	$(".content_withleftside .col:first-child").addClass("first-child");

	// IE6 helper functions
	if ($.browser.msie && $.browser.version < 7) {

		// PNG fix
		iepngfix();
	}

	$('#home ul.news li:last-child').addClass("last")

//alert("Here I Am");
$("#subnav").wrap('<div id="subnav_wrap"><div id="subnav_left"><div id="subnav_right"></div></div></div>');
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

$(".vertical_logos img").hide();

$("#mission-services").hover(function(){
		$('#mission-services .vertical_logos img').fadeIn("medium");
	}, function(){
		$('#mission-services .vertical_logos img').fadeOut("slow");
	});
$("#information-solutions").hover(function(){
		$('#information-solutions .vertical_logos img').fadeIn("medium");
	}, function(){
		$('#information-solutions .vertical_logos img').fadeOut("slow");
	});


//HOMEPAGE POP-OUT BOXES

$("#pop-out-container>div").hide();


// ADD THE CLOSE BUTTON TO EACH POP-OUT DIV
//$(".pop-out .inside").after('<div class="close-me"><a href="#"></a></div>');

// CLOSE BUTTON'S CLOSE FUNCTION
$(".close-me a").click(function(){
			// CLose POP-OUT
			$("#pop-out-container>div:visible").fadeOut('fast').animate({top:"-20px"},250);
			return false;
		});


// THE POP-OUT "MAGIC" BEGINS

//  FOR IE 6

if ($.browser.msie && $.browser.version < 7) {
		$("#home-photos a").hover(function(){
			// Switch POP-OUT
			$("#pop-out-container>div:visible").hide();
			$(this.hash).show();

			return false;
		},function(){
		
		});
		
$("#pop-out-container div").hover(function(){
// nothing in here since we're already "over" the div, but we need a blank corresponding function.
	}, function(){
		$("#pop-out-container>div:visible").hide();
	});
	
}
else {

// FOR ALL OTHERS
	


$("#home-photos a").hover(function(){
		$("#pop-out-container>div:visible").fadeOut('fast').animate({top:"-10px"},50);
		$(this.hash).fadeIn(10).animate({top:"-21px"},50);
	}, function(){
// nothing in here since the div is being covered therefore forcing the mouseout, but we need a blank corresponding function.
	});
	

$("#pop-out-container div").hover(function(){
// nothing in here since we're already "over" the div, but we need a blank corresponding function.
	}, function(){
		$("#pop-out-container>div:visible").fadeOut('fast').animate({top:"-10px"},100);
	});

	

}
		
		
//~~~~~~~~~~~~~~~~~~~~~~~~~~~

// capabilities page fly outs

$("ul.continuum_list").hide();

$(".capabilities a.continuum").hover(function(){
		$(this.hash).slideDown("medium");
	}, function(){
		$(this.hash).slideUp("slow");
	});


});




/* --- IE6 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);
	});
}
