/*
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
*/

function positionElements() {
	var leftColumn = document.getElementById('leftColumn');
	var leftColumnHeight = leftColumn.offsetHeight;
	var middleColumn = '';
	if(document.getElementById('middleColumn') == null)
	{
		middleColumn = document.getElementById('middleColumn-alt');
	}
	else
	{
		middleColumn = document.getElementById('middleColumn');
	}
	
	
	var middleColumnHeight = middleColumn.offsetHeight;
	var rightColumn = document.getElementById('rightColumn');
	
	var rightColumnHeight;
	if(rightColumn) {
		rightColumnHeight = rightColumn.offsetHeight;
	} else {
		rightColumnHeight = 0;
	}
	var targetHeight = Math.max(Math.max(leftColumnHeight, middleColumnHeight), rightColumnHeight);
	
	if(leftColumn.offsetHeight < targetHeight) {
		document.getElementById('leftColumn').style.height = targetHeight + "px";
		document.getElementById('visitMassArt').style.bottom = "8px";
	}
	if(middleColumn.offsetHeight < targetHeight) {
		document.getElementById('middleColumn').style.height = targetHeight - 38 + "px";
	}
	if(rightColumn && rightColumn.offsetHeight < targetHeight) {
		document.getElementById('rightColumn').style.height = targetHeight - 135 + "px";
	}

	// check for cookie for box positions
/*
	var coord_str = readCookie("ma_coords");
	if (!coord_str) return(false);
	// since cookie is not empty, check for string "img", if this is present, we've gotten here from ther Flash homepage
	if (isMatch(coord_str,"img")) {
		// hide the bgLines div used to position the HTML
		document.getElementById("bgLines1").style.display = "none";
		document.getElementById("bgLines2").style.display = "none";
		document.getElementById("bgLines3").style.display = "none";
		// update the page's body the bgimg passed by Flash
		document.getElementsByTagName("BODY")[0].style.backgroundColor = "#e5e5e5";
		document.getElementsByTagName("BODY")[0].style.backgroundRepeat = "no-repeat";
		document.getElementsByTagName("BODY")[0].style.backgroundImage = "url(images/flashbgs/"+coord_str+".gif)";
		
		
	} else {
		// otherwise, we can grab the bg line positions from the cookie since we came from the HTML homepage
		// parse cookie
		var cookieValues_array = coord_str.split("|");
		var pageTop = cookieValues_array[0];
		//position sprite boxes
		for (var i = 1; i < cookieValues_array.length; i++) {
			var coord_array = cookieValues_array[i].split(",");
			var box = document.getElementById("bgLines" + i);
			box.style.left = coord_array[0] + "px";
			box.style.top = coord_array[1] + "px";
		}
		return(true);
	}
*/
}

function isMatch(pEl,pMatch){
	if ((pEl.match(pMatch))==pMatch) {
		return true;
	} else {
		return false
	}
}

function clearDefault ( el ) {
        if ( ! el.defaultValue ) {
                el.defaultValue = el.value;
        }
        if (  el.defaultValue == el.value) {
                el.value = "";
        }
}

function setDefault ( el ) {
        if ( el.value == "" && el.defaultValue ) {
                el.value = el.defaultValue;
        }
}

// For Continuing Education videos

function print_ce_video ( )
{
	var videos = new Array (
        "animation.flv",
	"bladesmithing.flv",
        "book-making.flv",
	"clothing-tech.flv",
        "drawing-for-designers.flv",
	"figure-clay.flv",
        "foundry.flv",
	"graphic-design.flv",
	"jewlery.flv",
	"silk-screening.flv",
        "tailoring.flv",
	"typography.flv",
        "web-design.flv"
	) ;

	var captions = new Array (
	"Continuing Education: Animation",
	"Continuing Education: Bladesmithing",
	"Continuing Education: Letterpress",
	"Continuing Education: Clothing Construction",
	"Continuing Education: Drawing for Designers",
	"Continuing Education: The Figure in Clay",
	"Continuing Education: Foundry",
	"Continuing Education: Graphic Design",
        "Continuing Education: Jewelry",
	"Continuing Education: Silkscreen Printing",
        "Continuing Education: Tailoring",
	"Continuing Education: Typography",
        "Continuing Education: Web Design"
	) ;

	var stills = new Array (
	"animation-still-with-play-b.jpg",
	"bladesmithingwebshot.jpg",
        "letterpresswebshot.jpg",
	"clothingconstwebshot.jpg",
        "drawingdesignerswebshot.jpg",
	"figuresculpturewebshot.jpg",
        "foundrywebshot.jpg",
	"GRAPHICDESIGN.jpg",
        "jewelrywebshot.jpg",
	"silkscreenwebshot.jpg",
        "tailoringwebshot.jpg",
	"gdtypographywebshot.jpg",
        "webdesignwebshot.jpg"
	) ;

	var randomnumber=Math.floor(Math.random()*13) ;
	// alert ( randomnumber ) ;

	document.write ( '<a class="thickbox" href="PreBuilt/mediaplayer.html?mediapath=../Media/flv/continuing_education/' + videos[randomnumber] + '&amp;vidwidth=720&amp;vidheight=400&amp;TB_iframe=true&amp;height=420&amp;width=720" title="' + captions[randomnumber] + '"><img height="117" src="Images/www.massart.edu/continuing_education/' + stills[randomnumber]+ '" width="184" /></a>' ) ;
}


