var IE = (navigator.appName == "Microsoft Internet Explorer") ? 1 : 0;
var NS = (navigator.appName == "Netscape") ? 1 : 0;


function setSize() {
	alert(document.size_menu.sizePicker.value);
}


//generate random funnies for bio pages
function randomFunny() {
	var fortune = new Array();
	fortune[0] = "Aquarius";
	fortune[1] = "Angry Musketeer";
	fortune[2] = "Terrified of lab rats";
	fortune[3] = "Crafty";
	fortune[4] = "Passionate rebel";
	fortune[5] = "Lead guitar, vocals, tape loops, trampoline, cowboy outfits";
	fortune[6] = "Made of Silly Putty";
	fortune[7] = "Wealthy gadabout";
	fortune[8] = "Cynical...err...realist";
	fortune[9] = "Willfully disobedient";
	fortune[10] = "Capricorn";
	fortune[11] = "Legend";
	fortune[12] = "Loose cannon";
	fortune[13] = "Revolutionary War hero";
	fortune[14] = "Free Mason";
	fortune[15] = "Judge and jury (but not executioner)";
	fortune[16] = "Zealot";
	fortune[17] = "Realist...err...cynic";
	fortune[18] = "The contemporary Johnny Appleseed";
	fortune[19] = "Glory hound";
	fortune[20] = "Playmate of the Year";
	fortune[21] = "Lead vocals, sass";
	fortune[22] = "Beziers, gradients and halftones";
	fortune[23] = "Polar opposite";
	fortune[24] = "Polar explorer";
	fortune[25] = "Scoutmaster";
	fortune[26] = "Gemini";
	fortune[27] = "Carpetbagger";
	fortune[28] = "Gadfly";
	fortune[29] = "Muckraker";
	fortune[30] = "Assistant director";
	fortune[31] = "Tic-tac-toe champion";
	fortune[32] = "Glass blowing";
	fortune[33] = "Fullback";
	fortune[34] = "Middle linebacker";
	fortune[35] = "Left field";
	fortune[36] = "Shortstop";
	fortune[37] = "First base";
	fortune[38] = "Secret agent (shhh!)";
	fortune[39] = "Locksmith";
	fortune[40] = "Clown-in-training";
	var ran_number=Math.round(Math.random()*40); 
	return fortune[ran_number];
}

//get age
function getAge(dateString) {


    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());

    var yearNow = now.getFullYear();
    var monthNow = now.getMonth();
    var dateNow = now.getDate();

    var dob = new Date(dateString.substring(6,10),dateString.substring(3,5)-1,dateString.substring(0,2));

    var yearDob = dob.getFullYear();
    var monthDob = dob.getMonth();
    var dateDob = dob.getDate();
	


    yearAge = yearNow - yearDob;

    
    if (monthNow >= monthDob)
        var monthAge = monthNow - monthDob;
    else {
        yearAge--;
        var monthAge = 12 + monthNow -monthDob;
    }

    if (dateNow >= dateDob)
        var dateAge = dateNow - dateDob;
    else {
        monthAge--;
        var dateAge = 31 + dateNow - dateDob;

        if (monthAge < 0) {
            monthAge = 11;
            yearAge--; 
        }
    }

    return yearAge + 'y' + monthAge + 'm' + dateAge +'d';
}


// open a window with the proper big image inside
function openImageWindow(imageName) {
	eval('imageSrc=document.images.' + imageName + '.src');
	pageSrc="productshot.php?img=" + imageSrc;
	popup(pageSrc,600,600);
}

// open a generic popup window, specifying source and size

	function popup(source,width,height) {
		
		now = new Date()
		window_name = now.getTime()
		popup_window = window.open(source,window_name,"width="+String(width)+",height="+String(height)+",location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes");
		popup_window.focus()
	}


// rollover

	function swap(name,state) {
	
		eval('document.images.' + name + '.src = ' + name + '_' + String(state) + '.src')
	}
	


// make my preloads for image swaps

	function makePreloads(names) {
		names = names.split(",")
		
		for (i=0; i < names.length; i++) {
			thisName = names[i]
			eval(thisName+"_0 = new Image()")
			eval(thisName+"_0.src = 'images/"+thisName+"_0.gif'")
			eval(thisName+"_1 = new Image()")
			eval(thisName+"_1.src = 'images/"+thisName+"_1.gif'")
		}
	}
	


