function detectWWW(rootURL){
	var currentURL = location.href;
	return 	__detectWWW(currentURL, rootURL);
}

function __detectWWW(currentURL, rootURL){
	if (currentURL.indexOf('//www.') == -1) {
		if (rootURL.indexOf('//www.') == -1) {
			return rootURL;
		} else {
            return rootURL.replace('//www.', '//'); 
		}
	} else {
		if (rootURL.indexOf('www.') == -1) {
			return rootURL.replace('//', '//www.'); 			
		} else {
			return rootURL;
		}
	}
}

function checkGooglemapAddress(otherCityName){
	var url = 'http://maps.google.com/maps?q=';
	var ids = ['address1', 'address2', 'country', 'city_country', 'state', 'postcode'];
	
	var value = '';
	for (var i = 0; i < ids.length; i++) {
		value = document.getElementById(ids[i]).value;				
		if (document.getElementById(ids[i]).value !== '') {
			if (value == otherCityName){
				value = document.getElementById('other_city_value').value;
			}		
			url += value + ' ';
		}
	}
	
	window.open(url);
}