// retrieve the value from a pulldown menu
function getOption(pulldown){
	return pulldown.options[pulldown.options.selectedIndex].value;
}

// retrieve the value associated with a radio button group
function getRadio(radio){
	for (i=0; i<radio.length; i++){
		if (radio[i].checked) return radio[i].value;
	}
	return "";
}

// retrieve the value(s) associated with a check box (group)
function getCheck(check){
	if (check.length == undefined) return check.value;
	values = [];
	for (i=0; i<check.length; i++){
		if (check[i].checked) values[values.length] = check[i].value;
	}
	return values;
}

// parse a variable from the query string
function getURLValue(variable){
	queryString = document.location.search.substring(1);
	if (queryString == "") return "";
	pairs = queryString.split("&");
	for (i=0; i<pairs.length; i++){
		if (pairs[i].split("=")[0].toLowerCase() == variable.toLowerCase()) return unescape(pairs[i].split("=")[1]);
	}
	return "";
}
function capitalize(string){
	// capitalizes all words in a string
	tmp = "";
	string = string.split(/\s+/); // split on any white space
	for (i=0; i<string.length; i++){
		tmp += ((i==0)?"":" ") + string[i].charAt(0).toUpperCase() + string[i].substring(1).toLowerCase();
	}
	return tmp;
}
function popup(url, name, w, h){	
	var left = (screen.width - w) / 2;
	var top = (screen.height - h) / 2;
	features = 'width='+w+',height='+h+',top='+top+',left='+left+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	newwindow=window.open(url,name,features);
	newwindow.focus()
}

function popupScroll(url, name, w, h){	
	var left = (screen.width - w) / 2;
	var top = (screen.height - h) / 2;
	features = 'width='+w+',height='+h+',top='+top+',left='+left+',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
	newwindow=window.open(url,name,features);
	newwindow.focus()
}


Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
} 


var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
parseDate = function (inDate) {
	dateArray = inDate.split("/");
	outMonth = months[dateArray[0]-1];
	outDay = dateArray[1].toString();
	if (outDay.charAt(outDay.length-1) == "1" && outDay.charAt(outDay.length-2) != "1") {
		outDay += "st";
	} else if (outDay.charAt(outDay.length-1) == "2" && outDay.charAt(outDay.length-2) != "1") {
		outDay += "nd";
	} else if (outDay.charAt(outDay.length-1) == "3" && outDay.charAt(outDay.length-2) != "1") {
		outDay += "rd";
	} else {
		outDay += "th";
	}
	return outMonth+" "+outDay;
};

function showDate(){
	now=new Date();
	return months[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear();
}

function showImage(img){
	document.getElementById("celebs_img").innerHTML = "<img src='assets/CELEBS/pngs/" + img + ".png'>";
	
}

function popShirt(){
	popup("/shirt.html", "shirt", 400, 500);	
}

function popMenu(){
	popupScroll("/tallmenu.html", "menu",660, 760);
}
