
function supportsSVG() {     return !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect;   }

function supportsVml() {     
	if (typeof supportsVml.supported == "undefined") {         
		var a = document.body.appendChild(document.createElement('div'));         
		a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';         
		var b = a.firstChild;         
		b.style.behavior = "url(#default#VML)";         
		supportsVml.supported = b ? typeof b.adj == "object": true;         
		a.parentNode.removeChild(a);     
	}     
	
	return supportsVml.supported 
} 

var colors = {};
var cc, event;
colors['au'] = '#B80060';
colors['fr'] = '#B80060';
colors['nz'] = '#006F3D';
colors['us'] = '#B80060';
colors['es'] = '#006F3D';
colors['cl'] = '#006F3D';
colors['ar'] = '#B80060';
colors['za'] = '#B80060';
colors['it'] = '#B80060';
colors['de'] = '#006F3D';

$(document).ready(function () {
  if ($('#vmap').length > 0) {
	if (supportsVml() || supportsSVG()){
		$('#vmap').vectorMap({
		  colors: colors,
		  hoverOpacity: 0.7,
		  hoverColor: false,
		onLabelShow: function (event, label, cc) {
		switch (cc) {
			  case 'au': case 'nz': case 'cl': case 'ar': case 'za': case 'fr': case 'it': case 'es': case 'de':
		  break;
		  case 'us':
		  $(label).text("California");
		  break;
			  default:
			//prevent label showing
		  event.preventDefault();
		  //display alternate label
		  //$(label).text("Rest of World");
				break;
		}
		},
		onRegionOver: function (event, cc) {
		switch (cc) {
			  case 'au': case 'nz': case 'us': case 'cl': case 'ar': case 'za': case 'fr': case 'it': case 'es': case 'de':
		  break;
			  default:
			//prevent hover colour appearing
		  event.preventDefault();
				break;
		}
		},
		  onRegionClick: function (event, cc) {
			switch (cc) {
			  case 'au':
				window.location = '/Australia-6197.html';
				break;
			  case 'nz':
				window.location = '/New%20Zealand-6196.html';
				break;
			  case 'us':
				window.location = '/California-6198.html';
				break;
			  case 'cl':
				window.location = '/Chile-6199.html';
				break;
			  case 'ar':
				window.location = '/Argentina-6200.html';
				break;
			  case 'za':
				window.location = '/South-Africa-6195.html';
				break;
			  case 'fr':
				window.location = '/France-6410.html';
				break;
			  case 'it':
				window.location = '/Italy-6411.html';
				break;
			  case 'es':
				window.location = '/Spain-6412.html';
				break;
			  case 'de':
				window.location = '/Germany-6194.html';
				break;
			  default:
				//window.location = '/Rest-Of-World-6413.html';
				break;
			} 
		  }
		});
	}
	else {
		$('#vmap').css("display","none");
		$('#vmaplinktext').text = "Click on the links below for more information on our World of Wines ...";
	}
  }
});
