// JavaScript Document
jQuery(document).ready(function() {
	$("#accordion").accordion({
		autoHeight: false,
		event: "mouseover"
	});
	// select #flowplanes and make it scrollable. use circular and navigator plugins
		/*$("#flowpanesVideo").scrollable({ circular: true }).navigator({
			// select #flowtabs to be used as navigator
			navi: "#flowtabs",
			// select A tags inside the navigator to work as items (not direct children)
			naviItem: 'a',
			// assign "current" class name for the active A tag inside navigator
			activeClass: 'current',
			// make browser's back button work
			history: true
		}).autoscroll({
			interval: 3000
		});*/
		flowplayer(
			"flowpanesVideo", 
			HOSTURL+"static/flash/flowplayer-3.1.5.swf", 
			"http://static.ezeego1.co.in/ezeego1/images/hotelimages/ezvideos/destination/final.mp4"
		);
		$("#flowpanesPhoto").scrollable({ circular: true }).navigator({
			// select #flowtabs to be used as navigator
			navi: "#flowtabsphoto",
			// select A tags inside the navigator to work as items (not direct children)
			naviItem: 'a',
			// assign "current" class name for the active A tag inside navigator
			activeClass: 'current',
			// make browser's back button work
			history: true
		}).autoscroll({
			interval: 3000
		});
	
	$("#destination_within_outside").val('within');
	/**
	Form Loader when ajax is called for populating any fields
	*/
	 jQuery('#fadeOutFormOverlay').ajaxStart(function() {
	 
						if ($.browser.msie) {
							jQuery('#overlayForm').bgiframe({top:0, left:0});					
						 }
						  jQuery('#overlayForm').addClass('overlayForm').fadeTo('fast', 0.5).css('display', 'block').css('height', jQuery(this).height()+"px").css('width', jQuery(this).width()+"px");
							 jQuery('#loadingCalenderOverlay').removeClass('loadingCalenderHide').addClass('loadingCalender');
	});	
	
					 jQuery('#fadeOutFormOverlay').ajaxStop(function() {				    
						jQuery('#overlayForm').css('height', 0+"px").css('width', 0+"px").removeClass('overlayForm').fadeTo('fast', 0.5).css('display', 'none');
						  jQuery('#loadingCalenderOverlay').removeClass('loadingCalender').addClass('loadingCalenderHide'); 
						//  jQuery('#fadeOutCalenderOverlay').unbind('ajaxStart');			
	 });
					
	//End of loader functionality
	
	//Intializing Google map
	initialize();
});


function validate_video_submit(){
	var errstring = '';
	var str = '';
	
	if(document.getElementById("select_destination").value=="" || document.getElementById("select_destination").value==" ")
	{
		errstring +="<li>Please select your favourite Destination</li>";
	}else{
		str+="<input name='city' value='"+document.getElementById("select_destination").value+"' type='hidden'>";
	}		

	if(errstring == ''){
		document.searchvideodestination.innerHTML= str;
		jQuery("#searchvideodestination").append(jQuery("#productForm").html());
		document.searchvideodestination.submit();
	}
	if (errstring != ''){
		jQuery.facebox('<div style="width:400px;"><div class="floatr" style="margin:5px 5px 0 0; width:100px; "><a href="javascript:;" class="colorgrey bold text11 closeicon" style="text-decoration:none;float:right;" onclick="$(document).trigger(\'close.facebox\');" ></a>&nbsp;</div><div class="clear"><div class="error-page-alert"><span class="ezee">ezee</span><span class="alert">alert</span><br/><div class="alertimg padl20">&nbsp;</div></div><div class="error-page-main_content"><div class="error_content"><ul class="error_content">'+errstring+'</ul></div></div><div class="clear">&nbsp;</div></div></div>');
		return false
	}else return true;
}

function set_within_outside(jtype){
	if(jtype == 'within'){
		$("#destination_within_outside").val('within');
		$("#within").addClass('selectedjtype');
		$("#outside").removeClass('selectedjtype');
	}else{
		$("#destination_within_outside").val('outside');
		$("#within").removeClass('selectedjtype');
		$("#outside").addClass('selectedjtype');
	}
	show_box_car();
}

function show_box_car(){
	var out_in = $("#destination_within_outside").val();
	out_in = jQuery.trim(out_in);
	
	switch(out_in){
		case 'within':
			$('#destination_search_outside').hide();
			$('#destination_search_within').show();
		break;
		
		case 'outside':
			$('#destination_search_within').hide();
			$('#destination_search_outside').show();
		break;		
	}
}

