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_bait_user(fish,bait,user) {
    str = 'caught_' + fish + '_' + bait;
    checked = element(str).checked;
    //alert(fish + ' - ' + lure + ' - ' + user + ' - ' + checked);
    //pg = "includes/ajax/save_fish_bait_contact.php?fishID=" + fish + "&baitID=" + bait + "&contactID=" + user + "&checked=" + checked + "&d=" + Date();
    pg = UTBC + "index.php/fish/save_fish_bait_contact/" + fish + "/" + bait + "/" + user + "/" + checked;
    xmlhttp.open("GET", pg,true);
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
        column = element('column_' + fish + '_' + bait);
        if(checked) {
            column.innerHTML = parseInt(column.innerHTML) + 1; 
        } else {
            column.innerHTML = parseInt(column.innerHTML) - 1;
        }
     }
    }
    xmlhttp.send(null)   
}


function other_fish_baits(fishID,user,subject) {
    bait = element('caught_it').value;
		if(bait == '') {
			alert("You must enter a " + subject + ".");
		} else {
	    bait = escape(bait);
	    //pg = "includes/ajax/save_other_fish_bait_contact.php?bait=" + bait + "&fishID=" + fishID + "&contactID=" + user + "&d=" + Date();
	    pg = UTBC + "index.php/fish/save_other_fish_bait_contact/" + fishID + "/" + bait + "/" + user
	    xmlhttp.open("GET", pg,true);
	    xmlhttp.onreadystatechange=function() {
	     if (xmlhttp.readyState==4) {
	        //alert(xmlhttp.responseText);
	        element('success_table').style.display = '';
	     }
	    }
	    xmlhttp.send(null)
		}
}


function other_baits_fish(baitID,user,subject) {
    fish = element('caught_it').value;
		if(fish == '') {
			alert("You must enter a " + fish + ".");
		} else {
	    fish = escape(fish);
	    //pg = "includes/ajax/save_other_fish_bait_contact.php?bait=" + bait + "&fishID=" + fishID + "&contactID=" + user + "&d=" + Date();
	    pg = UTBC + "index.php/fish/save_other_fish_bait_contact/" + fish + "/" + baitID + "/" + user
	    xmlhttp.open("GET", pg,true);
	    xmlhttp.onreadystatechange=function() {
	     if (xmlhttp.readyState==4) {
	        //alert(xmlhttp.responseText);
	        element('success_table').style.display = '';
	     }
	    }
	    xmlhttp.send(null)
		}
}



