$imagewidth		= 0;
$imageObject	= "";
$mic = ".avi.mpg.mpeg.wmv.wmx.asx.asf";
$mSid = 0;
function upload($obj, $sid, $nr, $width, $src) {
	if ( !controlBytes() ) {
		alert("Server limit bereikt");
		return;
	}
	if ( typeof $src != "string" ) $src = "";
	$imagewidth = $width;
	$mSid = $sid;
	if ( typeof $obj == "object" ) $imageObject = $obj;
	$html =	"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><HTML lang='nl'><BODY>";
	$html +=	"<FORM id='uploadfrm' method='post' action='http://" + window.location.host + "/z-php/upload.php'";
	$html +=	" enctype='multipart/form-data' target='upFrame'>\n";
	$html +=	"<INPUT type='file' style='visibility: hidden' id='userfile' name='userfile' onchange='parent.$my_uploaden(this)'>";
	$html +=	"<INPUT type='hidden' name='sid'		value='" + $sid + "'>";
	$html +=	"<INPUT type='hidden' name='url'		value='" + document.getElementById("url").value + "'>";
	$html +=	"<INPUT type='hidden' name='site'		value='" + document.getElementById("site").value + "'>";
	$html +=	"<INPUT type='hidden' name='width'		value='" + $width + "'>";
	$html +=	"<INPUT type='hidden' name='src'		value='" + $src + "'>";
	$html +=	"</FORM></BODY></HTML>";
	frames['upFrame'].document.open();
	frames['upFrame'].document.write($html);
	frames['upFrame'].document.close();
	frames['upFrame'].document.getElementById("userfile").click();
}
function $my_uploaden($m_obj) {
	if ( $imageObject != null ) {
		if ( typeof $imageObject == "object" ) $imageObject.src = "z-img/newRecord.jpg";
	}
	$img = ".jpg.gif.png.bmp";
	//startLoading("Loading " + $m_obj.value + ".....");
	frames['upFrame'].document.getElementById("uploadfrm").submit();
}
function showPicture($picture, $sid) {
	//stopLoading();
	//alert($picture);
	if ( $sid == "mediabase" ) {
		document.getElementById("emailfoto").src = $picture;
		document.getElementById("userform_foto").value = $picture;
		return;
	}
	if ( $sid == "eddy" ) {
		$file = $picture.substr($picture.lastIndexOf("/")*1+1);
		var oOption = document.createElement("OPTION");
		oOption.text=$file;
		oOption.value=$picture;
		document.getElementById("bijlagen").add(oOption);
		return;
	}
	if ( $picture == "" ) getPage("");
	if ( $imagewidth == "imageLoad" ) {
		document.getElementById("sx").value = "url(/" + $picture + ")";
		$activeValue = "url(/" + $picture + ")";
		ssColor();
		return;
	}
	if ( $mSid == -100 ) {
		$imageObject.src = $picture;
		return;
	}
	$alt = $picture.substr($picture.lastIndexOf("/")*1+1);
	$alt = $alt.substr(0, $alt.lastIndexOf("."));
	if ( $sid > 0 ) {
		if ( forumS > 0 ) {
			alert("upload compleded");
			return;
		}
		$imageObject.src = $picture;
		return;
	}
	while ( $alt.indexOf("-") > -1 ) $alt = $alt.replace("-", " ");
	if ( $imagewidth < 1 ) $imagewidth = ""; else $imagewidth = " width='" + $imagewidth + "'";
	frames[2].tinyMCE.execCommand("mceInsertContent", false, "<img usemap='' src='/" + $picture + "' border='0' alt='" + $alt + "'" + $imagewidth + ">");
	$imagewidth = "";
}
function getMovies() {
	if ( supervisor > 0 ) {
		if ( document.getElementById("colorHolder").offsetTop > 0 ) {
			getImages();
			return;
		}
		if ( document.getElementById("popMenuDiv").offsetTop > 0 ) {
			getImages();
			return;
		}
	}
	$swfCounter = 0;
	for ( $ii = 0; $ii < 2; $ii ++ ) {
	$d = document.getElementsByTagName("img");
	for ( $ic in $d ) {
		if ( $d[$ic] == null ) continue;
		if ( $d[$ic].src == null ) continue;
		$url	= $d[$ic].src;
		if ( $d[$ic].className.indexOf("pop") > -1 ) $d[$ic].onclick = function anonymous() {popup(this)};
		if ( $d[$ic].src.indexOf("www.youtube.com") > -1 ) {
			$d[$ic].parentNode.innerHTML = "<div class='youtubeDiv' style='width: 425; height: 344'><object width='425' height='344'><param name='movie' value='" + $url + "'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='" + $url + "' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='425' height='344'></embed></object></div>";
			continue;
		}
		if ( supervisor > 0 ) {
			if ( $d[$ic].offsetWidth > 75 ) {
				$d[$ic].onmouseup = function anonymous() {findstyle(this)};
			}
		}
		if ( $d[$ic].src.indexOf(".swf") == -1 ) continue;
		flashId = "swf" + $swfCounter;
		$width	= $d[$ic].offsetWidth;
		$height = $d[$ic].offsetHeight;
		$d[$ic].parentNode.innerHTML = "<div onclick='popup(\"" + $url + "\")' id='flashcontent' style='background-color: transparent; width: " + $width + "; height: " + $height + "'></div>";
		so = new SWFObject($url, "", $width, $height , "6", "#ffffff");
		so.addParam("allowScriptAccess", "always");
		so.write("flashcontent");
		$swfCounter++;
		document.getElementById("flashcontent").style.padding = 5;
		document.getElementById("flashcontent").id = "swf_" + $swfCounter;
	}
	}
}
function getImages() {
	$d = document.getElementsByTagName("object");
	for ( $ic in $d ) {
		if ( $d[$ic]			== null ) continue;
		if ( $d[$ic].parentNode	== null ) continue;
		$d[$ic].parentNode.parentNode.innerHTML = "<img usemap='' src='" + $d[$ic].movie + "' border='0' alt='' width='" + $d[$ic].width + "' height='" + $d[$ic].height + "'>";
	}
}
function getMediaplayer($obj) {
	$standard	= "playCount=1,volume=50,AutoStart=false,AnimationAtStart=true".split(",");
	$width		= $obj.offsetWidth;
	$height		= $obj.offsetHeight;
	$mediaHtml	= "<object width='" + $width + "' height='" + $height + "' ";
	$mediaHtml	+= "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' id='mediaplayer'>";
	$mediaHtml	+= "<param name='Filename' value='" + $obj.src + "'>";
	for ( $var in $standard ) {
		if ( $standard[$var].indexOf("=") < 0 ) continue;
		$m		= $standard[$var].split("=");
		if ( $m[0].toLowerCase() == "autoStart" ) $mg = false;
		$mediaHtml	+= "<param name='" + $m[0] + "' value='" + $m[1] + "'>\n";
	}
	$mediaHtml += "<embed type='application/x-mplayer2' ";
	$mediaHtml += "pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/' ";
	$mediaHtml += "width='" + $width + "' ";
	$mediaHtml += "height='" + $height + "' ";
	$mediaHtml += "src='" + $obj.src + "' ";
	$mediaHtml += "filename='" + $obj.src + "' ";
	for ( $var in $standard ) {
		if ( $standard[$var].indexOf("=") < 0 ) continue;
		$m		= $standard[$var].split("=");
		$mediaHtml	+= "<param name='" + $m[0] + "' value='" + $m[1] + "'>\n";
	}
	$mediaHtml += "</embed>";
	$mediaHtml += "</object>";
	if ( document.all ) {
		$obj.outerHTML = $mediaHtml;
	} else {
		$obj.parentNode.innerHTML = $mediaHtml;
	}
}
function getYouTube($obj) {
	$mediaHtml =  "<object width='" + $obj.width + "' height='" + $obj.height + "'><param name='movie' value='" + $obj.src + "'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='" + $obj.src + "' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='" + $obj.width + "' height='" + $obj.height + "'></embed></object>";
	if ( document.all ) {
		$obj.outerHTML = $mediaHtml;
	} else {
		$obj.parentNode.innerHTML = $mediaHtml;
	}
}
//<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/KXUQzmaFnPM&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/KXUQzmaFnPM&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
function popdia($obj) {
	if ( document.all ) {
		$height = document.getElementById("diaTd").offsetHeight;
	} else {
		$height = document.getElementById("diaTd").offsetHeight-40;
	}
	document.getElementById("diadoek").style.width = "";
	document.getElementById("diadoek").src = $obj.src;
	while ( document.getElementById("diadoek").offsetHeight > $height ) {
		document.getElementById("diadoek").style.width = document.getElementById("diadoek").offsetWidth -10;
	}
}
$popObject = "";
function popup($obj) {
	if ( !ctrlNoClick() ) return;
	if ( typeof $obj == "object" ) {
		$url = $obj.src;
	} else if ( $obj.indexOf(".swf") > -1 ) {
		$url = $obj;
	} else {
		$url = $obj;
	}
	$ext = $url.substr($url.lastIndexOf("."));
	$alt = $url.substr($url.lastIndexOf("/")*1+1);
	$alt = $alt.substr(0, $alt.lastIndexOf("."));
	if ( typeof $obj.alt == "string" ) $alt = $obj.alt;
	while ( $alt.indexOf("-") > -1 ) $alt = $alt.replace("-", " ");
	$html = "<table id='popTbl' cellpadding='0' cellspacing='2' border='0' style='background-color: #cccccc'><tr>";
	$html += "<td style='text-align: right; background-image: url(z-img/back/bluebar.gif); cursor: hand' onmousedown='onoff(this, event)' onmouseup='endDrag()'>";
	$html += "<table cellpadding='0' cellspacing='0' border='0' style='width: 100%'><tr>";
	$html += "<td onmousedown='onoff(this, event)' onmouseup='endDrag()' style='width: 100%; color: #cccccc; font-weight: bolder' disabled='true'>&nbsp;" + $alt + "</td>";
	if ( $url.indexOf("z-eddy") > -1 ) {
		$html += "<td style='padding: 2'><img src='z-img/icoons/delete.gif' alt='verwijder bijlage' onclick='delBijlage(\"" + $url + "\")'></td>";
	}
	$html += "<td style='padding: 2'><img src='z-img/icoons/closered.jpg' alt='close' border='0' onclick='closePop(this);closeMsg()'></td>";
	$html += "</tr></table>";
	$html += "</td>";
	$html += "</tr><tr>";
	$e = ".jpg.png.gif.swf.jpeg.bmp";
	if ( $url.indexOf(".swf") > - 1) {
		$html += "<td><div id='flashcontent' style='background-color: #ffffff; width: 278; height: 254'></div></td>";
	} else if ( $e.indexOf($ext) > -1 ) {
		$html += "<td><img src='" + $url + "' border='0' alt='" + $alt + "'></td>";
	} else {
		$html += "<td><iframe width='500' height='300' src='" + $url + "'></iframe></td>";
	}
	$html += "</tr></table>";
	getImages();
	document.getElementById("popDiv").innerHTML = $html;
	// size
	setBlack(true);
	//window.setTimeout("sizer()", 1000);
	document.getElementById("popDiv").style.width = "";
	document.getElementById("popDiv").style.height = "";
	$xc		= document.body.offsetWidth;
	$yc		= document.body.offsetHeight;
	$xp		= document.getElementById("popDiv").offsetWidth;
	$yp		= document.getElementById("popDiv").offsetHeight;
	$left	= Math.floor(($xc - $xp) / 2);
	$top	= Math.floor(($yc - $yp) / 2);
	document.getElementById("popDiv").style.left	= document.body.scrollLeft+$left;
	document.getElementById("popDiv").style.top		= document.body.scrollTop+$top;
	document.getElementById("contentDiv").disabled	= true;
	document.getElementById("popDiv").style.zIndex	= $zIndex;
	if ( document.getElementById("popDiv").offsetTop < 0 ) {
		document.getElementById("popDiv").style.top = 0;
	}
	if ( $yp > $yc ) {
		document.getElementById("popDiv").style.overflowY = "scroll";
		document.getElementById("popDiv").style.height = $yc;
	} else document.getElementById("popDiv").style.overflowY = "visible";
	$zIndex++;
	if ( $url.indexOf(".swf") > - 1) {
		flashId = "flashcontent";
		so = new SWFObject($url, "", 278, 254 , "6", "#000000");
		so.addParam("allowScriptAccess", "always");
		so.write("flashcontent");
		$swfCounter++;
		document.getElementById("flashcontent").id = "";
	}
}
function sizer() {
	document.getElementById("popDiv").style.width = "";
	document.getElementById("popDiv").style.height = "";
	$xc		= document.body.offsetWidth;
	$yc		= document.body.offsetHeight;
	$xp		= document.getElementById("popDiv").offsetWidth;
	$yp		= document.getElementById("popDiv").offsetHeight;
	$left	= Math.floor(($xc - $xp) / 2);
	$top	= Math.floor(($yc - $yp) / 2);
	document.getElementById("popDiv").style.left	= document.body.scrollLeft+$left;
	document.getElementById("popDiv").style.top		= document.body.scrollTop+$top;
	document.getElementById("contentDiv").disabled	= true;
	document.getElementById("popDiv").style.zIndex	= $zIndex;
	if ( document.getElementById("popDiv").offsetTop < 0 ) {
		document.getElementById("popDiv").style.top = 0;
	}
	if ( $yp > $yc ) {
		document.getElementById("popDiv").style.overflowY = "scroll";
		document.getElementById("popDiv").style.height = $yc;
	} else document.getElementById("popDiv").style.overflowY = "visible";
	$zIndex++;
}
function startLoading($txt) {
	if ( supervisor < 1 ) {
		if ( document.getElementById("loadBar").value == "off" ) return;
	}
	setBlack(true);
	if ( typeof $txt != "string" ) $txt = "loading.....";
	if ( document.getElementById("loadDiv").offsetTop > 0 ) return;
	document.getElementById("loadTxt").innerHTML = $txt;
	document.getElementById("useDiv").innerHTML = $txt;
	document.getElementById("loadImg").style.width = 1;
	document.getElementById("loadDiv").style.zIndex = $zIndex;
	$zIndex++;
	document.getElementById("loadDiv").style.top = 50 + document.body.scrollTop;
	$blue = window.setInterval("setBlue()", 1);
}
function stopLoading() {
	setBlack(false);
	//$dnr["opa"] = window.setInterval("opacity()", 1);
	window.clearInterval($blue);
	document.getElementById("loadDiv").style.top = -10000;
	document.getElementById("useDiv").innerHTML = "&nbsp;";
}
$opa = 60;
function setBlack($h) {
	if ( $h ) {
		document.getElementById("useDiv").style.left = document.body.scrollLeft;
		document.getElementById("useDiv").style.top = document.body.scrollTop;
		if ( document.all && document.body.scroll != "no" ) {
			document.getElementById("useDiv").style.width = document.body.offsetWidth-23;
		} else {
			document.getElementById("useDiv").style.width = document.body.offsetWidth;
		}
		document.getElementById("useDiv").style.height = document.body.offsetHeight-5;
		document.getElementById("useDiv").style.zIndex = 1;
	} else {
		document.getElementById("useDiv").style.top = -10000;
		document.getElementById("useDiv").style.width = 1;
		document.getElementById("useDiv").style.height = 1;
		document.getElementById("useDiv").style.filter = "alpha(opacity=60)";
		document.getElementById("contentDiv").style.visibility = "visible";
	}
}
function opacity() {
	document.getElementById("useDiv").style.filter = "alpha(opacity=" + $opa + ")";
	$opa -= 10;
	if ( $opa < 1 ) {
		window.clearInterval($dnr["opa"]);
		$opa = 60;
		setBlack(false);
	}
}
function closePop() {
	setBlack(false);
	document.getElementById("popDiv").style.overflowY = "visible";
	document.getElementById("contentDiv").disabled = false;
	document.getElementById("popDiv").innerHTML = "&nbsp;";
	document.getElementById("popDiv").style.top = -10000;
	document.getElementById("popDiv").style.height = 1;
	document.getElementById("popDiv").style.width = "";
	document.getElementById("popDiv").style.height = "";
	getMovies();
}
function closeMsg() {
	if ( document.getElementById("bijlagen") != null ) document.getElementById("bijlagen").selectedIndex = 0;
}