function submit_page_validated(){
	var out_in = $("#destination_within_outside").val();
	out_in = jQuery.trim(out_in);
	
	switch(out_in){
		case 'within':
			validate_submit('within');
		break;
		
		case 'outside':
			validate_submit('outside');
		break;		
	}
}

function setcityOutside(city){
	if(city == ''){
		city = '';
	}
	x = jQuery("#outside_country").val();
	if(x == 'India'){
		setcityIndia(city);
	}else{
		setcityInt(x, city);
	}
}

function setcityIndia(city){
	var url = HOSTURL+"destination/index.php";
	jQuery.ajax({
	  type: "get",
	  url: url,
	  data: "action=cityIndia",
	  success: function(msg){
		jQuery("#outside_city").html("");
		jQuery("#outside_city").append(msg);
		if(city != ''){
			jQuery("#outside_city").val(city);
		}
	  }
	});	
}

function setcityInt(x, city){
	var url = HOSTURL+"destination/index.php";
	jQuery.ajax({
	  type: "get",
	  url: url,
	  data: "action=cityInt&country="+x,
	  success: function(msg){
		jQuery("#outside_city").html("");
		jQuery("#outside_city").append(msg);
		if(city != ''){
			jQuery("#outside_city").val(city);
		}
	  }
	});	
}

function setwithincity(obj){
	x = $(obj).val();
	$("#within_city").val(x);
}

function setoutsidecity(country, obj){
	jQuery("#outside_country").val(country);
	city = $(obj).val();
	setcityOutside(city);
}

function validate_submit(appen){
	var errstring = '';
	var str = '';
	
	if(document.getElementById(appen+"_country").value=="" || document.getElementById(appen+"_country").value==" ")
	{
		errstring +="<li>Please select destination Country</li>";
	}else{
		str+="<input name='country' value='"+document.getElementById(appen+"_country").value+"' type='hidden'>";
	}		
	if(document.getElementById(appen+"_city").value=="" || document.getElementById(appen+"_city").value==" ")
	{
		errstring +="<li>Please select destination City</li>";
	}else{
		str+="<input name='city' value='"+document.getElementById(appen+"_city").value+"' type='hidden'>";
	}		

	if(errstring == ''){
		document.searchdestination.innerHTML= str;
		jQuery("#searchdestination").append(jQuery("#productForm").html());
		document.searchdestination.submit();
	}
	if (errstring != ''){
		jQuery.facebox('<div style="width:400px;"><div class="floatr" style="margin:5px 5px 0 0; width:100px; "><a href="javascript:;" class="colorgrey bold text11 closeicon" style="text-decoration:none;float:right;" onclick="$(document).trigger(\'close.facebox\');" ></a>&nbsp;</div><div class="clear"><div class="error-page-alert"><span class="ezee">ezee</span><span class="alert">alert</span><br/><div class="alertimg padl20">&nbsp;</div></div><div class="error-page-main_content"><div class="error_content"><ul class="error_content">'+errstring+'</ul></div></div><div class="clear">&nbsp;</div></div></div>');
		return false
	}else return true;
}

function validate_video_submit(){
	var errstring = '';
	var str = '';
	
	if(document.getElementById("select_destination").value=="" || document.getElementById("select_destination").value==" ")
	{
		errstring +="<li>Please select your favourite Destination</li>";
	}else{
		str+="<input name='city' value='"+document.getElementById("select_destination").value+"' type='hidden'>";
	}		

	if(errstring == ''){
		document.searchvideodestination.innerHTML= str;
		jQuery("#searchvideodestination").append(jQuery("#productForm").html());
		document.searchvideodestination.submit();
	}
	if (errstring != ''){
		jQuery.facebox('<div style="width:400px;"><div class="floatr" style="margin:5px 5px 0 0; width:100px; "><a href="javascript:;" class="colorgrey bold text11 closeicon" style="text-decoration:none;float:right;" onclick="$(document).trigger(\'close.facebox\');" ></a>&nbsp;</div><div class="clear"><div class="error-page-alert"><span class="ezee">ezee</span><span class="alert">alert</span><br/><div class="alertimg padl20">&nbsp;</div></div><div class="error-page-main_content"><div class="error_content"><ul class="error_content">'+errstring+'</ul></div></div><div class="clear">&nbsp;</div></div></div>');
		return false
	}else return true;
}

