/*
	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");

	// IE6 helper functions
	if ($.browser.msie && $.browser.version < 7) {

		// PNG fix
		iepngfix();
	}



//alert("Here I Am");


$(document).ready(function(){

	var $gallery = $("div#inside_pics");

	// Create extra elements & navigation links
	$gallery
		.wrap('<div id="gallery-wrapper"></div>')
		.wrap('<div id="gallery-innerwrapper"></div>');

	// Remove IE's alt tooltip
	if ($.browser.msie) { $gallery.find("img").attr("title", ""); }


	// Settings
	var currentimage = 0;
	var currentpage = 0;  // 6 images per page
	var imagecount = $gallery.find("li").size();

	// Image width
	var $firstimage = $gallery.find("img:first");
	var imageWidth = 240;
	var gallerywidth = 240;
	var galleryheight = 370;
	
	// Set the strip's actual width to be safe
	$gallery.width(imageWidth * imagecount);


	// Movement links
	$("#gallery-next").click(function(){
//
		// Do not move on last page
		if ((currentpage+1) >= imagecount) { return false; }

		// Undisable other link
		$("#gallery-previous").removeClass("disabled");

		// Slide images
		$gallery.animate({left: -gallerywidth*++currentpage}, 1000, "swing", function(){

			// Disable link if last page
			// increase or decrease the +4 if you add images??
			if ((currentpage+4) >= imagecount) { $("#gallery-next").addClass("disabled"); }

			// Click first link in group (put inside callback for smoother scrolling)
			$("#gallery-innerwrapper img").eq(currentpage).click();
		});

		return false;
	});

	$("#gallery-previous").click(function(){
		// Do not move on first page
		if (currentpage == 0) { return false; }

		// Undisable other link
		$("#gallery-next").removeClass("disabled");

		// Slide images
		$gallery.animate({left: -gallerywidth*--currentpage}, 1000, "swing", function(){

			// Disable link if first page
			if (currentpage == 0) { $("#gallery-previous").addClass("disabled"); }

			// Click first link in group (put inside callback for smoother scrolling)
			$("#gallery-innerwrapper img").eq(currentpage).click();
		});

		return false;
	});


});

		
		
//~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Show active subnavigation link and mark wrapper to match page name
	var urlpaths = location.href.split("?")[0].split("#")[0].split("/");
	$("#wrapper").addClass(urlpaths[4].split(".")[0]);
	if (urlpaths[4]) {
		// Match the path filename to a link
		$("#subnav ul li a[href*='" + urlpaths[4] + "']").addClass("active");
		$("#sidenav ul li a[href*='" + urlpaths[4] + "']").addClass("active");
		//$("#contentwrapper").addClass(urlpaths[3].split(".")[0]);
		//$("#contentwrapper").addClass(urlpaths[4].split(".")[0]);
		

	} else {
		// Assume index page
		$("#subnav ul a[href$='index.php']").addClass("active");
		//$("#contentwrapper").addClass(urlpaths[3].split(".")[0]);
		//$("#contentwrapper").addClass("landing");
	}
///////

$("#innercontentwrap").after('<div id="innercontentbtm"></div>');

//$("#maincontent p:first").addClass("firstp");


});




/* --- 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);
	});
}

// email hider--This script is to kill any spambot in its tracks
function returnEmail(username, domain) {
					var formattedEmail = username+"@"+domain;
					window.location.href = "mailto:"+formattedEmail+"?subject=";
				}
// ~~~~~~~EXAMPLE~~~~~~~<a href="javascript:returnEmail('name', 'domain.com');" title="Click to email">