

function getQueryArray() {
	var ThisQueryArray = new Array();
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    
    var IndexName = pair[0];
    var VarValue = pair[1];
    
    ThisQueryArray[IndexName] = VarValue;	
    	
  } 
  return(ThisQueryArray);
}
var QueryStringArray = getQueryArray();



function SearchArray(Needle,Haystack) {
var SearchResult = "failure";

		for (var i = 0; i < Haystack.length; i++) {
		
			if (Haystack[i] == Needle) {
				SearchResult = "success";
			}
		}
		
	if (SearchResult == "succes") {
	
		return true;
		
	} else {
	
		return false;
		
	}
	
} //function SearcArray
 

// *******************************************************************************************

function getAbsoluteLeft(objectId) {
// Get an object left position from the upper left viewport corner
// Tested with relative and nested objects
o = document.getElementById(objectId)
oLeft = o.offsetLeft            // Get left position from the parent object
while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
oParent = o.offsetParent    // Get parent object reference
oLeft += oParent.offsetLeft // Add parent left position
o = oParent
}
// Return left postion
return oLeft
}

function getAbsoluteTop(objectId) {
// Get an object top position from the upper left viewport corner
// Tested with relative and nested objects
o = document.getElementById(objectId)
oTop = o.offsetTop            // Get top position from the parent object
while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
oParent = o.offsetParent  // Get parent object reference
oTop += oParent.offsetTop // Add parent top position
o = oParent
}
// Return top position
return oTop
}


if (QueryStringArray['module'] == "pixilator") {

	var PathTo_gfxpixi = "../";

} else {
	
	var PathTo_gfxpixi = "../";

}
	function ImageOverlay_onmouseover(ThisOverlayID,Transparency,imagename,title,description,ProductionDate,Production,Editor,Camera,Sound,showthumb,height,SiteID,PageID,MovieFilename,FilmplayerID,PlayerType) {
	showMovietrail(imagename,title,description,ProductionDate,Production,Editor,Camera,Sound,showthumb,height,SiteID,PageID,MovieFilename,FilmplayerID,PlayerType);
	
	var MozzDigit = Transparency/100;

	document.getElementById(ThisOverlayID).innerHTML = "<a href='index.php?SiteID=" + SiteID + "&PageID=" + PageID + "&MovieFilename=" + MovieFilename + "&PlayMovie=true#player" + FilmplayerID + "'><img style='filter:alpha(opacity=" + Transparency + "); -moz-opacity:" + MozzDigit + ";' src='" + PathTo_gfxpixi + "gfxpixi/MoviePlayer/Player" + PlayerType + "_MovieThumbnailOverlay_Hover.gif' alt='' width='60' height='60' hspace='10' border='0' onmouseout=\"ImageOverlay_onmouseout('" + ThisOverlayID + "','" + Transparency + "','" + imagename + "','" + title + "','" + description + "','" + ProductionDate + "','" + Production + "','" + Editor + "','" + Camera + "','" + Sound + "','" + showthumb + "',231,'" + SiteID + "','" + PageID + "','" + MovieFilename + "','" + FilmplayerID + "','" + PlayerType + "')\"></a>";
	
	}

	function ImageOverlay_onmouseout(ThisOverlayID,Transparency,imagename,title,description,ProductionDate,Production,Editor,Camera,Sound,showthumb,height,SiteID,PageID,MovieFilename,FilmplayerID,PlayerType) {
	var MozzDigit = Transparency/100;
	hideMovietrail();
	
	document.getElementById(ThisOverlayID).innerHTML = "<img style='filter:alpha(opacity=" + Transparency + "); -moz-opacity:" + MozzDigit + ";' src='" + PathTo_gfxpixi + "gfxpixi/MoviePlayer/Player" + PlayerType + "_MovieThumbnailOverlay.gif' alt='' width='60' height='60' hspace='10' border='0' onmouseover=\"ImageOverlay_onmouseover('" + ThisOverlayID + "','" + Transparency + "','" + imagename + "','" + title + "','" + description + "','" + ProductionDate + "','" + Production + "','" + Editor + "','" + Camera + "','" + Sound + "','" + showthumb + "',231,'" + SiteID + "','" + PageID + "','" + MovieFilename + "','" + FilmplayerID + "','" + PlayerType + "');\" >";

	}

