//////////////////////////////////////////////////Change image for home page slider
/* This was the code for work.swf
function changeImage(direction, coordinate) {
		
	if($.browser.msie){
				
		$('#info'+coordinate+'').css("display","block");
		$('.projectImages').html('<img src="images/image'+coordinate+'.png" alt="Project Work" id="work" />');
		
	} else {
		
		$('#info'+coordinate+'').css("display","block");
		$('.projectImages').html('<img src="images/image'+coordinate+'.png" alt="Project Work" id="work" />');
		
	}
}
*/

//////////////////////////////////////////////////Change image for home page slider
function changeImage(index) {
		
	if($.browser.msie){
		
		$('.project-images ul li').removeClass('opened');
		$('#info-'+index+'').addClass('opened');
		$('.project-images ul li').html('<a href="portfolio.php"><img src="images/home-img-'+index+'.png" alt="Project Work" id="work" /></a>');
		
	} else {
		
		//$('.us').css('z-index', '10');
		$('.project-images ul li').removeClass('opened');
		$('#info-'+index+'').addClass('opened');
		$('.project-images ul li').html('<a href="portfolio.php"><img src="images/home-img-'+index+'.png" alt="Project Work" id="work" /></a>');
		
	}
	
	
	//setTimeout('switchIt()', 600);
	
}

/*
function switchIt() {
	$('.us').css('z-index', '1');
}
*/

//////////////////////////////////////////////////Dropdown menus
$(document).ready(function () {
	$(".subnav-wrap-who").addClass("alt");
	
    $('#whoHead').hover(
	function () {
		$('.subnav-wrap-who').stop(true,true).slideToggle('fast');
    },
	function () {
		$('.subnav-wrap-who').stop(true,true).slideToggle('fast');
    }
	);
	
});
$(document).ready(function () {
	$(".subnav-wrap-how").addClass("alt");
    $('#howHead').hover(
	function () {
		$('.subnav-wrap-how').stop(true,true).slideToggle('fast');
    },
	function () {
		$('.subnav-wrap-how').stop(true,true).slideToggle('fast');
    }
	);
});
$(document).ready(function () {
	$(".subnav-wrap-what").addClass("alt");
    $('#whatHead').hover(
	function () {
		$('.subnav-wrap-what').stop(true,true).slideToggle('fast');
    },
	function () {
		$('.subnav-wrap-what').stop(true,true).slideToggle('fast');
    }
	);
});

////////////////////////////////////////////////// Menu Highlighter
function extractPageName(hrefString)
{
	var arr = hrefString.split('/');
	return  (arr.length<2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();               
}

function setActiveMenu(arr, crtPage)
{
	for (var i=0; i<arr.length; i++)
	{
		if(extractPageName(arr[i].href) == crtPage)
		{
			if (arr[i].parentNode.tagName != "DIV")
			{
				arr[i].className = "current";
				arr[i].parentNode.className = "current";
			}
		}
	}
}

function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;

	if (document.getElementById("nav")!=null)
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
}

/***************************************** onfocus onblur events *****************************************/
$(document).ready(function() {
	$.fn.search = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	$(':input:not(input[type=checkbox])').search();
});
