$(document).ready(function() {	


// Rep finder area map

var $regions_multiple = $('#region_1,#region_2,#region_3,#region_4,#region_5,#region_6,#region_7,#region_8,#region_9,#region_10');
var showText='See all sales reps in the US';
var hideText='Hide all sales reps in the US';

$('a.module-rep-expand').append( showText);

//$regions_multiple.hide();

$('a.module-rep-expand').click(function() {
	
	if($(this).html() == showText){	
		$regions_multiple.show();
		$.each($('a.module-rep-expand'), function(){
			$(this).html($(this).html()==hideText ? showText : hideText);																   
		});
	
	}
	else{
		$regions_multiple.hide();
		$.each($('a.module-rep-expand'), function(){
			$(this).html($(this).html()==showText ? hideText : showText);																   
		});
	}
	return false;
});

$('area.region_1').click(function(){	
	$regions_multiple.hide();
	$('#region_1').show();
	return false;
});

$('area.region_2').click(function(){	
	$regions_multiple.hide();
	$('#region_2').show();
	return false;
});

$('area.region_3').click(function(){	
	$regions_multiple.hide();
	$('#region_3').show();
	return false;
});

$('area.region_4').click(function(){
	$regions_multiple.hide();
	$('#region_4').show();
	return false;
});

$('area.region_5').click(function(){	
	$regions_multiple.hide();
	$('#region_5').show();
	return false;
});

$('area.region_6').click(function(){	
	$regions_multiple.hide();
	$('#region_6').show();
	return false;
});

$('area.region_7').click(function(){	
	$regions_multiple.hide();
	$('#region_7').show();
	return false;
});

$('area.region_8').click(function(){							  
	$regions_multiple.hide();
	$('#region_8').show();
	return false;
});

$('area.region_9').click(function(){	
	$regions_multiple.hide();
	$('#region_9').show();
	return false;
});

$('area.region_10').click(function(){	
	$regions_multiple.hide();
	$('#region_10').show();
	return false;
});
//input Mask

$.mask.definitions['~']='[+-]';
$('#date').mask('99/99/9999');


// product content module
$('#content > div').hide();
  $('#menu a').click(function() {
    var $this = $(this);
    var hash = $this.attr('href');
    $(hash).siblings(':visible').hide();
    $(hash).slideDown('fast');
    $('#menu li').removeClass('active');
    $this.parent('li').addClass('active');
    return false;
  });
  $('#content > div.show').show();
  
  // quick finder tabs module
  
$(function () {
	var tabContainers = $('div#quick-find > div.body');
	
	$('div#quick-find div.tabs a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$('div#quick-find div.tabs a').removeClass('active');
		$(this).addClass('active');
		return false;
	});

	$('#menu li:first').addClass('active');
});

});


function gotoCountrySelection(currentselection) {
//takes user to selected country
}

var quicklinks_array = new Array('#', '#', 'http://bettervm.basf.us/markets/markets-landing-page.html', 'http://bettervm.basf.us/contactUs.html', '#', '#', 'http://www.betterplants.com', 'http://www.pestcontrolfacts.org', 'http://www.betterturf.com', 'http://agproducts.basf.us', '#', 'http://www.agro.basf.com', 'http://www.basf.us', 'http://www.basfpublichealth.com/', 'http://bettervm.basf.us/safety-resources.html', 'http://www.pesweb.info/?mysite=BASF', 'http://www.webfulfillment.com/theAlanCo/Basf/', 'http://bettervm.basf.us/products/index-labels-and-msdss.html', 'https://agpro.basf.us/');
function gotoLocation(location) {
	document.location.href = location;
}
function gotoQuickLinks(currselection) {
	if ((currselection.value  == 0) || 
		(currselection.value  == 1) || 
		(currselection.value  == 4) || 
		(currselection.value  == 5) || 
		(currselection.value  == 10)) {
		
		//Do nothing for now
	} else {
		gotoLocation(quicklinks_array[currselection.value]);
	}




}


function redirect(){
	var homepage = "http://bettervm.basf.us/";
	var currenturl = location.href;

	if( currenturl.lastIndexOf(homepage) < 0){
		var newurl = currenturl.substring(7);
		newurl = newurl.replace(newurl.substring(0, newurl.indexOf("/")+1), "");
		
		window.location = homepage + newurl;
	}

}