//
function CreateImageOverlay(ImageContainerID,Transparency,imagename,title,description,ProductionDate,Production,Editor,Camera,Sound,showthumb,height,BASE_URL,SiteID,PageID,MovieFilename,FilmplayerID,PlayerType) {

var MozzDigit = Transparency/100;

var ThisOverlayID = "overlay_" + ImageContainerID;

var ContainerTop = getAbsoluteTop(ImageContainerID);
var ContainerLeft = getAbsoluteLeft(ImageContainerID);
ContainerLeft = ContainerLeft - 10;
ContainerTop = ContainerTop + 5;

//var ImageOverlayClass = "Player" + PlayerType + "_MovieThumbnailOverlay";
//var ImageOverlayHoverClass = "Player" + PlayerType + "_MovieThumbnailOverlay_Hover";


var ImageOverlay = document.createElement("div");
	ImageOverlay.setAttribute("id",ThisOverlayID);
	//ImageOverlay.setAttribute("class",ImageOverlayClass);
	//ImageOverlay.setAttribute("className",ImageOverlayClass);
	
	ImageOverlay.style.zIndex = "30";	
	ImageOverlay.style.position = "absolute";
	ImageOverlay.style.top = ContainerTop; 
	ImageOverlay.style.left = ContainerLeft; 
	
	document.body.appendChild(ImageOverlay);
	
	
		
	
	
document.getElementById(ThisOverlayID).innerHTML = "<img style='filter:alpha(opacity=" + Transparency + "); -moz-opacity:" + MozzDigit + ";' src='" + PathTo_gfxpixi + "gfxpixi/MoviePlayer/Player" + PlayerType + "_MovieThumbnailOverlay.gif' alt='' width='60' height='60' hspace='10' border='0' onmouseover=\"ImageOverlay_onmouseover('" + ThisOverlayID + "','" + Transparency + "','" + BASE_URL + "/media/thumbnails/" + imagename + "','" + title + "','" + description + "','" + ProductionDate + "','" + Production + "','" + Editor + "','" + Camera + "','" + Sound + "','" + showthumb + "',231,'" + SiteID + "','" + PageID + "','" + MovieFilename + "','" + FilmplayerID + "','" + PlayerType + "');\">";


}


// *******************************************************************************************


var M_offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var M_displayduration=0; //duration in seconds image should remain visible. 0 for always.
var M_currentimageheight = 270;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="trailMovieid" style="position:absolute; top:400; left:300; z-index:100;">');
	document.write('</div>');
}

function M_gettrailobj(){
if (document.getElementById)
return document.getElementById("trailMovieid").style
else if (document.all)
return document.all.trailMovieid.style
}

function M_gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailMovieid")
else if (document.all)
return document.all.trailMovieid
}


function M_truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function M_showMovietrailsmall(imagename, height) {

	if (height > 0){
		M_currentimageheight = height;
	}

	document.onmousemove=M_followmouse;
	newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;">';
	newHTML = newHTML + '<div align="center" style="padding: 2px 2px 2px 2px;"><img src="' + imagename + '" border="0"></div>';
	newHTML = newHTML + '</div>';

	M_gettrailobjnostyle().innerHTML = newHTML;
	M_gettrailobj().visibility="visible";
}


