var portfolioDetails = [
	{title: 'Sony Gamer Advisory Panel (G.A.P.)', description: 'The Gamer Advisory Panel (or G.A.P.) is the most elite membership tier in the PlayStation&reg; Underground&trade;', link: 'http://gap.us.playstation.com'},	
	{title: 'Prodigio RTS', description: 'Prodigio RTS offers a cutting<br>edge approach to equity &amp; futures trading', link: 'http://www.prodigiorts.net'},
	{title: 'Inner-Fire', description: 'Web-based school administration tools that allow students, teachers, administrators and parents to easily work with school data', link: 'http://www.inner-fire.com'},
	{title: 'MyEnergyAdvizor.com', description: 'Online utilities that allow you to get energy saving tips as well as track your utility bills and see more savings', link: 'http://www.myenergyadvizor.com'},
	{title: 'Ovation Benefits', description: 'Health Screening Registration - Online dynamic registration tool that allows employees to register for health screening', link: 'http://www.ovationbenefits.com'}, 
	{title: 'VRSim', description: 'VRSim creates virtual reality training tools that<br>help teach industrial trades and manufacturing skills', link: 'http://www.vrsim.net'},
	{title: 'Hydrogen Safety, LLC', description: 'Hydrogen Safety is a group of interdisciplinary specialists in risk management, insurability, applications engineering, safety, training, and project management to solve the real-world puzzle of commercializing the Hydrogen and Alternative Energy infrastructure', link: 'http://www.hydrogensafety.com/'}, 
	
	{title: 'Centritec Seals, LLC', description: 'With an increased focus on energy efficiency and environmental sensitivities by industries globally, the patented Centritec Seal&trade; for bearings is well positioned as a rather simple improvement to realize these goals', link: 'http://www.centritecseals.com'},	
	{title: '10orNot.com', description: '"<i>At 10orNot.com you get to compare people and be compared based purely on looks. Yes! It\'s superficial but it\'s also really fun!</i>"', link: 'http://www.10ornot.com'},	
	{title: 'Connecticut Business Incubator Network', description: '"<i>Hatching new businesses throughout the state</i>"', link: 'http://www.connecticutincubators.org'},		
	{title: 'CCAT Public Site', description: 'The public relations site for the<br>Connecticut Center for Advanced Technology, Inc.', link: 'http://www.ccat.us'},
	{title: 'CCAT Internal Portal', description: 'The Connecticut Center for Advanced Technology, Inc. internal portal tools, web apps and programs', link: 'http://portal.ccat.us'},	
	{title: 'ShowMeThat', description: 'ShowMeThat is an online gospel music and<br>DVD store to help musicians improve their techniques', link: 'http://www.showmethat.com'},	
	{title: 'Pip Bloomfield', description: 'Photographic art by Pip Bloomfield, Santa Monica CA', link: 'http://www.pipbloomfield.com'}
];


/*
Pre-load image functions
*/
function preloadBaseImages() {
	var imageArray = new Array('progress_dots.gif', 'btn/new_window_active.gif');

    preloadImages(imageArray, '/images/');	
}


function preloadImages(imageArray, dirPrefix) {
	for(i = 0; i < imageArray.length; i++) {
		var imageName = new Image();
        imageName.src = dirPrefix + imageArray[i];
	}
}


/*
Replaces text with by in string
*/
function replace(string, text, by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


/*
Make sure the specified string is numeric
*/
function IsNumeric(strString) {
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;

	if (strString.length == 0) return false;

	for (i = 0; i < strString.length && blnResult == true; i++) {
    	strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
      	}
	}
	
	return blnResult;
}


/*
Trim a string from leading and trailing spaces
*/
function Trim(iString) {
  iString = iString.replace( /^\s+/g, "" );
  return iString.replace( /\s+$/g, "" );
}


/*
Find an object on the page
*/
function findObj(objName) {
	var theObj = document.getElementById(objName);
	
	if (!theObj) {
		//theObj = document.all[objName];
	}
	
	return theObj;
}


