var ROOTURL="http://www.iwingo.co.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 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;

function preload_menu(){
   $pic1=new Image(97,25);$pic1.src=ROOTURL+'img/community_button2.gif';
   $pic2=new Image(100,25);$pic2.src=ROOTURL+'img/help_button2.gif';
   $pic3=new Image(54,25);$pic3.src=ROOTURL+'img/home_button2.gif';
   $pic4=new Image(91,25);$pic4.src=ROOTURL+'img/my_button2.gif';
}

window.onload=preload_menu;

function show_entry_form(){
   $free=document.getElementById('freeentryform');
   $text=document.getElementById('texttowin');
	 if(!$free.style.display || $free.style.display=='none'){
	    $free.style.display='block';
			$text.style.display='none';
	 }else{
	    $free.style.display='none';
			$text.style.display='block';
	 }
}

function bookmark_page() {
   $title="iWingo";
   $url="http://www.iwingo.com/";
   if(window.sidebar){
      //Mozilla
      window.sidebar.addPanel($title,$url,'');
   }else if(window.external){
      //IE
      window.external.AddFavorite($url,$title);
   }
	 return true;
}

function tell_gwingo(){
   $message=document.getElementById('gwingomessage').value;
	 if(!$message)return false;
   $url=ROOTURL+'inc/ajax/tell_gwingo.php?message='+$message;
   ajax_do(ajax_init(),$url,told_gwingo,'GET');
}

function told_gwingo(){
   $message=document.getElementById('gwingomessage').value='Your message was sent. Thanks for your feedback.';
}

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 expand_menu($id){
   $elem=document.getElementById($id);
	 if($elem.style.display=='none' || !$elem.style.display){
	    $elem.style.display='block';
	 }else{
	    $elem.style.display='none';
	 }
}
function show_random_quote(){
   document.getElementById('headerquote').style.display='block';
}
function hide_random_quote(){
   document.getElementById('headerquote').style.display='none';
}