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, addressLanguagConstant, tip){
	var url = 'http://code.google.com/apis/maps/documentation/examples/geocoding-simple.html';	  
	var ids = ['address1', 'address2', 'postcode', 'city_country', 'state', 'country'];
	
	var value = [];
	for (var i = 0; i < ids.length; i++) {									
		if (document.getElementById(ids[i]).value !== '' && document.getElementById(ids[i]).value != 0) {						
			if (document.getElementById(ids[i]).value == otherCityName){
				value.push(document.getElementById('other_city_value').value);
			} else {
				value.push(document.getElementById(ids[i]).value);		
			}					
		}
	}	
	
	if( window.clipboardData && clipboardData.setData ){
		clipboardData.setData("Text", value);
	}
	
	alert(addressLanguagConstant + ': ' + value.join(', ') + '\n' +  tip );
	window.open(url);
}