//Code for Google Map
var map;
var markersArray = [];
var cities = [  ['Aberdeen', 45.4646985, -98.4864829, '1_I'],  ['Adelaide', -34.9257700, 138.5997320, '2_I'],  ['Aix En Provence', 43.5249088, 5.4541444, '8_I'],  ['Albuquerque', 35.0844909, -106.6511367, '9_I'],  ['Alicante', 38.3452032, -0.4810060, '10_I'],  ['Amsterdam', 52.3738007, 4.8909347, '11_I'],  ['Antwerp', 51.2205806, 4.3997224, '12_I'],  ['Athens', 37.9791800, 23.7166470, '13_I'],  ['Atlanta', 33.7489954, -84.3879824, '14_I'],  ['Auckland', -36.8473850, 174.7657350, '15_I'],  ['Avignon', 43.9486126, 4.8059666, '3_I'],  ['Baltimore', 39.2903848, -76.6121893, '16_I'],  ['Bangkok', 13.7234186, 100.4762319, '17_I'],  ['Barcelona', 41.3879170, 2.1699187, '18_I'],  ['Bath', 51.3814282, -2.3574537, '19_I'],  ['Beijing', 39.9046670, 116.4081980, '20_I'],  ['Bergen', 60.3880719, 5.3318512, '21_I'],  ['Berlin', 52.5234051, 13.4113999, '6_I'],  ['Bilbao', 43.2569629, -2.9234409, '22_I'],  ['Bologna', 44.4942191, 11.3464815, '23_I'],  ['Boston', 42.3584308, -71.0597732, '24_I'],  ['Bratislava', 48.1483765, 17.1073105, '25_I'],  ['Brighton', 50.8195220, -0.1364200, '26_I'],  ['Brisbane', -27.4675800, 153.0278920, '27_I'],  ['Bruges', 51.2094345, 3.2252377, '28_I'],  ['Brussels', 50.8462807, 4.3547273, '29_I'],  ['Bucharest', 44.4325000, 26.1038889, '30_I'],  ['Budapest', 47.4984056, 19.0407578, '31_I'],  ['Buenos Aires', -34.6084175, -58.3731613, '4_I'],  ['Cairns', -16.9253970, 145.7751780, '32_I'],  ['Cairo', 30.0647420, 31.2495090, '33_I'],  ['Calgary', 51.0450000, -114.0572222, '34_I'],  ['Cancun', 21.1589640, -86.8459370, '35_I'],  ['Cannes', 43.5508939, 7.0105410, '36_I'],  ['Cape Town', -33.9237762, 18.4233455, '37_I'],  ['Cardiff', 51.4813069, -3.1804979, '38_I'],  ['Chicago', 41.8500330, -87.6500523, '39_I'],  ['Christchurch', -43.5316370, 172.6366450, '40_I'],  ['Cleveland', 41.4994954, -81.6954088, '41_I'],  ['Cologne', 50.9406645, 6.9599115, '42_I'],  ['Colombo', 6.9274680, 79.8483580, '43_I'],  ['Copenhagen', 55.6762944, 12.5681157, '44_I'],  ['Cork', 51.8978655, -8.4710941, '45_I'],  ['Cracow', 50.0646501, 19.9449799, '46_I'],  ['Dallas', 32.8029550, -96.7699230, '47_I'],  ['Darwin', -12.4613340, 130.8419040, '48_I'],  ['Denver', 39.7391536, -104.9847034, '49_I'],  ['Detroit', 42.3314270, -83.0457538, '50_I'],  ['Doha', 25.2802820, 51.5224760, '51_I'],  ['Dubai', 25.2500000, 55.3000000, '52_I'],  ['Dublin', 53.3441040, -6.2674937, '53_I'],  ['Dubrovnik', 42.6418783, 18.1064811, '54_I'],  ['Edinburgh', 55.9501755, -3.1875359, '55_I'],  ['Florence', 43.7687324, 11.2569013, '7_I'],  ['Frankfurt', 50.1115118, 8.6805059, '56_I'],  ['Geneva', 46.2038099, 6.1399589, '57_I'],  ['Glasgow', 55.8656274, -4.2572227, '58_I'],  ['Hamburg', 53.5538148, 9.9915752, '59_I'],  ['Hanoi', 21.0558567, 105.8290298, '60_I'],  ['Hanover', 52.3720683, 9.7356861, '61_I'],  ['Havana', 23.1333333, -82.3833333, '62_I'],  ['Helsinki', 60.1698125, 24.9382401, '63_I'],  ['Ho Chi Minh City', 10.7822222, 106.6772222, '64_I'],  ['Hong Kong', 22.4060834, 114.1201536, '65_I'],  ['Honolulu', 21.3069444, -157.8583333, '66_I'],  ['Houston', 29.7628844, -95.3830615, '67_I'],  ['Istanbul', 41.0052700, 28.9769600, '68_I'],  ['Jerusalem', 31.7857000, 35.2007000, '69_I'],  ['Johannesburg', -26.2014520, 28.0454880, '5_I'],  ['Kathmandu', 27.7028710, 85.3182440, '70_I'],  ['Kuala Lumpur', 3.1390030, 101.6868550, '71_I'],  ['La Paz', -16.4990100, -68.1462480, '72_I'],  ['Las Vegas', 36.1146460, -115.1728160, '73_I'],  ['Lille', 50.6371834, 3.0630174, '74_I'],  ['Lima', 40.7425510, -84.1052256, '75_I'],  ['Lisbon', 38.7070538, -9.1354884, '76_I'],  ['Liverpool', 53.4107766, -2.9778383, '77_I'],  ['Ljubljana', 46.0514263, 14.5059655, '78_I'],  ['London', 51.5001524, -0.1262362, '79_I'],  ['Los Angeles', 34.0522342, -118.2436849, '80_I'],  ['Lyon', 45.7672990, 4.8343287, '81_I'],  ['Madrid', 40.4166909, -3.7003454, '82_I'],  ['Manchester', 53.4807125, -2.2343765, '83_I'],  ['Manila', 34.9701050, -110.4104830, '84_I'],  ['Marrakech', 31.6313210, -8.0124780, '85_I'],  ['Marseille', 43.2976116, 5.3810421, '86_I'],  ['Melbourne', -37.8142510, 144.9631690, '87_I'],  ['Memphis', 35.1495343, -90.0489801, '88_I'],  ['Mexico City', 19.4270499, -99.1275711, '89_I'],  ['Miami', 25.7742657, -80.1936589, '90_I'],  ['Milan', 45.4636889, 9.1881408, '91_I'],  ['Minneapolis-st Paul', 44.9799654, -93.2638361, '92_I'],  ['Monte Carlo', 43.7404387, 7.4255775, '93_I'],  ['Montreal', 45.5088670, -73.5542420, '94_I'],  ['Moscow', 55.7557860, 37.6176330, '95_I'],  ['Munich', 48.1391265, 11.5801863, '96_I'],  ['Nashville', 36.1658899, -86.7844432, '97_I'],  ['New Orleans', 29.9647222, -90.0705556, '98_I'],  ['New York', 40.7142691, -74.0059729, '99_I'],  ['Newcastle', 54.9778404, -1.6129165, '100_I'],  ['Nice', 43.7034273, 7.2662656, '101_I'],  ['Orlando', 28.5383355, -81.3792365, '102_I'],  ['Oslo', 59.9138204, 10.7387413, '103_I'],  ['Palermo', 38.1156193, 13.3613758, '104_I'],  ['Palma', -10.7743717, 40.4745459, '105_I'],  ['Paris', 48.8566667, 2.3509871, '106_I'],  ['Perth', -31.9554000, 115.8585900, '107_I'],  ['Philadelphia', 39.9523350, -75.1637890, '108_I'],  ['Phnom Penh', 11.5500000, 104.9166667, '109_I'],  ['Prague', 50.0878114, 14.4204598, '110_I'],  ['Quebec City', 46.8020710, -71.2449260, '111_I'],  ['Queenstown', -31.8970103, 26.8734437, '112_I'],  ['Quito', -0.2294980, -78.5242770, '113_I'],  ['Reykjavik', 64.1353380, -21.8952100, '114_I'],  ['Riga', 56.9465363, 24.1048503, '115_I'],  ['Rio De Janerio', -22.9035393, -43.2095869, '116_I'],  ['Rome', 34.2570380, -85.1646726, '117_I'],  ['Salt Lake City', 40.7607793, -111.8910474, '118_I'],  ['Salzburg', 47.8004990, 13.0444100, '119_I'],  ['San Diego', 32.7153292, -117.1572551, '120_I'],  ['San Francisco', 37.7749295, -122.4194155, '121_I'],  ['Santa Fe', 35.6869752, -105.9377990, '122_I'],  ['Santiago', -33.4253598, -70.5664659, '124_I'],  ['Santiago De Compostela', 42.8804471, -8.5463034, '123_I'],  ['Seattle', 47.6062095, -122.3320708, '125_I'],  ['Seoul', 37.5665350, 126.9779692, '126_I'],  ['Seville', 37.3826400, -5.9962951, '127_I'],  ['Shanghai', 31.2307080, 121.4729160, '128_I'],  ['Siena', 43.3186614, 11.3305135, '129_I'],  ['Singapore', 1.2894066, 103.8499619, '130_I'],  ['Sofia', 42.6976262, 23.3222839, '131_I'],  ['Southampton', 50.9049660, -1.4032340, '132_I'],  ['Split', 43.5069058, 16.4424496, '133_I'],  ['St Petersburg', 59.9390390, 30.3157850, '134_I'],  ['Stockholm', 59.3327881, 18.0644881, '135_I'],  ['Strasbourg', 48.5829331, 7.7437488, '136_I'],  ['Sydney', -33.8671390, 151.2071140, '137_I'],  ['Taipei', 25.0910750, 121.5598345, '138_I'],  ['Tallinn', 59.4388619, 24.7544715, '139_I'],  ['Tel Aviv', 32.0554000, 34.7595000, '140_I'],  ['Tokyo', 35.6894875, 139.6917064, '141_I'],  ['Toronto', 43.6525000, -79.3816667, '142_I'],  ['Tripoli', 34.4333333, 35.8500000, '143_I'],  ['Turin', 45.0705621, 7.6866186, '144_I'],  ['Valencia', 10.1810000, -68.0040000, '145_I'],  ['Valetta', 35.8977778, 14.5125000, '146_I'],  ['Vancouver', 49.2485230, -123.1088000, '147_I'],  ['Venice', 45.4343363, 12.3387844, '148_I'],  ['Vienna', 48.2092062, 16.3727778, '149_I'],  ['Vilnius', 54.6893865, 25.2800243, '150_I'],  ['Warsaw', 52.2296756, 21.0122287, '151_I'],  ['Washington Dc', 38.8951118, -77.0363658, '152_I'],  ['Wellington', -41.2864800, 174.7762170, '153_I'],  ['York', 39.9625984, -76.7277450, '154_I'],  ['Zagreb', 45.8070790, 15.9643900, '155_I'],  ['Zurich', 47.3690239, 8.5380326, '156_I'], ['Agartala', 23.8333490, 91.2788550, '149_D'],  ['Agra', 27.1900000, 78.0100000, '2_D'],  ['Ahmedabad', 23.0395740, 72.5660200, '3_D'],  ['Ajmer', 26.4538889, 74.6388889, '150_D'],  ['Alibaug', 18.6554910, 72.8679200, '151_D'],  ['Alleppy', 9.4900000, 76.3300000, '104_D'],  ['Almora', 29.6017850, 79.6544430, '152_D'],  ['Alwar', 27.5618000, 76.6087420, '153_D'],  ['Amritsar', 31.6308900, 74.8715520, '1_D'],  ['Andaman', 11.9675605, 92.6983868, '27_D'],  ['Arunachal Pradesh', 28.2390993, 94.0695454, '29_D'],  ['Assam', 26.2006043, 92.9375739, '30_D'],  ['Auli', 30.5481021, 79.5571679, '154_D'],  ['Aurangabad', 19.8853000, 75.3196560, '105_D'],  ['Badami', 15.9149400, 75.6768110, '155_D'],  ['Badrinath', 30.7412230, 79.4929220, '113_D'],  ['Bandhavgarh', 23.6126714, 80.3869629, '110_D'],  ['Bandipur', 11.7667417, 76.4331698, '156_D'],  ['Bangalore', 12.9716060, 77.5943760, '4_D'],  ['Bharatpur', 27.2155990, 77.4901500, '157_D'],  ['Bhavnagar', 21.7702778, 72.1430556, '158_D'],  ['Bhopal', 23.2475000, 77.4158333, '25_D'],  ['Bhubaneswar', 20.2955710, 85.8527070, '5_D'],  ['Bikaner', 28.0166667, 73.3333333, '114_D'],  ['Chandigarh', 30.7313450, 76.7753850, '9_D'],  ['Chennai (ex Madras)', 13.0604160, 80.2496340, '7_D'],  ['Corbett National Park', 29.5333330, 78.9352780, '127_D'],  ['Cuttack', 20.4640000, 85.8793000, '119_D'],  ['Darjeeling', 27.0392530, 88.2634940, '123_D'],  ['Delhi', 28.6353080, 77.2249600, '12_D'],  ['Dwarka', 28.5901605, 77.0506896, '128_D'],  ['Gangtok', 27.3333000, 88.6167000, '129_D'],  ['Goa', 15.4253792, 73.9830029, '15_D'],  ['Gondal', 21.9611800, 70.8034520, '120_D'],  ['Haridwar', 29.9641840, 78.1745150, '130_D'],  ['Hassan', 13.0072000, 76.0945430, '131_D'],  ['Hyderabad', 17.3850440, 78.4866710, '18_D'],  ['Jaipur', 26.9261111, 75.8088889, '20_D'],  ['Jaisalmer', 26.9133333, 70.9138889, '132_D'],  ['Jhansi', 25.4485450, 78.5697130, '133_D'],  ['Jodhpur', 26.2805556, 73.0158333, '134_D'],  ['Kanha', 21.8077411, 80.6217957, '121_D'],  ['Kedarnath', 30.7333330, 79.0666670, '122_D'],  ['Khajuraho', 24.8423210, 79.9246300, '23_D'],  ['Kochi', 9.9392480, 76.2596250, '21_D'],  ['Kodagu', 12.3374942, 75.8069082, '118_D'],  ['Kolkata (ex Calcutta)', 22.4887534, 88.3624678, '22_D'],  ['Kovalam', 8.4009230, 76.9788300, '117_D'],  ['Kumarakom', 9.5833333, 76.4333333, '116_D'],  ['Kumbakonam', 10.9586600, 79.3819270, '115_D'],  ['Kurnool', 15.8222222, 78.0350000, '165_D'],  ['Kushinagar', 26.7404427, 83.8883810, '166_D'],  ['Lachung', 27.6166667, 88.6500000, '112_D'],  ['Lakshwadeep', , , '31_D'],  ['Leh', 34.1453227, 77.5676735, '103_D'],  ['Lonavala', 18.7480556, 73.4072222, '161_D'],  ['Lucknow', 26.8513200, 80.9168030, '6_D'],  ['Ludhiana', 30.9022222, 75.8547222, '162_D'],  ['Madurai', 9.9159970, 78.1218470, '147_D'],  ['Mahabaleshwar', 17.9216400, 73.6556320, '163_D'],  ['Mahabalipuram', 12.6166667, 80.1916667, '146_D'],  ['Manali', 32.2400000, 77.1885000, '33_D'],  ['Manipur', 24.6637173, 93.9062688, '34_D'],  ['Mashobra', 31.1266018, 77.2383599, '145_D'],  ['Matheran', 18.9800000, 73.2700000, '164_D'],  ['Meghalaya', 25.4670308, 91.3662160, '35_D'],  ['Mizoram', 23.1645430, 92.9375739, '36_D'],  ['Mount Abu', 24.5925000, 72.7155556, '144_D'],  ['Mumbai', 19.0176560, 72.8561780, '8_D'],  ['Munnar', 10.0846670, 77.0614930, '111_D'],  ['Mussoorie', 30.4500000, 78.0800000, '143_D'],  ['Mysore', 12.3035340, 76.6461100, '142_D'],  ['Nagaland', 26.1584354, 94.5624426, '38_D'],  ['Nagarhole', 12.0416805, 76.1319953, '126_D'],  ['Nagpur', 21.1538889, 79.0830556, '159_D'],  ['Nainital', 29.3929710, 79.4540510, '141_D'],  ['Narendra Nagar', 21.1046221, 79.0772159, '140_D'],  ['Nashik', 20.0013889, 73.7916667, '160_D'],  ['Ooty', 11.4118280, 76.6953560, '139_D'],  ['Pachmarhi', 22.4683400, 78.4322130, '138_D'],  ['Pahalgam', 34.0555120, 75.2958180, '167_D'],  ['Panchgani', 17.9203700, 73.7938540, '168_D'],  ['Parwanoo', 30.8380600, 76.9585000, '169_D'],  ['Patna', 25.6125000, 85.1283333, '10_D'],  ['Patnitop', , , '170_D'],  ['Pondicherry', 11.9349520, 79.8281210, '11_D'],  ['Port Blair', 11.6670870, 92.7454130, '137_D'],  ['Pune', 18.5204690, 73.8566210, '13_D'],  ['Raipur', 21.2428030, 81.6387080, '136_D'],  ['Rajkot', 22.2969090, 70.7983630, '135_D'],  ['Ranthambore', 26.0177941, 76.4863443, '125_D'],  ['Sasan', 21.1697567, 70.4275704, '124_D'],  ['Siddapur', 16.4551818, 75.2843627, '106_D'],  ['Sikkim', 27.7306273, 88.6337840, '39_D'],  ['Simla', 31.1000000, 77.1700000, '14_D'],  ['Somnath', 20.8880300, 70.4013030, '107_D'],  ['Srinagar', 34.0827800, 74.8084920, '24_D'],  ['Thekkady', 9.5330000, 77.2000000, '108_D'],  ['Thiruvananthapuram (ex Trivandrum', 8.4930222, 76.9425130, '16_D'],  ['Tirupati', 13.6500000, 79.4166667, '109_D'],  ['Tripura', 23.9408482, 91.9881527, '40_D'],  ['Udaipur', 24.5712700, 73.6915440, '17_D'],  ['Uttaranchal', 30.0667530, 79.0192997, '41_D'],  ['Varanasi', 25.3097220, 82.9886110, '19_D']];

