var currentHash;
var searchTimer;
var ie	= false;
var ie6	= false;
var pageTracker	= 0;
var firstSearch	= true;

	$(document).ready(function(){
		
		if( jQuery.browser.msie ){	
			ie	= true;
			if( Math.round(jQuery.browser.version) < 7 ){
				ie6	= true;
			} else {
				
			}
		}
		
		$('img[@src$=.png]').pngfix();
		$('#header .search .searchText').pngfix();
			
	});
	
	function search(){
		
		if( ( $.trim($('#header .search .searchText').val()) != "" ) && ( $.trim($('#header .search .searchText').val()).length > 3 ) ){
			
			$('#header .search .searchButton').hide();
			$('#header .search .searchLoad').show();
			
					$.ajax({
						type: "POST",
						url: "/search.php",
						data: "customer=" + customer + "&category=" + publication + "&view=" + volume + "&str=" + encodeURIComponent($('#header .search .searchText').val()),
						success: searchSuccess
					});
		} else {
			
			searchAlert('Debe ingresar al menos 4 caracteres ');
			
		}
				
	}
	
	function searchAlert(msg){
		
		$('#search .searchAlert')
			.html(msg)
			.fadeIn(1500,function(){
				
				 searchTimer	= setTimeout('clearSearchAlert()', 5000);
				
			});
		
	}
	
	function clearSearchAlert(){
		
		$('#search .searchAlert')
			.fadeOut(1500,function(){
				
				$(this).html('');
				clearTimeout(searchTimer);
				
			});
		
	}
	
	function checkHash(){
		
		if(location.hash != currentHash){
			currentHash	= location.hash;
			return true;
		} else {
			return false;
		}
		
	}
	
	function TrackAction(path,onlyHash){
		
		if(!ie6){ location.hash	= path; }
		currentHash		= location.hash;
		
		if(!onlyHash){
			path = "/" + publication + "/" + volume + path;
			
			if( custom == 0 ){ path = "/" + customer + path; }
			
			if(pageTracker != 0){ pageTracker._trackPageview(path); }
		}
		
	}
	
	function onlyTrack(path){
		
		path = "/" + publication + "/" + volume + path;
			
		if( custom == 0 ){ path = "/" + customer + path; }
			
		if(pageTracker){ pageTracker._trackPageview(path); }
		
	}
	
	function changePage(action,page){
		document.getElementById('flash').extChange(action,page);
	}