// prevent cross browser event bubbling

/* error catch
try{ 
  allert( 'this is a code example' ); 
} 
catch( exceptionObject ) { 
  var errorString = ''; 
  for( i in exceptionObject ) { 
    errorString += i + ':' + exceptionObject[i] + '\n'; 
  } 
  alert( errorString );
}
*/

//  alert(navigator.userAgent);
  /*
if (navigator.userAgent.indexOf("Firefox")!=-1){
//	document.write("<link rel='stylesheet' href='css1/wd33FF.css' media='screen' type='text/css'>")//Firefox
}else
if (navigator.userAgent.indexOf("MSIE")!=-1){
	//document.write("<link rel='stylesheet' href='css1/wd33IE.css' media='screen' type='text/css'>")//IE
	alert("Under Development for Internet Explorer - Better viewed in Firefox or Safari");
}else
if (navigator.userAgent.indexOf("Opera")!=-1){
	document.write("<link rel='stylesheet' href='css1/wd33FF.css' media='screen' type='text/css'>")//Firefox//Opera
}else
if (navigator.userAgent.indexOf("Mozilla")!=-1){
	document.write("<link rel='stylesheet' href='css1/wd33FF.css' media='screen' type='text/css'>")//Mozilla Safari
}
*/
var sUserAgent = navigator.userAgent;
var fAppVersion = parseFloat(navigator.appVersion);

//
$(document).ready(function(){
	
	var arrowSlide = function(){
		console.log('in');
		$('#tabNavJSArrow')
		.animate({
			left: '0',
			opacity:'100'
			}, '1000');
	};
		
		$('#one, #two, #three').hover(function(){
			arrowSlide;
			}, 
			function(){
				console.log('out')
				})
				//.unbind('mouseover mouseout');

	
	var timesClicked = 0;

	$('#topTabPullDown').click(function() {//Show/hide top panel
		$('#tabTop')
		//.css('display','block')
		.slideToggle('1900', function() {
		// Animation complete.
		});
	return false;
	});
				   	   			   
	
	/*
	$('#two').hover(function(){
		$('#tabNavJSArrow')
		.animate({
			left: '204px',
			opacity:100 }, '1000' ,
			function(){});
	},function(){
		$('#tabNavJSArrow')
		.animate({opacity:0});
		});//Empty function to prevent handler error in firebug for hover event
	
	$('#three').hover(function(){
		$('#tabNavJSArrow')
		.animate({
			left: '408px',
			opacity:100 }, '1000' ,
			function(){});
	},function(){
		$('#tabNavJSArrow')
		.animate({opacity:0});
		});//Empty function to prevent handler error in firebug for hover event
	
	*/
	//HIDE UNCHOSEN LOGOS
	$('.tabNav ul li').click(function(){
				
		var sClikAttr = $(this).attr('id');	
		var pLeftMarker = 0;
		
		if(pLeftMarker == 0){
		//	console.log('inbinded');
		//	$('#tabNavJSArrow').css('position', 'relative').css('height', 'auto').css('float', 'none');
		//	$('#one', '#two', '#three').unbind('hover');
		}
	
		$('.logoCommentBox').show();//Show comment box.
		$("input[name='logo']").val(sClikAttr);
		$('.tabNav ul li').each(function(){
			
			if (this.id != sClikAttr) $(this).hide();
			if (this.id == sClikAttr) $(this).addClass('whiteBg');
			$(this).removeClass('tranBg');
			$('.selectText p').html('You have chosen logo ' + sClikAttr + '. Please fill in your details or change your selection by clicking the red cross.');
	//JSON styles
	//		if (this.id == sClikAttr) $(this).css({'background-color':'#fff' , 'border-right' : '1px solid #000' , 'padding-right' : '5px;'});
	//		$(".sth").css( {'color' : '#f00', 'font-style' : 'italic', 'text-decoration' : 'underline'} );
			
		});
		
	})
	
	//Handle buttons
	$("input[type='reset']").click(function(){
		
		var sIntroChoice = 'Make your selection from the 3 logos. Once you have made your choice you will need to confirm your action.';
		
		$('.tabNav ul li').show().addClass('tranBg');
		$('.logoCommentBox').hide();
		$('.selectText p').html(sIntroChoice);
	//	$('#tabNavJSArrow').css('position', 'static');
	});
	
	//Validate form prior to sending to server
	$("form").validate({
		rules:{
			name:"required",
			email:"required"
		}
	});
	
	
	

	
//	$('.tabNav ul li').each(function(){}).click(function(){
//		var sClikAttr = $(this).attr('id');
//		console.log(sClikAttr);						
//	});
	
//	$.each(map, function(key, value) { 
// 		alert(key + ': ' + value); 
//	});
	
});
