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_lure_user(fish,lure,user) {
    str = 'caught_' + fish + '_' + lure;
    var checked = element(str).checked;
    //alert(fish + ' - ' + lure + ' - ' + user + ' - ' + checked);    
    //pg = "http://localhost/fishingmaster/includes/ajax/save_fish_lure_contact.php?fishID=" + fish + "&lureID=" + lure + "&contactID=" + user + "&checked=" + checked + "&d=" + Date();
    //pg = "http://localhost/fishingmaster/includes/ajax/save_fish_lure_contact.php?fishID=" + fish + "&lureID=" + lure + "&contactID=" + user + "&checked=" + checked + "&d=" + Date();
    pg = UTBC + "index.php/fish/save_fish_lure_contact/" + fish + "/" + lure + "/" + user + "/" + checked;
    xmlhttp.open("GET", pg,true);
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
        //alert(xmlhttp.responseText);
        column = element('column_' + fish + '_' + lure);
        if(checked) {
            column.innerHTML = parseInt(column.innerHTML) + 1; 
        } else {
            column.innerHTML = parseInt(column.innerHTML) - 1;
        }
     }
    }
    xmlhttp.send(null)   
}


function other_fish_lures(lure,user) {
    var fish = $('caught_it').value;
		if(fish == '') {
			alert("You must enter a fish.");
		} else {
	    while(fish.indexOf("/") != -1) {
	        fish = fish.replace("/","_@_");
	    }    
	    fish = escape(fish);
	    dd = new Date();
	    //pg = "includes/ajax/save_other_fish_lure_contact.php?fish=" + fish + "&lureID=" + lure + "&contactID=" + user + "&d=" + dd;
	    pg = UTBC + "index.php/fish/save_other_fish_lure_contact/" + fish + "/" + lure + "/" + user;
	    xmlhttp.open("GET", pg,true);
	    xmlhttp.onreadystatechange=function() {
	     if (xmlhttp.readyState==4) {
	        element('success_table').style.display = '';
	     }
	    }
	    xmlhttp.send(null)
		}
}

function other_lures_fish(fish,user) {
    lure = element('caught_it_lure').value;
		if(lure == '') {
			alert("You must enter a lure.");
		} else {
	    lure = escape(lure);
	    pg = UTBC + "index.php/fish/save_other_fish_lure_contact/" + fish + "/" + lure + "/" + user;    
	    xmlhttp.open("GET", pg,true);
	    xmlhttp.onreadystatechange=function() {
	        if(xmlhttp.readyState==4) {
	            //alert(xmlhttp.responseText);
	            element('success_table_lures').style.display = '';
	        }
	    }
	    xmlhttp.send(null)
		}
}

/*
function add_fish_lure_user(obj,fish,lure,user) {
    if(obj.value != '') {
        //alert(fish + ' - ' + lure + ' - ' + user + ' - ' + checked);
        pg = "includes/ajax/add_fish_lure_contact.php?fishID=" + fish + "&lureID=" + lure + "&contactID=" + user + "&checked=" + checked;
        xmlhttp.open("GET", pg,true);
        xmlhttp.onreadystatechange=function() {
         if (xmlhttp.readyState==4) {
            column = element('column_' + fish + '_' + lure);
            if(checked) {
                column.innerHTML = parseInt(column.innerHTML) + 1; 
            } else {
                column.innerHTML = parseInt(column.innerHTML) - 1;
            }
         }
        }
        xmlhttp.send(null)
    } else {
        
    }
}
*/


