function viewPhoto(category,id,number,hits) {

	window.open("photoutils.php?action=view&category="+category+"&id="+id+"&number="+number+"&hits="+hits+"","","width=500,height=600,statusbar=0,status=0,resizable=1,scrollbars=1");


}


function viewAudio(category,id,number,hits) {

	newWindow = window.open("mediautils.php?action=viewaudio&category="+category+"&id="+id+"&number="+number+"&hits="+hits+"","RAMEDIA","width=350,height=350,statusbar=0,resizable=1");
	newWindow.focus();	

}


function viewVideo(category,id,number,hits) {

	newWindow = window.open("mediautils.php?action=viewvideo&category="+category+"&id="+id+"&number="+number+"&hits="+hits+"","RAMEDIA","width=350,height=390,statusbar=0,resizable=1");
	newWindow.focus();

}


function checkboxChecked(checkboxname) {

	if (document.all &&typeof document.all[checkboxname] == "undefined") {
		window.status = "checkbox: " + checkboxname + " does not exist";
	}

	//if (typeof document.all[checkboxname] != "undefined") {
		if (document.getElementById(checkboxname).checked) {
			return true;
		}
	//}
	//else {
		//window.status = "checkbox: " + checkboxname + " does not exist";
		//return true;
	//}

}

function uncheckAllBoxes() {

	checkboxes = document.getElementsByTagName("input");
	for (i = 0; i < checkboxes.length; i++) {
		if (checkboxes[i].type.toLowerCase() == "checkbox") {
			checkboxes[i].checked = false;
		}
	}

	updateSearch();

}



function talent(id,firstname,lastname,agemin,agemax,heightfeet,heightinches,weight,eyecolor,haircolor,experiencetheatrical,experiencecommercial,experiencespokesperson,experienceearprompt,experiencecomedy,experiencemusicaltheatre,experienceadd1,experienceadd2,experienceadd3,experienceadd4,experienceall,unionsag,unionaftra,unionaea,unionnon,unionadd1,unionadd2,unionadd3,unionadd4,unionall,ethniccaucasian,ethnicafricanamerican,ethnichispanic,ethnicasian,ethnicnativeamerican,ethniceastindian,ethnicmiddleeastern,ethnicadd1,ethnicadd2,ethnicadd3,ethnicadd4,ethnicall,languagemulti) {

this.id = id;
this.firstname= unescape(firstname);
this.lastname= unescape(lastname);
this.agemin = agemin;
this.agemax= agemax;
this.heightfeet = heightfeet;
this.heightinches = heightinches;
this.weight = weight;
this.eyecolor = eyecolor;
this.haircolor = haircolor;
this.experiencetheatrical= experiencetheatrical;
this.experiencecommercial= experiencecommercial;
this.experiencespokesperson= experiencespokesperson;
this.experienceearprompt= experienceearprompt;
this.experiencecomedy= experiencecomedy;
this.experiencemusicaltheatre= experiencemusicaltheatre;
this.experienceadd1= experienceadd1;
this.experienceadd2= experienceadd2;
this.experienceadd3= experienceadd3;
this.experienceadd4= experienceadd4;
this.experienceall= experienceall;
this.unionsag= unionsag;
this.unionaftra= unionaftra;
this.unionaea= unionaea;
this.unionnon= unionnon;
this.unionadd1= unionadd1;
this.unionadd2= unionadd2;
this.unionadd3= unionadd3;
this.unionadd4= unionadd4;
this.unionall= unionall;
this.ethniccaucasian= ethniccaucasian;
this.ethnicafricanamerican= ethnicafricanamerican;
this.ethnichispanic= ethnichispanic;
this.ethnicasian= ethnicasian;
this.ethnicnativeamerican= ethnicnativeamerican;
this.ethniceastindian= ethniceastindian;
this.ethnicmiddleeastern= ethnicmiddleeastern;
this.ethnicadd1= ethnicadd1;
this.ethnicadd2= ethnicadd2;
this.ethnicadd3= ethnicadd3;
this.ethnicadd4= ethnicadd4;
this.ethnicall= ethnicall;
this.languagemulti= languagemulti;

if (ethnicall) {
//alert(this.lastname)
}

}



function showResultDetails() {
	selectedValue = document.getElementById("results").value;

	if (selectedValue != -1) {
		t = talents[selectedValue];
		
		titleText = t.firstname+" "+t.lastname;
		if (t.agemax != 0) {
			titleText += "\nAge range: "+t.agemin+" to "+t.agemax;
		}
		titleText += "\nHeight: "+t.heightfeet + "\' " + t.heightinches + "\"";
		if (t.weight != "" && t.weight != "0") {
			titleText += "\nWeight: "+t.weight + "";
		}
		if (t.eyecolor != "") {
			titleText += "\nEye Color: "+t.eyecolor + "";
		}
		if (t.haircolor != "") {
			titleText += "\nHair Color: "+t.haircolor + "";
		}

		document.getElementById("thumbnail").setAttribute("src",thumbnails[t.id].src)//"photoutils.php?category="+category+"&type="+type+"&type2="+type2+"&id="+t.id+"&number=1&t=1");
		document.getElementById("thumbnail").setAttribute("title",titleText);
		document.getElementById("thumbnailLink").setAttribute("href","database.php?action=view&category="+category+"&type="+type+"&type2="+type2+"&id="+t.id+"&hits=1");

		document.getElementById("openResultInNewWindowDiv").innerHTML = "<a target=_blank href=database.php?action=view&category="+category+"&type="+type+"&type2="+type2+"&id="+t.id+"&hits=1>Open "+ t.firstname + " " + t.lastname + " in a new window</a>";	

	}	
	else {	
		document.getElementById("thumbnail").setAttribute("src","images/spacer.gif");
		document.getElementById("thumbnail").setAttribute("title","");
		document.getElementById("openResultInNewWindowDiv").innerHTML = "";
		document.getElementById("thumbnailLink").setAttribute("href","javascript:void(0);");
	}



}

