
function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'');
	return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	return str;
}
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

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;
	}

	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}

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;
}


function hideLightbox()
{

	objLightbox.style.display = 'none';
	objOverlay.style.display = 'none';
	objLightbox.innerHTML = "";
}



var firsttime = true;

function playVideo(id,loader,title,clearer){

	var video = document.getElementById('video');
	var overlay = document.getElementById('overlay');
	if(loader){
		if(clearer)
			clearList('ul1');
		video.innerHTML = '<div style="text-align: center; font-size: 120%;"><img src="'+live_site+'/load.gif"><br />loading videos...</div>';
		height= 80;
		width = 220;
	}else{
		// video.innerHTML = '<div style="text-align: right; font-size: 120%;">'+title.substr(0,60)+'  <img src="'+live_site+'/close.gif" onclick="hideLightbox()"><br/>'+createPlayerNow(id)+'</div>';
		// video.innerHTML = '<div style="text-align: right; font-size: 120%;">'+title.substr(0,60)+'  <img src="'+live_site+'/close.gif" onclick="hideLightbox()"><br/><object width="510" height="420"><param name="movie" value="'+live_site+'/v/'+id+'&rel=0&color1=0x234900&color2=0x4e9e00&border=0"></param><param name="autoplay" value="1"><param name="wmode" value="transparent"></param><embed src="'+live_site+'/v/'+id+'&autoplay=1&rel=0&color1=0x234900&color2=0x4e9e00&border=0" type="application/x-shockwave-flash" wmode="transparent" width="510" height="420"></embed></object></div>';
		video.innerHTML = '<div style="text-align: right; font-size: 120%;">'+title.substr(0,60)+'  <img src="'+live_site+'/close.gif" onclick="hideLightbox()"><br/><embed src="'+live_site+'/flash/mediaplayer.swf" width="510" height="420" allowscriptaccess="always" allowfullscreen="false" flashvars="height=420&width=510&file='+live_site+'/playYT.php?v='+id+'&backcolor=0xCCCCCC&lightcolor=0xEEEEEE&screencolor=0x333333&logo='+live_site+'/images/logo/final2_white_micro_mini2.png&recommendations='+live_site+'/flash/recommendations/recommendations_youtube.xml&autostart=false"/></div>';
		height= 420;
		width = 510;
	}

	//if(firsttime){
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();

		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 60 - width) / 2);

		video.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		video.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";

		overlay.style.height = (arrayPageSize[1] + 'px');
		overlay.style.display = 'block';
	//}
	video.style.display = "block";

}

function mousOverImage(name,id,nr){
	if(name)
		imname = name;
	imname.src = ""+live_site+"/images/vid/"+id+"/"+nr+".jpg";
	imname.style.border = 	'1px solid orange';
	nr++;
	if(nr > 3)
		nr = 1;
	timer =  setTimeout("mousOverImage(false,'"+id+"',"+nr+");",1000);

}

function mouseOutImage(name){

	if(name)
		imname = name;
	//make border back to greyish
	imname.style.border = 	'1px solid #333';
	if(timer)
		clearTimeout(timer);

}
