function element(id) {
 if(document.getElementById != null) {
  return document.getElementById(id);
 }
 if(document.all != null) {
  return document.all[id];
 }
 if(document.layers != null) {
  return document.layers[id];
 }
 return null;
}

var xmlhttp=false;
try {
 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
 try {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (E) {
  xmlhttp = false;
 }
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 xmlhttp = new XMLHttpRequest();
}

var UTBC = 'http://www.fishingmaster.com/';

function save_fish_rig_user(fish,rig,user) {
    str = 'caught_' + fish + '_' + rig;
    checked = element(str).checked;
    //alert(fish + ' - ' + lure + ' - ' + user + ' - ' + checked);    
    //pg = "includes/ajax/save_fish_rig_contact.php?fishID=" + fish + "&rigID=" + rig + "&contactID=" + user + "&checked=" + checked + "&d=" + Date();
    pg = UTBC + "index.php/fish/save_fish_rig_contact/" + fish + "/" + rig + "/" + user + "/" + checked;
    xmlhttp.open("GET", pg,true);
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
        column = element('column_' + fish + '_' + rig);
        if(checked) {
            column.innerHTML = parseInt(column.innerHTML) + 1; 
        } else {
            column.innerHTML = parseInt(column.innerHTML) - 1;
        }
     }
    }
    xmlhttp.send(null)   
}


function other_rigs_fish(fishID,user) {
    var rig = element('caught_it_rig').value;
		if(rig == '') {
			alert("You must enter a rig.");
		} else {
	    rig = escape(rig);
	    //pg = "includes/ajax/save_other_fish_rig_contact.php?fishID=" + fishID + "&rig=" + rig + "&contactID=" + user + "&d=" + Date();
	    pg = UTBC + "index.php/fish/save_other_fish_rig_contact/" + fishID + "/" + rig + "/" + user;
	    xmlhttp.open("GET", pg,true);
	    xmlhttp.onreadystatechange=function() {
	     if (xmlhttp.readyState==4) {
	        //alert(xmlhttp.responseText);
	        element('success_table_rigs').style.display = '';
        
	     }
	    }
	    xmlhttp.send(null)
		}
}


function other_fish_rigs(rigID,user) {
  var fish = element('caught_it_rig').value;
	if(fish == '') {
		alert("You must enter a fish.");
	} else {
	  if(fish == '') {
	    fish = 'none';
	  }
	  fish = escape(fish);    
	  pg = UTBC + "index.php/fish/save_other_fish_rig_contact/" + fish + "/" + rigID + "/" + user;
	  xmlhttp.open("GET", pg,true);
	  xmlhttp.onreadystatechange=function() {
	   if (xmlhttp.readyState==4) {
	      //alert(xmlhttp.responseText);
	      element('success_table_rigs').style.display = '';
	   }
	  }
	  xmlhttp.send(null)
	}
}



