$(document).ready(function() {
	switchLabels();
	accordionActions();
});

function switchLabels() {    
    $(".Searchbox fieldset input:text").each(function(e) { 
        DefaultValue = $(this).attr('title');
        if($(this).val() == '')
		{
		    $(this).val(DefaultValue);
		}
    });
      
    $(".Searchbox fieldset input:text").blur(function(e) { 
        DefaultValue = $(this).attr('title');
        if($(this).val() == '')
		{
		    $(this).val(DefaultValue);
		}
    });
    
    $(".Searchbox fieldset input:text").focus(function(e) { 
        DefaultValue = $(this).attr('title');
        if($(this).val() == DefaultValue) $(this).val('');
    });
            
    $("#.Searchbox fieldset input:submit").click(function(e) { 
        RemoveWaterMark();
    });
}

function RemoveWaterMark() {    
    $(".Searchbox fieldset input:text").each(function(e) { 
        DefaultValue = $(this).attr('title');
        if($(this).val() == DefaultValue)
		{
		    $(this).val('');
		}
    });
}



//Handles the slide movement of accordion elements
function accordionActions() {
	$('.accordion .content').not('.first').hide();
	$('.accordion .title').click(function() {
		$(this).siblings('.content').slideDown();
		$(this).parents('.accordion').children('.section').children('.content').not($(this).siblings('.content')).slideUp();
	});
}

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}


function ReplaceQueryString(queryString, key, value)
{   
    if(queryString == "" || queryString == null || queryString == "undifined") return "";
    
    key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
    var qs = regex.exec(queryString);
    if(qs == null)
    {
        if(value != "") return queryString + "&" + key + "=" + value; else return queryString;
    }
    else
    {
        if(value != "" || value > -1)
        {
            return queryString.replace(key + "=" + qs[1], key + "=" + value);
        }
        else
        {
            queryString = queryString.replace(key + "=" + qs[1], "");
            if(queryString.substr(queryString.length - 1, 1) == "&") queryString = queryString.substr(0, queryString.length - 1);
            queryString = queryString.replace("&&", "&");            
            queryString = queryString.replace("?&", "?");
            
            return queryString.replace(key + "=" + qs[1], "");
        }
    }
}

function GetValueFromQueryString(queryString, key)
{    
    key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
    var qs = regex.exec(queryString);
    if(qs == null)
    {
        return "";
    }
    else
    {        
        return qs[1];
    }
}

function isNumber(field) {
    var re = /^[0-9-'.'-',']*$/; 
    if (!re.test(field.value)) field.value = field.value.replace(/[^0-9-'.'-',']/g,"");
}  







         
function D2( val ) {
return ( ( val * 1 < 10 ) ? '0' : '' ) + ( val * 1 )
}

function separate( val ) {
val = D2( val );
return val.substr( 0, 1 ) + '&nbsp;&nbsp;&nbsp;' + val.substr( 1 );
}

/*
 Count down until any date script-
 By JavaScript Kit (www.javascriptkit.com)
 Over 200+ free scripts here!
*/

//change the text below to reflect your own,
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown( yr, m, d ) {
    
    var today  = new Date();
    var todayy = today.getFullYear();
    var todaym = today.getMonth();
    var todayd = today.getDate();
    var todaystring  = montharray[ todaym ] + " " + todayd + ", " + todayy
    var futurestring = montharray[ m - 1 ] + " " + d + ", " + yr
    var difference   = ( Math.round( ( Date.parse( futurestring ) - Date.parse( todaystring ) ) / ( 24*60*60*1000 ) ) * 1 );
    if ( difference == 0 )
      document.write( current )
    else
        if ( difference > 0 )
        {
            $("#time").html(separate(difference));
        }     
}
// enter the count down date using the format year/month/day