function showMovietrail(imagename,title,description,ProductionDate,Production,Editor,Camera,Sound,showthumb,height,SiteID,PageID,MovieFilename,FilmplayerID,PlayerType){

	if (height > 0){
		M_currentimageheight = height;
	}

	document.onmousemove=M_followmouse;

	cameraHTML = '';
	newHTML = '<div class="Player' + PlayerType + '_MovieHoverContainer">';
	
	
	
	
	if (arguments.length > 1) { 
	
		newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieHoverTitleBox">' + title + '</div>';
		newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieHoverDescriptionBox">' + description + '</div>';
		
		
		
	
	}
	/*
	if (ratingnumber == 0){
		ratingaverage = 0;
	}

	if (arguments.length > 1) { 
	
		for(x = 1; x <= 5; x++){
	
			if (ratingaverage >= 1){
				cameraHTML = cameraHTML + '<img src="http://www.istockphoto.com/images/camera_1.gif">';
			} else if (ratingaverage >= 0.5){
				cameraHTML = cameraHTML + '<img src="http://www.istockphoto.com/images/camera_05.gif">';
			} else {
				cameraHTML = cameraHTML + '<img src="http://www.istockphoto.com/images/camera_0.gif">';
			}
		
			ratingaverage = ratingaverage - 1;
	
		}
	
		cameraHTML = cameraHTML + ' (' + ratingnumber + ' Review';
		if ( ratingnumber != 1 ) cameraHTML += 's';
		cameraHTML = cameraHTML + ')';
	
		newHTML = newHTML + '<h2>' + title + '</h2>';
		newHTML = newHTML + 'Rating: ' + cameraHTML + '<br/>';
		newHTML = newHTML + description + '<br/>';
	}
	*/
	
	if (showthumb > 0 || arguments.length == 1){
	
	newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieHoverImageBox" ><img src="' + imagename + '" border="0" width="40"></div>';
	

	
	} 
	
	// MovieInfo
		newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieHoverInfoBox">';
		
		if (ProductionDate) {
	
			newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieInfo_ProductionDate">Dato: ' + ProductionDate + '</div>';
		
	
		}
		
		if (Production) {
		
			newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieInfo_Production">Produceret af: ' + Production + '</div>';
		}
		
		if (Editor) {
		
			newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieInfo_Editor">Tilrettel&aelig;ggelse: ' + Editor + '</div>';
		}
		
		if (Camera) {
		
			newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieInfo_Camera">Kamera: ' + Camera + '</div>';
		}
		
		if (Sound) {
		
			newHTML = newHTML + '<div class="Player' + PlayerType + '_MovieInfo_Sound">Lyd: ' + Sound + '</div>';
		}
		
		newHTML = newHTML + '</div>';
	
	
	
	

	
	newHTML = newHTML + '</div>'; //Player1_MovieHoverContainer
	

	M_gettrailobjnostyle().innerHTML = newHTML;

	M_gettrailobj().visibility="visible";

}


function hideMovietrail(){

M_gettrailobj().visibility="hidden"
   //document.onmousemove=""
    M_gettrailobj().left="-500px"

}

function M_followmouse(e){

var TrailBox = M_gettrailobjnostyle().innerHTML;


	var xcoord=M_offsetfrommouse[0]
	var ycoord=M_offsetfrommouse[1]

	var docwidth=document.all? M_truebody().scrollLeft+M_truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(M_truebody().scrollHeight, M_truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	M_gettrailobjnostyle().innerHTML = 'A = ' + M_truebody().scrollHeight + '<br>B = ' + M_truebody().clientHeight;
	//} else {
	//	M_gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}
	
	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 380){
			xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
			//xcoord += e.pageX;
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (M_currentimageheight + 110)){
			//ycoord += e.pageY - Math.max(0,(110 + M_currentimageheight + e.pageY - docheight - M_truebody().scrollTop));
			ycoord += e.pageY;
		
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 380){
			xcoord = event.clientX + M_truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
			//xcoord += M_truebody().scrollLeft+event.clientX
		} else {
			xcoord += M_truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (M_currentimageheight + 110)){
			//ycoord += event.clientY + M_truebody().scrollTop - Math.max(0,(110 + M_currentimageheight + event.clientY - docheight));
			ycoord += M_truebody().scrollTop + event.clientY;
		} else {
			ycoord += M_truebody().scrollTop + event.clientY;
		}
	}
	
	//alert('Left: ' + xcoord + 'TOP: ' + ycoord);
	
	var docwidth=document.all? M_truebody().scrollLeft+M_truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(M_truebody().scrollHeight, M_truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	
	
	M_gettrailobj().left=xcoord+"px"

	M_gettrailobj().top=ycoord+"px"
	
}


