function check_form_entries()
{

if(document.reg_form.newusername.value=="")
{
alert('Please enter a username');
return false;
}
else if(document.reg_form.newpassword.value=="")
{
alert('Please enter a password');
return false;
}
else if(document.reg_form.newpassword.value.length<6)
{
alert('Password must be at least 6 characters long');
return false;
}
else if(document.reg_form.newpassword2.value=="")
{
alert('Please confirm the password you entered');
return false;
}
else if(document.reg_form.newpassword.value!=document.reg_form.newpassword2.value)
{
alert('The password you entered a second time does not match the password you entered the first time');
return false;
}
else if(isEmail(document.reg_form.newemail.value)==false)
{
alert('Please enter a valid email address');
return false;
}
else if(document.reg_form.city.value=="")
{
alert('Please enter your city');
return false;
}
else if(document.reg_form.register_country.value==" ")
{
alert('Please choose your country');
return false;
}
else if(verify_username(document.reg_form.newusername.value)==false)
{
alert('The username'+document.reg_form.newusername.value+' is already taken...');
return false;
}

}


function verify_login_form()
{
if(document.login_form.username.value=="")
{
alert('Please enter a username and password to login');
return false;
}
else if(document.login_form.password.value=="")
{
alert('Please enter a username and password to login');
return false;
}
}


function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
 var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}



function get_directions(id)
{
toggle(id);

}


function print(id)
{
toggle(id);

}

function review(id)
{
if(readCookie('username')==null || readCookie('password')==null)
{
alert('Please login to review this entry...');
}
else
{
toggle(id);
}
}

function bookmark(id)
{
if(readCookie('username')==null || readCookie('password')==null)
{
alert('Please login to bookmark this entry...');
}
else
{
toggle(id);
}
}

function claim(id,category)
{
if(readCookie('username')==null || readCookie('password')==null)
{
alert('Please login to claim this entry...');
}
else
{
window.open('http://www.rockle.com/yap/claim?id='+id+'&category='+category,'claim')
}
}

function toggle(id)
{

if (document.getElementById(id).style.display == "none")
{
	document.getElementById(id).style.display = "";
}
else
{
	document.getElementById(id).style.display = "none";
}


}


     function createMarker(point,address) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {   
        getHTML(address,marker);                 
        });
        return marker;
        }

function find_geo_add_marker(address,map)
{
var geocoder = new GClientGeocoder();
geocoder.getLatLng(address,
function(point){
if (point)
{
map.setCenter(point,8);
var marker = createMarker(point,address);
map.addOverlay(marker);
}
}
);

}



function load_direction_map(from,to)
{
 if (GBrowserIsCompatible()) { 
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(49.496675,-102.65625), 2);
directionsPanel = document.getElementById("directions");
directions = new GDirections(map, directionsPanel);
directions.load(from + " to " + to);
}    
    //   display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
}




function readCookie(name) { 
var nameEQ = name + "="; 
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i]; 
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null; 
}




function load_map(address,id)
{
toggle('map_'+id);
toggle('close_map_'+id);
 if (GBrowserIsCompatible()) { 
var map = new GMap2(document.getElementById('map_'+id));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
find_geo_add_marker(address,map);
}    
    //   display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
}