/*
Find an object that is contained within an object
*/
function findContainedObj(objName, objContainer) {
	var theObj = objContainer.elements[objName];
	
	if ((!theObj) && (objContainer.all)) {
		theObj = objContainer.all[objName];
	}
	
	// If no object found, search through layers
	if ((!theObj) && (objContainer.getElementsByTagName)) {
		var tmpObj = objContainer.getElementsByTagName("div");
		for (var i = 0; i < tmpObj.length; i++) {
			if ((tmpObj[i].name == objName) || (tmpObj[i].id == objName)) {
				theObj = tmpObj[i];
			}
		}
	}
	
	// If we still haven't found the object, look for table cells
	if ((!theObj) && (objContainer.getElementsByTagName)) {
		var tmpObj = objContainer.getElementsByTagName("td");		
		for (var i = 0; i < tmpObj.length; i++) {
			if ((tmpObj[i].name == objName) || (tmpObj[i].id == objName)) {
				theObj = tmpObj[i];
			}
		}
	}
		
	// If we still haven't found the object, look for spans
	if ((!theObj) && (objContainer.getElementsByTagName)) {
		var tmpObj = objContainer.getElementsByTagName("span");		
		for (var i = 0; i < tmpObj.length; i++) {
			if ((tmpObj[i].name == objName) || (tmpObj[i].id == objName)) {
				theObj = tmpObj[i];
			}
		}
	}	

	// If we still haven't found the object, look for tables
	if ((!theObj) && (objContainer.getElementsByTagName)) {
		var tmpObj = objContainer.getElementsByTagName("table");		
		for (var i = 0; i < tmpObj.length; i++) {
			if ((tmpObj[i].name == objName) || (tmpObj[i].id == objName)) {
				theObj = tmpObj[i];
			}
		}
	}
	
	return theObj;	
}


/*
Reload the current window after a set time
*/
function reloadWindowTimeout() {
	setTimeout('window.location.reload();', 250);
}


/*
Redirect the current window after a set time
*/
function redirectWindowTimeout(iLocation) {
	setTimeout('window.location.href=\'' + iLocation + '\'', 250);
}


/*

*/
function initMain(iHeight) {
	$('#containerDiv').slideshow({
		delay: 500,
		width: 590,
		height: iHeight,
		onchange: function(iIndex) {
			$('#bottomLink').find('span').removeClass('active');
			$('#bottomLink').find('span:eq(' + (iIndex - 1) + ')').addClass('active');
		}
	});
	
	$('.subcontainerDiv').show();
	$('#containerDiv').slideshow('force_draw');		
}


/*

*/
function initPortfolio() {
	$('#portfolioDiv').slideshow({
		delay: 500,
		width: 240,
		height: 180,
		type: 'verticle',
		onchange: function(iIndex) {
			var tmpDetails = portfolioDetails[iIndex - 1];
			$('#moreInfoCell').html('<a href="' + tmpDetails.link + '" target="_blank" class="newWindowLink"><b>' + tmpDetails.title + '</b></a><br>' + tmpDetails.description);
		}
	});
	
	$('#portfolioDiv').find('div').show();
	$('.portfolioThumb:not(:first)').addClass('portfolioThumbInactive');
	$('.portfolioThumb:first').removeClass('portfolioThumbInactive');
	
	$('.portfolioThumb').bind('mouseenter', function() {
		$('.portfolioThumb').addClass('portfolioThumbInactive');		
		$('#portfolioDiv').slideshow('jumpto', $('.portfolioThumb').index(this));
		$(this).removeClass('portfolioThumbInactive');
	});
	
	$('#portfolioDiv').slideshow('first');
}


/*
Contact info has been submitted
*/
function contactConfirmed() {
	$('#name_row').hide();
	$('#email_address_row').hide();
	$('#message_row').hide();
	$('#updateBtn').hide();
	
	$('#updateMsg').html('Thank you for submitting your contact info. Someone from Smithwick Design will respond shortly.');
}
