// Set default done loading status
var DONE_LOADING = false;

//Need to set a variable so we can pass the part number to the dealer finder
var part_number = "";
/*
 * This function will populate the drop downs base on the current data
 * */
function populate_list(self) {
}


//This function looks at the drop down and reloads the page with the url
function reload_dd_page(self) {
	window.location.href = $(self).val();
}


function popup(box, partno) {
	$(".dealer_finder_links").hide();
	part_number = partno;
	if(!DONE_LOADING) { 
		$(".dealer_link").fancybox({ 
		'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'imageScale':false, 'centerOnScroll':false ,
		'frameHeight':310 , 
		'frameWidth':400, 
		'hideOnContentClick' : false
		});
	
		//These are for the authorized dealer popups
		$(".msrp_link").fancybox({ 
		'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'imageScale':false, 'centerOnScroll':false ,
		'frameHeight':140 , 
		'frameWidth':400, 
		'hideOnContentClick' : false
		});
		
		//These are for the 2010 NAMM Flickr Photos popups
		$(".namm2010_flickr").fancybox({ 
		'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'imageScale':false, 'centerOnScroll':false ,
		'frameHeight':650 , 
		'frameWidth':850, 
		'hideOnContentClick' : false
		});
		
		$(".dealer_link").trigger('click');
	}

	return false;
}

/*
 * This function controls the dealer
 * */
function dealer_popup() {

}

/*
 * This function takes you to the appropriate dealer finder for the selected region 
 * */
function select_dealer_region(self) {
	$select = $(self);
	region = $select.val();
	if (region == "us") {
		$(".dealer_finder_links a").attr("href", $(".dealer_finder_links a").attr("href").replace(/product=[0-9]+/, 'product='+part_number));
		$(".dealer_finder_links").show();
	}
	else {
		if (region == "it") {
			window.location = "http://www.fender.it/dealerfinder"
		}
		else if (region == "uk") {
			window.location = "http://www.fender.co.uk/dealerfinder"
		}
		else if (region == "se") {
			window.location = "http://www.fender.se/dealerfinder"
		}
		else if (region == "de") {
			window.location = "http://www.fender.de/dealerfinder"
		}
		else if (region == "fr") {
			window.location = "http://www.fender.fr/dealerfinder"
		}
		else if (region == "es") {
			window.location = "http://www.fender.es/dealerfinder"
		}
		else if (region == "mx") {
			window.location = "http://www.fender.mx/dealerfinder"
		}
		else if (region == "za") {
			window.location = "http://www.fender.co.za/dealerfinder"
		}
		else if (region == "sk") {
			window.location = "http://www.fender.sk/dealerfinder"
		}
		
	}
}

//Setup the fancy box features
$(document).ready(function() {
	//These are for the authorized dealer popups
	$(".dealer_link").fancybox({ 
	'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'imageScale':false, 'centerOnScroll':false ,
	'frameHeight':310 , 
	'frameWidth':400, 
	'hideOnContentClick' : false
	});

	//These are for the authorized dealer popups
	$(".msrp_link").fancybox({ 
	'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'imageScale':false, 'centerOnScroll':false ,
	'frameHeight':140 , 
	'frameWidth':400, 
	'hideOnContentClick' : false
	});
	
	//These are for the 2010 NAMM Flickr Photos popups
	$(".namm2010_flickr").fancybox({ 
	'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'imageScale':false, 'centerOnScroll':false ,
	'frameHeight':650 , 
	'frameWidth':850, 
	'hideOnContentClick' : false
	});

	// Set done loading status to true
	DONE_LOADING = true;
});