var currNav = ''; // Set current nav id

// Replace a text field with a value
function replaceValue(target, defaultText, newValue)
{
	if (target.value == defaultText) target.value = newValue;
}

// Set top and sometimes left nav
function setNav(topNav, sideNav)
{
	currNav = topNav;
	if (document.getElementById(topNav)) {
		document.getElementById(topNav).className = 'selected';
	}

	if (sideNav != undefined)
	{
		if (document.getElementById(sideNav)) {
			document.getElementById(sideNav).className = 'selected';
		}
	}
}

// Profile props
function slideSwitch() {
  $.each($('.slideshow'), function() {
    var $active = $('img.active', this);

    if ( $active.length == 0 ) $active = $('img:last', this);

    var $next =  $active.next().length ? $active.next()
        : $('img:first', this);

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
  });
}

function nextProp()
{
  var maxBack = (totalProps-1) * -280;
  if (parseInt($('#allPropsSlider').css('left')) > maxBack)
  {
    $('#allPropsSlider').animate({left: '-=280'}, 500, 'swing');
  }
}
function lastProp()
{
  if (parseInt($('#allPropsSlider').css('left')) < 0)
  {
    $('#allPropsSlider').animate({left: '+=280'}, 500, 'swing');
  }
}

// Everybody`s friend, the Dreamweaver Image Preloader
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// Popup window - give me the url, width, and height, and I'll give you a popup
function popUp(url, x, y)
{
	if (isIE() == true)
	{
		y += 40;
	}
    var args = "resizable=1,width=" + x + ",height=" + y;
    var date = new Date();
    var now = date.getTime();
    var newName = (now).toString(10);

    window.open(url,newName,args);
}


/*** Form checking functions ***/
function checkField (val, field)
{
    var error = "";
    if (val == "")
    {
      error = "You must enter a value in the " + field + " field.\n";
    }
    return error;
}
function checkEmail(val, field)
{
    var error = "";
    if ((val == "" || val.length < 3) ||
        (val.indexOf("@") == "-1") ||
        (val.indexOf(".") == "-1"))
    {
        error = "Please enter a valid " + field + " address.\n";
    }

    return error;
}

// For popup thing
function isIE()
{
	//Detect IE5.5+
	version=0;
	if (navigator.appVersion.indexOf("MSIE")!=-1) {
		temp=navigator.appVersion.split("MSIE");
		version=parseFloat(temp[1]);
	}
	if (version >= 5.5)
	{ //NON IE browser will return 0
		return true;
	} else {
		return false;
	}
}

function showDiv(target)
{
	document.getElementById(target).style.display = 'block';
}
function hideDiv(target)
{
	document.getElementById(target).style.display = 'none';
}