function initialize() {
	var myOptions = {
	  zoom: 1,
	  center: new google.maps.LatLng(41.8954656, 12.4823243),
	  navigationControl: true,
	  mapTypeControl: false,
	  scaleControl: false,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	google.maps.event.addListener(map, 'zoom_changed', function() {
		zoomLevel = map.getZoom();
		if (zoomLevel < 4) {
		  clearOverlays();
		}else{
		  showOverlays();
		} 
		if (zoomLevel > 8) {
		  map.setZoom(8);
		}      
	});

	setMarkers(map, cities);
	clearOverlays();
}

function setMarkers(map, locations) {
  for (var i = 0; i < locations.length; i++) {
    var city = locations[i];
    var myLatLng = new google.maps.LatLng(city[1], city[2]);
	var checkie6 = false;

	if(jQuery.browser.msie){
		if(parseInt(jQuery.browser.version) < 7){
		  checkie6 = true;
		}
	}
	if(checkie6 == false){
		addMarker(myLatLng, city[0], city[3]);	
	}else{
		addMarkerie6(myLatLng, city[0], city[3]);	
	}
  }
}

function addMarker(latlong, cityname, citycode) {
  var image = new google.maps.MarkerImage(STATICURL+'/images/destination/gmap_icon.gif',
      new google.maps.Size(36, 41),
      new google.maps.Point(0,0),
      new google.maps.Point(13, 41));
  var shadow = new google.maps.MarkerImage(STATICURL+'/images/destination/gmap_icon_shadow.gif',
      new google.maps.Size(36, 41),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 41));
  var shape = {
      coord: [12,37,14,36,14,33,16,33,24,16,24,9,19,3,17,2,9,2,2,10,2,17,11,33,11,37,12,37],
      type: 'poly'
  };
  marker = new google.maps.Marker({
    position: latlong,
    map: map,
	title:cityname,
    shadow: shadow,
	icon: image,
	shape: shape
  });
  markersArray.push(marker);
  // Add a listener for the click event
  google.maps.event.addListener(marker, 'click', function() {
	gmapsubmitdest(citycode);
  });
}

function addMarkerie6(latlong, cityname, citycode) {
  marker = new google.maps.Marker({
	position: latlong,
	map: map,
	title:cityname
  });
  markersArray.push(marker);
  // Add a listener for the click event
  google.maps.event.addListener(marker, 'click', function() {
	gmapsubmitdest(citycode);
  });
}

// Removes the overlays from the map, but keeps them in the array
function clearOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
  }
}

// Shows any overlays currently in the array
function showOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(map);
    }
  }
}

// Deletes all markers in the array by removing references to them
function deleteOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
    markersArray.length = 0;
  }
}

function gmapsubmitdest(citycode){
	var str ="<input name='city' value='"+citycode+"' type='hidden'>";
	document.searchdestination.innerHTML= str;
	jQuery("#searchdestination").append(jQuery("#productForm").html());
	document.searchdestination.submit();
}
