function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
} //end getPageSize

function getPageScroll() {
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	return yScroll;
} //end getPageScroll

function showLightbox(from) {
	var pageSize = getPageSize();
	
	var target = document.getElementById("lightbox");
	emptyElement(target);
	switch (from) {
		case "rate":
			var div = document.createElement("div");
			div.setAttribute("class","form-content");
			div.setAttribute("id","form-content");
			
			var table = document.createElement("table");
			table.setAttribute("cellspacing","0");
			table.setAttribute("border","0");
			
			//Create a tbody so crappy IE will actually work
			var tbody = document.createElement("tbody");
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			td.setAttribute("width","230");
			td.appendChild(makeStrong("Your Name"));
			tr.appendChild(td);
			
			var td = document.createElement("td");
			td.setAttribute("width","125");
			td.appendChild(makeStrong("City"));
			tr.appendChild(td);
			
			var td = document.createElement("td");
			td.appendChild(makeStrong("State"));
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			var input = document.createElement("input");
			input.setAttribute("type","text");
			input.setAttribute("id","rate_name");
			input.setAttribute("size","40");
			input.setAttribute("maxlength","75");
			td.appendChild(input);
			tr.appendChild(td);
			
			var td = document.createElement("td");
			var input = document.createElement("input");
			input.setAttribute("type","text");
			input.setAttribute("id","rate_city");
			input.setAttribute("size","20");
			input.setAttribute("maxlength","50");
			td.appendChild(input);
			tr.appendChild(td);
			
			var td = document.createElement("td");
			var dropdown = document.createElement("select");
			dropdown.setAttribute("id","rate_state");
			dropdown.setAttribute("invincible","yes");
			var option = document.createElement("option");
			option.setAttribute("selected","selected");
			option.setAttribute("value","");
			option.appendChild(document.createTextNode("Select State"));
			dropdown.appendChild(option);
			var states = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY");
			for (i in states) {
				var option = document.createElement("option");
				option.setAttribute("value",states[i]);
				option.appendChild(document.createTextNode(states[i]));
				dropdown.appendChild(option);
			} //end i in states FOR
			td.appendChild(dropdown);
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			if (document.all) {
				td.setAttribute("colSpan","3");
			} else {
				td.setAttribute("colspan","3");
			} //end document.all IF
			td.appendChild(makeStrong("Write your comment here"));
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			if (document.all) {
				td.setAttribute("colSpan","3");
			} else {
				td.setAttribute("colspan","3");
			} //end document.all IF
			var textarea = document.createElement("textarea");
			textarea.setAttribute("rows","8");
			textarea.setAttribute("cols","72");
			textarea.setAttribute("id","rate_comment");
			td.appendChild(textarea);
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			if (document.all) {
				td.setAttribute("colSpan","3");
			} else {
				td.setAttribute("colspan","3");
			} //end document.all IF
			td.appendChild(makeStrong("To rate this video select one below:"));
			td.appendChild(document.createTextNode(" ( 5 stars is the highest rating )"));
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			td.setAttribute("class","vert-align");
			if (document.all) {
				td.setAttribute("colSpan","3");
			} else {
				td.setAttribute("colspan","3");
			} //end document.all IF
			
			for (i = 5; i > 0; i--) {
				try {
					var input = document.createElement('<input type="radio" name="rating" id="rate_'+i+'">');
				} catch (err) {  
					var input = document.createElement("input");
					input.setAttribute("type","radio");
					input.setAttribute("name","rating");
					input.setAttribute("id","rate_"+i);
				} //end TRY/CATCH
				td.appendChild(input);
				td.appendChild(document.createTextNode(" "));
				
				for (j = 1; j <= i; j++) {
					var img = document.createElement("img");
					img.setAttribute("src","/i/small_blue_star.gif");
					img.setAttribute("width","10");
					img.setAttribute("height","9");
					td.appendChild(img);
				} //end j = 1; j <= i; j++ FOR
				
				for (k = 1; k <= (5-i); k++) {
					var img = document.createElement("img");
					img.setAttribute("src","/i/small_lightblue_star.jpg");
					img.setAttribute("width","10");
					img.setAttribute("height","10");
					td.appendChild(img);
				} //end k = 1; k <= (5-i); k++ FOR
				
				td.appendChild(document.createTextNode(" "));
				td.appendChild(document.createTextNode(" "));
				td.appendChild(document.createTextNode(" "));
			} //end i = 5; i > 0; i-- FOR
			var span = document.createElement("span");
			span.setAttribute("id","rate_rating_error");
			span.setAttribute("class","error");
			span.appendChild(document.createTextNode("You must choose a rating."));
			td.appendChild(span);
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			if (document.all) {
				td.setAttribute("colSpan","3");
			} else {
				td.setAttribute("colspan","3");
			} //end document.all IF
			var input = document.createElement("input");
			input.setAttribute("type","checkbox");
			input.setAttribute("id","rate_newsletter");
			td.appendChild(input);
			td.appendChild(document.createTextNode(" Yes, please sign me up for the PERDUE® Meals & More® e-newsletter that features new recipes, PERDUE® product news, promotions, and much more!"));
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			var tr = document.createElement("tr");
			var td = document.createElement("td");
			if (document.all) {
				td.setAttribute("colSpan","3");
			} else {
				td.setAttribute("colspan","3");
			} //end document.all IF
			td.appendChild(makeStrong("Email Address: "));
			var input = document.createElement("input");
			input.setAttribute("type","text");
			input.setAttribute("id","rate_email");
			input.setAttribute("size","30");
			input.setAttribute("maxlength","40");
			td.appendChild(input);
			tr.appendChild(td);
			tbody.appendChild(tr);
			
			table.appendChild(tbody);
			div.appendChild(table);
			target.appendChild(div);
			
			var p = document.createElement("p");
			p.setAttribute("id","form-bottom");
			p.setAttribute("class","form-bottom");
			target.appendChild(p);
			
			var p = document.createElement("p");
			p.setAttribute("id","terms");
			p.setAttribute("class","terms");
			var input = document.createElement("input");
			input.setAttribute("type","checkbox");
			input.setAttribute("id","rate_terms");
			input.setAttribute("value","1");
			p.appendChild(input);
			p.appendChild(document.createTextNode(" I have read and agree to "));
			var a = document.createElement("a");
			a.setAttribute("href","/util/privacy.html");
			a.setAttribute("target","_blank");
			a.appendChild(document.createTextNode("Perdue's Terms & Conditions and Privacy Policy"));
			p.appendChild(a);
			p.appendChild(document.createTextNode("."));
			var span = document.createElement("span");
			span.setAttribute("id","rate_terms_error");
			span.setAttribute("class","error");
			span.appendChild(document.createTextNode("You must agree to Perdue's Terms & Conditions and Privacy Policy."));
			p.appendChild(span);
			target.appendChild(p);
			
			var p = document.createElement("p");
			p.setAttribute("id","rate_buttons");
			var img = document.createElement("img");
			img.setAttribute("class","pointer");
			img.setAttribute("src","/i/button_submit.jpg");
			img.setAttribute("alt","Submit");
			if (document.all) {
				img.onclick = rateVideo;
			} else {
				img.setAttribute("onclick","rateVideo();");
			} //end document.all IF
			p.appendChild(img);
			p.appendChild(document.createTextNode(" "));
			var img = document.createElement("img");
			img.setAttribute("class","pointer");
			img.setAttribute("src","/i/button_cancel.jpg");
			img.setAttribute("alt","Cancel");
			if (document.all) {
				img.onclick = hideLightbox;
			} else {
				img.setAttribute("onclick","hideLightbox();");
			} //end document.all IF
			p.appendChild(img);
			target.appendChild(p);
			
			//Crappy IE style fixes
			if (document.all) {
				document.getElementById("form-content").className = "form-content";
				document.getElementById("form-bottom").className = "form-bottom";
				document.getElementById("terms").className = "terms";
				document.getElementById("rate_terms_error").className = "error";
				document.getElementById("rate_rating_error").className = "error";
			} //end document.all IF
		break;
		case "share":
			target.innerHTML = "";
		break;
	} //end from SWTICH
	
	//Hide select boxes as they will 'peek' through the blackout in IE
	var selects = document.getElementsByTagName("select");
	for (i = 0; i < selects.length; i++) {
		if (selects[i].getAttribute("invincible") != "yes") {
			selects[i].style.visibility = "hidden";
		} //end selects[i].getAttribute("invincible") != "yes" IF
	} //end i = 0; i < selects.length; i++ FOR
	
	//Blackout screen
	var blackout = document.getElementById("blackout");
	blackout.style.width = (pageSize[0]-10)+"px";
	blackout.style.height = (pageSize[1]-10)+"px";
	blackout.style.display = "block";
	
	//Display lightbox
	target.style.width = "580px";
	//target.style.height = "400px";
	target.style.left = ((pageSize[2]/2)-290)+"px";
	target.style.top = (((pageSize[3]/2)-150)+getPageScroll())+"px";
	target.style.display = "block";
} //end showLightbox

function hideLightbox() {
	//Remove blackout & lightbox
	document.getElementById("blackout").style.display = "none";
	document.getElementById("lightbox").style.display = "none";
	
	//Make select boxes visible
	var selects = document.getElementsByTagName("select");
    for (i = 0; i < selects.length; i++) {
		selects[i].style.visibility = "visible";
	} //end i = 0; i < selects.length; i++ FOR
} //end hideLightbox