function updateSearch() {


resultsReturned = 0;


ageminChoice = document.getElementById("agemin").value;
agemaxChoice = document.getElementById("agemax").value;

var checkboxNames = ["experiencetheatrical","experiencecommercial","experiencespokesperson",
"experienceearprompt","experiencecomedy","experiencemusicaltheatre","unionsag","unionaftra",
"unionaea","unionnon","ethniccaucasian","ethnicafricanamerican","ethnichispanic","ethnicasian",
"ethnicnativeamerican","ethniceastindian","ethnicmiddleeastern","ethnicall","languagemulti"]

var checkboxStatus = [];
for (var i = 0; i<checkboxNames.length; i++) {
	checkboxStatus[checkboxNames[i]] = checkboxChecked(checkboxNames[i])
}

var noneexperience = (!checkboxStatus["experiencetheatrical"] && !checkboxStatus["experiencecommercial"] && !checkboxStatus["experiencespokesperson"] && !checkboxStatus["experienceearprompt"] && !checkboxStatus["experiencecomedy"] && !checkboxStatus["experiencemusicaltheatre"])

var noneunion = (!checkboxStatus["unionsag"] && !checkboxStatus["unionaftra"] && !checkboxStatus["unionaea"] && !checkboxStatus["unionnon"])

var noneethnicity = (!checkboxStatus["ethniccaucasian"] && !checkboxStatus["ethnicafricanamerican"] && !checkboxStatus["ethnichispanic"] && !checkboxStatus["ethnicasian"] && !checkboxStatus["ethnicnativeamerican"] && !checkboxStatus["ethniceastindian"] && !checkboxStatus["ethnicmiddleeastern"] && !checkboxStatus["ethnicall"])



document.getElementById("results").length = 0;
	for (var i = 0; i < talents.length; i++) {
		t = talents[i];

window.status = (t.ethnicall == checkboxStatus["ethnicall"]);


if (
(noneexperience ||
t.experienceall
||
t.experiencetheatrical == checkboxStatus["experiencetheatrical"]
||
t.experiencecommercial == checkboxStatus["experiencecommercial"]
||
t.experiencespokesperson == checkboxStatus["experiencespokesperson"]
||
t.experienceearprompt == checkboxStatus["experienceearprompt"]
||
t.experiencecomedy == checkboxStatus["experiencecomedy"]
||
t.experiencemusicaltheatre == checkboxStatus["experiencemusicaltheatre"]
||
t.ethnicall == checkboxStatus["ethnicall"]
)
&&
(noneunion ||
t.unionall ||
t.unionsag == checkboxStatus["unionsag"]
||
t.unionaftra == checkboxStatus["unionaftra"]
||
t.unionaea == checkboxStatus["unionaea"]
||
t.unionnon == checkboxStatus["unionnon"]
)
&&
(noneethnicity ||
t.ethniccaucasian == checkboxStatus["ethniccaucasian"]
||
t.ethnicafricanamerican == checkboxStatus["ethnicafricanamerican"]
||
t.ethnichispanic == checkboxStatus["ethnichispanic"]
||
t.ethnicasian == checkboxStatus["ethnicasian"]
||
t.ethnicnativeamerican == checkboxStatus["ethnicnativeamerican"]
||
t.ethniceastindian == checkboxStatus["ethniceastindian"]
||
t.ethnicmiddleeastern == checkboxStatus["ethnicmiddleeastern"]
||
t.ethnicall == checkboxStatus["ethnicall"]
)
&&
(
!checkboxStatus["languagemulti"] || (checkboxStatus["languagemulti"] && (t.languagemulti == checkboxStatus["languagemulti"]))
)
&&
((t.agemax == 0) || (t.agemin >= ageminChoice && t.agemin <= agemaxChoice) || (t.agemax >= ageminChoice && t.agemax <= agemaxChoice))


) {

			var newOption = new Option(t.lastname + ", " + t.firstname, i); 
			var nbOptions = document.getElementById("results").length; 
			document.getElementById("results").options[nbOptions] = newOption;
			resultsReturned++;   
		}



		
	}


	if (resultsReturned > 0) {
		document.getElementById("results").selectedIndex = 0;
		showResultDetails();
	}
	else {
		var newOption = new Option("No Matches", -1); 
var nbOptions = document.getElementById("results").length; 
document.getElementById("results").options[nbOptions] = newOption;
		document.getElementById("results").selectedIndex = 0;
		showResultDetails();
	}

	document.getElementById("results").focus();
	document.getElementById("resultsReturnedDiv").innerHTML = "<b>Results:</b> <font color=blue>"+resultsReturned + " matches</font>";

}





