// Thomas Bennett 12.09.2009

jQuery(document).ready(function(){
	$('#hero').cycle({ 
		fx:     'fade', 
		prev:   '.previousArrow', 
		next:   '.nextArrow',
		speed:    800,
		timeout: 6000
	});
});

jQuery(document).ready(function(){
	$('.txtSearch').autofill({
		value: 'Search',
		defaultTextColor: '#000',
		activeTextColor: '#000'
	});
});

jQuery(document).ready(function(){
	$('a.zoom').fancybox({ 'hideOnContentClick': false });
	$('#accordion').accordion();
});
 
jQuery(document).ready(function(){  
	$('#first').hover(function(){ 
		$(this).find("img").attr("src","/images/new/shop_hover.jpg");  
		}, function() {  
		$(this).find("img").attr("src","/images/new/shop.jpg");  
	});  
	$("#second").hover(function() {  
		$(this).find("img").attr("src","/images/new/map_hover.jpg");  
		}, function() {  
		$(this).find("img").attr("src","/images/new/map.jpg");  
	});
	$("#third").hover(function() {  
		$(this).find("img").attr("src","/images/new/icons_hover.jpg");  
		}, function() {  
		$(this).find("img").attr("src","/images/new/icons.jpg");
	});
});  

jQuery(document).ready(function(){
	$('.productBox').livequery('click', function(){
		var id = $(this).attr('id');
		$.ajax({
			type: 'post',
			url:  'products/'+id+'.php',
			success: function(data){
				$('#second_nav_info').html(data);
			//	$('a.zoom').fancybox();
			}
		})
	});
	$('#infoTabs ul li#new').addClass('activeTab');
	$('.tabLink').livequery('click', function(){
		var id = $(this).attr('id');
		$.ajax({
			type: 'post',
			url: 'products/'+id+'.php',
			success: function(data){
				$('#second_nav_info').html(data);
			}
		})
	});
});

jQuery(document).ready(function(){
	setInterval("checkAnchor()", 300);
});

var currentAnchor = null;
//Function which chek if there are anchor changes, if there are, sends the ajax petition
function checkAnchor(){
	//Check if it has changes
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		//if there is not anchor, the loads the default section
		if(!currentAnchor)
			query = "products/new.php";
		else
		{
			//Creates the  string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2
			var splits = currentAnchor.substring(1).split('&');
			//Get the section
			var section = splits[0];
			delete splits[0];
			//Create the params string
			var params = splits.join('&');
			var query = section + '.php';
		}

		//Send the petition
		$("#loading").show();
		$.get(query, function(data){
		$("#second_nav_info").html(data);
		$("#loading").hide();
		});
	}
}

//DEALERS PAGE STUFF
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
//document.onmousedown = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
var state = '<?=$row[0]?>';

// Main function to retrieve mouse x-y pos.s
function receivedFromFlash (txt) {
	state=txt.toUpperCase();
    openmypage();
	return;
}



