$(document).ready( function() {
$(".data-table tr:even").addClass("alt");
	
});
$(document).ready(function()
{
    // find all containers with the imageAdjust class and center images horizonally and vertically
    $(".imageAdjust").each(function(i)
    {
        var heightDiff = $(this).find("img").height() - $(this).height();
        var widthDiff = $(this).find("img").width() - $(this).width();

        if (heightDiff > 0)
        {
            $(this).find("img").css("marginTop", -heightDiff / 2);
        }

        if (widthDiff > 0)
        {
            $(this).find("img").css("marginLeft", -widthDiff / 2);
        }
    });

    $("a[href^='http']").each(function(i)
    {
        var $this = $(this);

        $this.bind("click", function()
        {
            pageTracker._trackPageview("/outgoing/" + $this.attr('href'));
        });
    });

    $("a[href$='pdf'][href$='doc'][href$='xls'][href$='jpg'][href$='gif'][href$='ppt']").each(function(i)
    {
        var $this = $(this);
        $this.bind("click", function()
        {
            pageTracker._trackPageview("/downloads/" + $this.attr('href'));
        });
    });


    $(".form-holder input").focus(function()
    {
        $(this).addClass("has-focus");
    });

    $(".form-holder textarea").focus(function()
    {
        $(this).addClass("has-focus");
    });

    $(".form-holder input").blur(function()
    {
        $(this).removeClass("has-focus");
    });

    $(".form-holder textarea").blur(function()
    {
        $(this).removeClass("has-focus");
    });


});





var strUserAgent = navigator.userAgent.toLowerCase();
var isIE = strUserAgent.indexOf("msie") > -1;
var isNS6 = strUserAgent.indexOf("netscape6") > -1;
var isNS4 = !isIE && !isNS6 && parseFloat(navigator.appVersion) < 5; 


/*

Accesible Pop Up Code

This file contains only functions necessary for the article features
The full library code and enhanced versions of the functions present
here can be found at http://v2studio.com/k/code/lib/

MISC CLEANING-AFTER-MICROSOFT STUFF

isUndefined(v)
    returns true if [v] is not defined, false otherwise

    IE 5.0 does not support the undefined keyword, so we cannot do a direct
    comparison such as v===undefined.
*/

// MISC CLEANING-AFTER-MICROSOFT STUFF

function isUndefined(v) {
    var undef;
    return v===undef;
}

function SetSearchIndicator(type)
{
	var indicator = document.getElementById("hdnSearchFlag");
	if(indicator != null)
		indicator.value = type;
}

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = '';

function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function CheckDD(itemID, exclVal)
{
	var o = GetMyObjectByID(itemID);
	var select = o.options[o.selectedIndex].value;
	if(exclVal == null)
		exclVal = "-Please Select-"
	if(select.length<1 || select == "0" || select == exclVal)
		return false;
	else
		return true;
}




function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

// XML Parser Object
var XmlParser = function() {
    this.xmlDoc = '';
}

// Parses XML object into xmlDocument in XMl.xmlDoc
XmlParser.prototype.Parse = function(xml) {
    try //Internet Explorer
    {
        this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        this.xmlDoc.async = "false";
        this.xmlDoc.loadXML(text);
    }
    catch (e) 
    {
        try //Firefox, Mozilla, Opera, etc.
        {
            parser = new DOMParser();
            this.xmlDoc = parser.parseFromString(xml, "text/xml");
        }
        catch (e) { alert(e.message) }
    }
}
XmlParser.prototype.Find = function(name) {
    return this.xmlDoc.getElementsByTagName(name);
}

/*
Select Box Redirect Function
This function controls the redirecting of select box selections
*/

function ShowPage(e)	{
	var s = e.options[e.selectedIndex].value;
	if(s.length > 0)
	{
		document.location.href = s;
	}
}


function ShowPlaceHolder(e)	{
	var s = e.options[e.selectedIndex].value;
	if(s.length > 0)
	{
		document.location.href = "#"+ s;
	}
}

function GoToProject(e)
{
	var s = e.options[e.selectedIndex].value;
	var sText = e.options[e.selectedIndex].text;
	var sBase = e.options[e.selectedIndex].text;
	
	if(s =="0" || s.length == 0)
	 return;
	
	if(s.length > 0)
	{
		if(s.indexOf("http") != -1||s.indexOf("/")==0)
		{
			document.location.href = s;
			return;
		}
		else if(s.indexOf("../") != -1)
		{
			document.location.href = s.replace("../","");
			return;
		}
		else if(s.indexOf("ourprojects.aspx") != -1)
		{
			document.location.href = s.replace("../","");
			return;

        }
		else if(s.indexOf("<link") != -1){
		    var xml = new XmlParser();
		    xml.Parse(s);
		    var results = xml.Find("url");
		    document.location.href = "http://"+results[0].childNodes[0].nodeValue;
		}
		else
		{
			sText = sText.toLowerCase();
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			sText = sText.replace(' ','');
			
			document.location.href = "project/"+ sText +".aspx";
		}
	}
}

function GoToRegion(e)
{
	var s = e.options[e.selectedIndex].value;
	if(s.length>0)
	{
		if(s.indexOf("../") != -1)
		{
			document.location.href = s.replace("../","");
			return;
		}
		
		document.location.href="ourprojects.aspx?Region="+ s;
	}
}

function SiteSearch()
{
	var search_text = GetMyObjectByID("site_search").value;	
	if(search_text.length>0)
		document.location.href ="/landcom/searchresults.aspx?q="+ search_text
		
}
/* Jump to an anchor on the same page */
function Jump(s)
{
	var hash = s.options[s.selectedIndex].value;
	if (hash != "")
	{
	    var script = window.location.protocol + "//" + window.location.hostname + window.location.pathname;
	    if (window.location.href.indexOf("#") > -1)
	    {
	        window.location.href = window.location.href.substring(0, window.location.href.indexOf("#"))+"#item"+hash;
	    } else
	    {
	        window.location.href = window.location.href + "#item" + hash;
	    }
	}
}

/* Jump to an item on another same page */
function JumpItem(s)
{
	var url = s.options[s.selectedIndex].value;
	if (url != "")
	{
	    alert(window.location);
	    window.location = window.location+"#"+url;
	}
}

//mask input to allow integer only
function CheckNumeric(objEvent)
{
    var iKeyCode, strKey;
    var reValidChars = /\d/;
    var reKeyboardChars = /[\x00\x03\x08\x0D\x16\x18\x1A]/;
    if (isIE)
    {
        iKeyCode = objEvent.keyCode;
    } else
    {
        iKeyCode = objEvent.which;
    }

    strKey = String.fromCharCode(iKeyCode);

    if (!reValidChars.test(strKey) && !reKeyboardChars.test(strKey))
    {
        return false;
    }
}



/*
 * Popup window script 
 *  
 * Example markup 
 * <a href="mypage.html" onclick="popUpWin(this.href,'console',660,520);return false;" title="Open popup window">Link text</a>
 */
var newWindow = null;
function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	closeWin();
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}