// M+H JS FILE

$(function() {
	var countryLocations = {
		initialSelection: 'UK',
		'New York' :  {
			locationName: 'Lattimer USA',
			locationAdd: '3603 North Mill Road, Vineland, NJ 08360, USA',
			locationTel: '+1 856 691 2203',
			locationFax: '+1 856 691 5509',
			locationContact: 'Mr J Pearson',
			locationEmail: 'salesamericas@lattimer.com'
		},
		'South America' : {
			locationName: 'SA - Lattimer USA',
			locationAdd: '3603 North Mill Road, Vineland, NJ 08360, USA',
			locationTel: '+1 856 691 2203',
			locationFax: '+1 856 691 5509',
			locationContact: 'Mr J Pearson',
			locationEmail: 'salesamericas@lattimer.com'
		},
		'South Africa':{
			locationName: 'Lattimer UK',
			locationAdd: '79-83 Shakespeare Street, Southport,<br /> Merseyside, England, PR8 5AP',
			locationTel: '+44 (0) 1704 535040',
			locationFax: '+44 (0) 1704 541046',
			locationEmail: 'sales@lattimer.com'
		},
		'Saudi Arabia' : {
			locationName: 'Lattimer UK',
			locationAdd: '79-83 Shakespeare Street, Southport,<br /> Merseyside, England, PR8 5AP',
			locationTel: '+44 (0) 1704 535040',
			locationFax: '+44 (0) 1704 541046',
			locationEmail: 'sales@lattimer.com'
		},
		'Egypt' : {
			locationName: 'ESW',
			locationAdd: '12 Sayed Abd El Wahed St, Flat 57 Heliopolis, Cario, Egypt',
			locationTel: '+2 0222561217',
			locationFax: '+2 0222592054',
			locationEmail: 'w.shafei@esw-eg.com'
		},
		'Turkey':{
			locationName: 'Hanci Glass',
			locationAdd: 'Beyaz Villa Sok, Uzuner Kutay Apt No 15, Daire 18,<br />P.K.34862, Kartal-Istanbul, Turkey',
			locationTel: '+90 2163890716',
			locationFax: '+90 2163067624',
			locationEmail: 'info@hanciglass.com'
		},
		'Spain':{
			locationName: 'Crisa',
			locationAdd: 'Av. Bon Pastor, 08930 Sant Adria de Besos, Barcelona, Spain',
			locationTel: '+34 933 812 112',
			locationFax: '+34 955 867 776',
			locationContact: 'Paco Espinar',
			locationEmail: 'crisa.espinar@gmail.com'
		},
		'Germany': {
			locationName: 'Raddon GmbH',
			locationAdd: 'Cheruskerstrasse 23, D-10829 Berlin, Germany',
			locationTel: '+49 307 809 770',
			locationFax: '+49 307 809 7715',
			locationContact: 'Alexander Raddon',
			locationEmail: 'info@raddon.de'
		},
		'Italy': {
			locationName: 'GLA.MO.RO srl',
			locationAdd: 'Via. G. Acerbi 8/1,16148 Genova,ITALIA',
			locationTel: '+39 010 37 42 161',
			locationFax: '+39 010 37 40 189',
			locationEmail: 'info@glamoro.it'
		},
		'France': {
			locationName: 'Rondot S.A.S',
			locationAdd: "BP 55, 69410 Champagne au Mont d'Or, France",
			locationTel: '+33 472 52 0860',
			locationFax: '+33 478 474 866',
			locationContact: 'Stephane Rossignol',
			locationEmail: 'sales@rondot-sa.com'
		},
		'UK': {
			locationName: 'Lattimer UK',
			locationAdd: '79-83 Shakespeare Street, Southport,<br /> Merseyside, England, PR8 5AP',
			locationTel: '+44 (0) 1704 535040',
			locationFax: '+44 (0) 1704 541046',
			locationEmail: 'sales@lattimer.com'
		},
		'Ukraine':{
			locationName: 'Evgeniy Rovenko',
			locationAdd: 'Ukraine',
			locationTel: 	'+38 095 27 444 34',
			locationFax: '',
			locationEmail: 'lattimer@meta.ua'
		},
		'Russia': {
			locationName: 'Lattimer USA',
			locationAdd: '3603 North Mill Road, Vineland, NJ 08360, USA',
			locationTel: '+1 856 691 2203',
			locationFax: '+1 856 691 5509',
			locationContact: 'Mr J Pearson',
			locationEmail: 'salesamericas@lattimer.com'
		},
		'India & Sri Lanka': {
			locationName: 'Ceracon Engineers PVT Ltd.',
			locationAdd: 'B - 1/75 Janakpuri, New Delhi, 110 058, India',
			locationTel: '+91 112 559 8468',
			locationFax: '+91 112 552 5397',
			locationContact: 'Mr. J Sarin',
			locationEmail: 'ceracon@vsnl.com'
		},
		'Korea': {
			locationName: 'Sungbong Industrial Corporation',
			locationAdd: 'Kangdong, P.O. Box 165 Seoul, Korea',
			locationTel: '+82 2487 5636',
			locationFax: '+82 2487 5838',
			locationContact: 'Gahk Hyun Kim',
			locationEmail: 'sungbong@hanafos.com'
		},
		'Tokyo' : {
			locationName: 'Taihei Boeki Co. Ltd.',
			locationAdd: '13-6 Nihonbashi, Muromachi 1-Chome, Tokyo 103, Japan',
			locationTel: '+81 332 704 825',
			locationFax: '+81 332 451 767',
			locationContact: 'Ryohei Izumi',
			locationEmail: 'tokyo@taiheiboeki.co.jp'
		},
		'Australia':{
			locationName: 'Tiger Chemical Company',
			locationAdd: '79-83 Munster Terrace, North Melbourne, Australia 3051',
			locationTel: '+61 3 9328 3099',
			locationFax: '+61 3 9328 3813',
			locationEmail: 'sales@tigerchem.com'
		},
		'Thailand': {
			locationName: 'GRT',
			locationAdd: '1213/336 Srivara Town in Town, Ladphrao 94 Rd, Wangthonglang, Bangkok, 10310, Thailand',
			locationTel: '+66 (0) 25309832',
			locationFax: '+66 (0) 25593720',
			locationContact: 'Asawin Wannopat',
			locationEmail: 'w_asawin@yahoo.com'
		},
		'Philippines': {
			locationName: 'Geobels Technologies Inc.',
			locationAdd: 'Unit No 2305, Le Mirage Tower,2126 A Mabini St,<br /> Malate, Manila, Philippines 1004',
			locationTel: '+63 25394319',
			locationFax: '+63 23136979',
			locationEmail: 'ivan@geobels.com'
		},
		'New Zealand': {
			locationName: 'Tiger Chemicals (NZ) Ltd',
			locationAdd: '3A St. Oswalds Rd,Greenlane, Auckland 1003',
			locationTel: '+64 9 634 7266',
			locationFax: '+64 9 634 0128',
			locationEmail: 'sales@tigerchem.com'
		},
		'Central & Latin America' :{
			locationName: 'Interglass S.A. de C.V',
			locationAdd: 'Plaza Empresarial Puerta De Hierro, Boulevard Puerta De Hierro,5200-16-B, CP 45110 Guadalajara, Jalisco, Mexico',
			locationTel: '+52 3656 2660',
			locationFax: '+52 3656 1301',
			locationContact: 'Roberto Iberri',
			locationEmail: 'sdiaz@interlub.com'
		}
	}
		
			
			
			$('li.headlink').hover(
				function() { $('ul', this).css('display', 'block'); },
				function() { $('ul', this).css('display', 'none'); }
			);
			
			//$("a.popupVid").fancybox();
			//append a script to the head if we're in the locations page
			
			$(function(){
				var H = 0;
				$(".equal").each(function(i){
					var h = $(".equal").eq(i).height();
					if(h > H) H = h;
				});
				$(".equal").height(H);
			});

				
		    if(window.location.search.match(/\?locations/)){
		    	
		    	$(".mapZone").hover(function(){
				var thisSelection = $(this).attr('alt');
				$("#rightinfo").children('h3').text(countryLocations[thisSelection].locationName);
				$(".locationAdd").html(countryLocations[thisSelection].locationAdd);
				$(".locationTel").text(countryLocations[thisSelection].locationTel);
				$(".locationFax").text(countryLocations[thisSelection].locationFax);
				$(".locationEmail").attr('href','mailto:'+countryLocations[thisSelection].locationEmail+'?subject=Lattimer Website Contact').text(countryLocations[thisSelection].locationEmail);
			},function(){
				var thisSelection = countryLocations[countryLocations.initialSelections];
				$("#rightinfo").children('h3').text(countryLocations[thisSelection].locationName);
				$(".locationAdd").html(countryLocations[thisSelection].locationAdd);
				$(".locationTel").text(countryLocations[thisSelection].locationTel);
				$(".locationFax").text(countryLocations[thisSelection].locationFax);
				$(".locationEmail").attr('href','mailto:'+countryLocations[thisSelection].locationEmail+'?subject=Lattimer Website Contact').text(countryLocations[thisSelection].locationEmail);
			});
			
			$(".mapZone").click(function(e){
				e.preventDefault();
				var thisSelection = $(this).attr('alt');
				$(".locationAdd").html(countryLocations[thisSelection].locationAdd);
				$(".locationTel").text(countryLocations[thisSelection].locationTel);
				$(".locationFax").text(countryLocations[thisSelection].locationFax);
				$(".locationEmail").attr('href','mailto:'+countryLocations[thisSelection].locationEmail+'?subject=Lattimer Website Contact').text(countryLocations[thisSelection].locationEmail);
			});
		    
		    
		    	function initialize() {
		    		var theLocation = window.location.href.replace(/(.+)\/locations\/(\w+)\.php$/i,"$2"),
		    		latlng,
		    		mapCenter = new google.maps.LatLng(53.705,-2.516);
		    		switch(theLocation){
		    			case 'southport':
		    					mapCenter = new google.maps.LatLng(53.705,-2.516); 
		    					latlng = new google.maps.LatLng(53.638,-3.004);
		    					contentString = '<h1>Lattimer UK</h1>';
		    					contentString += '<address>79-83 Shakespeare Street,<br />';
		    					contentString += 'Southport,</br />';
		    					contentString += 'Merseyside,</br />';
		    					contentString += 'England, PR8 5AP</br />';
		    					contentString += '</address><br />Tel <strong>+44 (0) 1704 535040</strong> Fax <strong>+44 (0) 1704 541046</strong>';
		    					break;
		    		}
    	    	    var myOptions = {
      	    	    	zoom: 9,
      	    	    	center: mapCenter,
      	    	    	mapTypeId: google.maps.MapTypeId.ROADMAP
    	    	    };
    	    	
    	    	    var map = new google.maps.Map(document.getElementById("locationbanner"),myOptions);
    	    	    
    	    	    var marker = new google.maps.Marker({
		 						position: latlng,
		 						animation: google.maps.Animation.DROP, 
		 			    		map: map, 
		 			    		title:"Hello World!"
		 					 });
					var infowindow = new google.maps.InfoWindow({
    					content: contentString
					});	
					
					google.maps.event.addListener(marker, 'click', function() {
  						infowindow.open(map,marker);
					});							 
  		    	}
  		    	
  		    	//initialize();
			}

});
