function photo_open_topic(link, width, height)
{
	var photoWindow = window.open(link,"photo",'scrollbars=no,resizable=no,width='+width+',height='+height);
}

function photo_open_image(link, width, height)
{
	var photoWindow = window.open(link,"photo",'scrollbars=no,resizable=no,width='+width+',height='+height);
}

function validate_password_form()
{
    x=document.register_entry;
	pass1Text = x.pass1.value;
	pass2Text = x.pass2.value;


	if(pass1Text.length < 4)
	{
		alert("Warning: Your password is too short.  \nPlease Enter 4 or more characters");
		x.pass1.value = "";
		x.pass2.value = "";
		return false;
	}
	if(pass1Text != pass2Text)
	{
		alert("Error: The two passwords do not match");
		x.pass1.value = "";
		x.pass2.value = "";
		return false;
	}

}

function validate_forum_register_form()
{
    x=document.register_entry;
	userText = x.user.value;
	emailText = x.email.value;

    // Is username blank
    if(userText.indexOf(" ") >= 0)
	{
		alert("Warning: Your user name cannot contain spaces");
		return false;
	}

    // Is username too short
	if(userText.length < 3)
	{
		alert("Warning: Your user name is too short.\n  Please choose a user name with more than 3 characters");
		return false;
	}


	invalidChars = " /:,;"
	if (emailText == "")
	{
		alert("Warning: Please enter an email address");
		return false;
	}


	for (i=0; i < 5; i++)
	{
		badChar = invalidChars.charAt(i)
		if (emailText.indexOf(badChar,0) > -1)
		{
			badEntry = "badEmail"
			alert("Error: You have entered an invalid email address");
		    return false;
		}
	}


	atsignLoc = emailText.indexOf("@",1)
	if (atsignLoc == -1)
	{
		alert("Error: There seems to be a problem with this email address");
		return false;
	}
	if (emailText.indexOf("@",atsignLoc+1) > -1)
	{
		alert("Error: There seems to be a problem with this email address");
		return false;
	}

	dotLoc = emailText.indexOf(".",atsignLoc)
    if (dotLoc == -1)
	{
		alert("Error: There seems to be a problem with this email address");
		return false;
	}
	if (dotLoc+3 > emailText.length)
	{
		alert("Error: There seems to be a problem with this email address");
		return false;
	}

}


function validate_forum_topic_entry_form()
{
	x=document.topic_entry;
	topicText = x.topic.value;
	commentText = x.comment.value;

	submitOK="True";

	if(topicText.length == 0)
	{
		alert("You must enter a Topic");
		submitOK="False";
	}
	else if(commentText.length == 0)
	{
		alert("You must enter a Comment");
		submitOK="False";
	}

	if(submitOK=="False")
	{
		return false;
	}
}

function validate_forum_topic_entry_form()
{
	x=document.topic_entry;
	topicText = x.topic.value;
	commentText = x.comment.value;

	submitOK="True";

	if(topicText.length == 0)
	{
		alert("You must enter a Topic");
		submitOK="False";
	}
	else if(commentText.length == 0)
	{
		alert("You must enter a Comment");
		submitOK="False";
	}

	if(submitOK=="False")
	{
		return false;
	}
}

/**
 * This function ensures that spaces are not allowed in image names
 */
function validate_image_name()
{
	x=document.uploadimage;
	commentText = x.userfile.value;

	submitOK="True";

	while ( commentText.indexOf( "\\" ) != -1)
	{
		commentText = commentText.substring(commentText.indexOf("\\") +1);
	}



	if (commentText.indexOf(" ") >= 0)
	{
		alert("The image name cannot contain spaces");
		submitOK="False";
	}

	if(submitOK=="False")
	{
		return false;
	}
}

function validate_date()
{
	x=document.newsform;
	dateText = x.date.value;

	submitOK="True";

	if (dateText.substring(4,5) != "-")
	{
	   submitOK="False";
	   alert("Date must be YYYY-MM-DD");
	   return false;
	}

	if (dateText.substring(7,8) != "-")
	{
	   submitOK="False";
	   alert("Date must be YYYY-MM-DD");
	   return false;
	}

	if (dateText.substring(0,4) == "YYYY")
	{
       submitOK="False";
	   alert("Date must be YYYY-MM-DD");
	   return false;

    }

}

function validate_topic_name()
{
	x=document.set_topic;
	commentText = x.new_topic.value;

	submitOK="True";

	if (commentText.indexOf(" ") >= 0)
	{
		alert("The topic name cannot contain spaces");
		submitOK="False";
	}

	if(submitOK=="False")
	{
		return false;
	}
}


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function


function load2(){
alert("test");
}

 function load() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(52.796703, -6.895369), 16);
	map.setMapType(G_SATELLITE_MAP);

	var point = new GLatLng(52.795383,-6.896458);
        map.addOverlay(createMarker(point, "Fr. Cullen National School<br><a class = 'light-link' href='http://www.tinryland.ie/index.php?parish/school'>Open School Page</a>"));

	var point2 = new GLatLng(52.796314,-6.896603);
        map.addOverlay(createMarker(point2, "St. Joseph's Church<br><a class = 'light-link' href='http://www.tinryland.ie/index.php?parish/church'>Open Church Page</a>"));

	var point3 = new GLatLng(52.799907,-6.881599);
        map.addOverlay(createMarker(point3, "Tinryland GFC<br><a class = 'light-link' href='http://www.tinryland.ie/index.php?sport/gaa'>Open Tinryland GFC Page</a>"));

	var point4 = new GLatLng(52.797682,-6.899693);
        map.addOverlay(createMarker(point4, "St. Joseph's AFC<br><a class = 'light-link' href='http://www.tinryland.ie/index.php?sport/soccer'>Open Soccer Page</a>"));
   }
 }

 
function createMarker(point, number) {
      var marker = new GMarker(point);
      GEvent.addListener(marker, "click", function() {
         marker.openInfoWindowHtml("<b>" + number + "</b>");
      });
      return marker;
 }
