
/*var host = 'http://10.1.10.63';
//var host = 'http://localhost';
var homeDir = 'http://10.1.10.63/convene/www/';*/
$(document).ready(function() {
	
	/*** Set up nav ***/
	//$('.nav_item').css('text-indent', '-9000em');
	
	$('.nav_item').hover(function() {	
		//$(this).css('background-position', '0px 0px');
		$(this).css('background-position', '0px 0px');
	}, function() {
		$(this).css('background-position', '0px 36px');
	});
	
	//set currently select background
	var sel_top = 0;
	
	if($('.nav_item.selected').attr('order')) {
		sel_top = $('.nav_item.selected').attr('order') * 37;
	}
	
	$('#nav').css('background-position', '0px -' + sel_top + 'px');
	//$('#nav').css('background-position', '0px -0px');
	
	/* link forwarding for nav item */
	$('.nav_item').click(function() {
		//window.location = host + $(this).find('a').attr('href');
		window.location = host + $(this).attr('rel');
	});
	
	/*** Set up field focus and blur actions ***/
	$('.txt').click(function() {

		if($(this).val() == $(this).attr('default'))
			$(this).val('');
	});
	
	$('.txt').blur(function() {
		if($(this).val() == '')
			$(this).val($(this).attr('default'));				
	});

	
	$('.validateform').validate({
		errorLabelContainer: "#messageBox",
		wrapper: "li"
	});
	
	/** for brief events **/
	$('#brief_states').change(function() {
		
		var option = $(this).find('option:selected');
		
		$("#event_options").empty();
		$("#event_options").append('<div align="center"><img src="' + homeDir + 'img/loading.gif" alt="loading..." /></div>');
		
		$('#event_options').load(homeDir + 'events/briefitems/city/' + escape($(option).val()), null, function(data){});
	});
	
	/** For selecting 'other' as country */
	
     $('#country').change(function() {
		
		var option = $(this).find('option:selected');
		
		
		var html = '<span id="other_country"><input type="text" name="OTHER_COUNTRY" class="txt" tabindex="10"/><input type="hidden" id="pretty_OTHER_COUNTRY" name="pretty_OTHER_COUNTRY" value="Other Country"><input type="hidden" value="OTHER_COUNTRY" name="DuplicateChecking6" id="DuplicateChecking6"></span>';
		if($(option).val() == 'other') 
			$('#other_country').show();
		else
			$('#other_country').hide();
		
	});

});


/** Helper function to pad leading 0's in seconds */
function padding(n, totalDigits) { 
    n = n.toString(); 
    var pd = ''; 
    if (totalDigits > n.length) { 
        for (i=0; i < (totalDigits-n.length); i++) { 
            pd += '0'; 
        } 
    } 
    return pd + n.toString(); 
} 



