//var ROOTURL="http://localhost/COM/MAKE/crawshawschool/";
var ROOTURL="http://www.crawshawschool.org.uk/";

function roll_over(image_id,change_to) {
   var this_img=document.getElementById(image_id);
   this_img.src=ROOTURL+change_to;
}
function post_form($form_id){document.getElementById($form_id).submit();}
function add_event($object,$type,$fn){ 
   if($object.attachEvent){ 
      $object['e'+$type+$fn] = $fn; 
      $object[$type+$fn] = function(){$object['e'+$type+$fn]( window.event );} 
      $object.attachEvent( 'on'+$type, $object[$type+$fn] ); 
   }else{
      $object.addEventListener($type,$fn,false); 
   }
}
function remove_event($object,$type,$fn){
   if($object.detachEvent){
      $object.detachEvent('on'+$type,$object[$type+$fn]);
      $object[$type+$fn]=null;
   }else{
      $object.removeEventListener($type,$fn,false);
   }
} 
function elements_with_class($elem,$tag_name,$class_name){
   var $arr_elems=($tag_name=="*" && document.all)? document.all : $elem.getElementsByTagName($tag_name);
   var $found = new Array();
   for($i=0;$i<$arr_elems.length;$i++){  
      if($arr_elems[$i].className==$class_name) $found.push($arr_elems[$i]);
   }
   return ($found);
}
function http_location($filename){
   window.location=$filename;
}
function confirm_action($message,$url) {
	var $answer=confirm($message);
	if($answer)window.location($url);
}
function picture_window($url,$width,$height,$window) {
   window.open($url+'&width='+$width+'&height='+$height,$window,"width="+$width+",height="+$height+",scrollbars=no,left=100,top=100");
}
function open_window($file_path,$width,$height,$title,$scrollbars) {
if(!$scrollbars)$scrollbars='no';
popup = window.open($file_path,$title,'scrollbars='+$scrollbars+',menubar=no,height='+$height+',width='+$width+',resizable=no,toolbar=no,location=no,status=no');
}
function show_event($event_id){
   $elem=document.getElementById('event'+$event_id);
	 $title=document.getElementById('eventtitle'+$event_id);
	 if(!$elem)return false;
	 if($elem.style.display=='block'){
	    $elem.style.display='none';
			$title.style.fontWeight='normal';
	 }else{
	    $elem.style.display='block';
			$title.style.fontWeight='bold';
	 }
}

function load_map($map_id) {
   $elem=document.getElementById($map_id);
	 if (GBrowserIsCompatible()) {
      var $map = new GMap2($elem);
      $point=new GLatLng(53.79237,-1.65671);
      $map.setCenter($point,13);
      var $marker = new GMarker($point);
      $map.addOverlay($marker);
      $marker.openInfoWindowHtml('<strong>Crawshaw School</strong><br />Robin Lane, Pudsey, Leeds, LS28 9HU<br /><a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q=LS28+9HU&ie=UTF8&ll=53.793782,-1.656704&spn=0.011129,0.029182&z=15&iwloc=addr&om=1" rel="external"><strong>Find us on Google Maps</strong></a>');
      $map.addControl(new GLargeMapControl());
   }
	 return true;
}

function external_links(){
   if (!document.getElementsByTagName) return;
   var anchors = document.getElementsByTagName("a");
   for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")anchor.target = "_blank";
   }
}
window.onload=external_links;