var hasRotated = false;
var lastPlayedId = false;
var displayDate = false;
var comId = 0;
var comTitle = '';
var comInfo = '';
var comEndPlakat = 0;
var endplakatId = 0;
var hasCountedSp = 0;
var countedUrls = 0;
var sponsorCounted = 0;
var sponsorUrl = '';
var sponsorId = 0;


function openNewsAlertWin() {
	window.location='maillist.php?sid='+sid;
}

function setInfo(_clip) {
	if (_clip.titel==null) 
		return null;
		
	//postpend dato in front of titel if it should be shown
	if (displayDate) {
		dispTitel = _clip.oprettetDen + " " + _clip.titel; 
	} else {
		dispTitel = _clip.titel;
	}

	//short titel Length so it won't break
	var titelLength = 60;
	if (dispTitel.length>titelLength) {
		dispTitel = dispTitel.substring(0, titelLength-3) + '...';
	}

	
	var infoHead = document.getElementById('infoHead');
	
	var header = document.createTextNode(dispTitel);
	infoHead.appendChild(header);
	
	var infoCont = document.getElementById('infoBody'); 
	var lineBreak = document.createElement("br");
	//[br] skal erstattes med html linieskift



// istedet er følgende indsat

	var txt = document.createTextNode(_clip.info);
	infoCont.appendChild(txt);

}


function clearInfo() {
	
	var head = document.getElementById('infoHead'); 
	
	while ( head.hasChildNodes() ) {
		head.removeChild(head.firstChild);
	}
	
	var body = document.getElementById('infoBody'); 
	
	while (body.hasChildNodes()) {
		body.removeChild(body.firstChild);
	}
	
}

function setTitle(_clip) {
	window.status=_clip.titel;
	var titelCont = document.getElementById('titelCont'); 
	var header = document.createTextNode(_clip.titel);
	 titelCont.appendChild(header);
}

function clearTitle() {

	var titel = document.getElementById('titelCont'); 
	while (titel.hasChildNodes() ) {
		titel.removeChild(titel.firstChild);
	}
	
}

function countShowSponsor(sponsorurl) {

	//html = '<iframe style="display:none" src="counter.php?loc=countShowSponsor&url=' + sponsorurl + '&sid=' + sid + '&req_uri=' + req_uri + '"></iframe>';

	//document.getElementById('counterCont').innerHTML=html;
}

function countShow(_clip) {
	//alert("TEST"+_clip.id);
	hasCountedSp = _clip.type;
	//alert('counter.php?loc=countShow&id=' + _clip.id + '&sid=' + sid + '&req_uri=' + req_uri + '');
	//html = '<iframe style="display:none;" src="counter.php?loc=countShow&id=' + _clip.id + '&sid=' + sid + '&req_uri=' + req_uri + '"></iframe>';
	
	//document.getElementById('counterCont').innerHTML=html;
}


function openTipWin(clip_id) {

	popUp = window.open('../../tip.php?action=tip&id='+ clip_id, "Tip","width=450,height=524,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
}

function openThumbWin(clip_id) {
	popUp = window.open('thumbnailChooser.php?clipID='+ clip_id, "ThumbnailChooser","width=468,height=90,resizable=0,toolbar=0,scrollbars=1,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
}

function openKlagWin(clip_id) {
	popUp = window.open('tip.php?action=klag&id='+ clip_id, "Tip","width=450,height=524,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
}


function openTipWin_gammel() {
	if (!lastPlayedId) {
		alert('Du skal vælge et klip før du kan tippe en ven');
	} else {
	popUp = window.open('tip.php?id='+ lastPlayedId, "Tip","width=450,height=560,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
		//window.location='tip.php?id='+ lastPlayedId;
	}
}

function openRelatedClips() {
	popUp = window.open('relatedclips.php', "relatedclips","width=900,height=760,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
}

var counting = 0;
function runsCommercial() {
	
	try {
		var currentUrl = document.player1.currentMedia.sourceUrl;
	
	} catch (Exception) { return false; }; //netscape skal altid returnere false da den ikke kan se om een reklame kører .
	
	if(clip.type == 'live')
	{
		if (clip.url != currentUrl) {
			return true;
		}
		
		return false;		
	}		
	else if(clip.url != currentUrl.substr(41))
	{
		return true;
	}
	return false;	
}

var isSetComTitle = 0;
function infoPolle() {
	var cooptest1 = document.getElementById('testdiv').innerHTML; 

	document.getElementById('testdiv').innerHTML = document.player1.currentMedia.sourceUrl;  
	
	var cooptest2 = document.getElementById('testdiv').innerHTML;
	
	if(cooptest1 != cooptest2)
	{
		if(countedUrls>0)
		{
		countShowSponsor(document.player1.currentMedia.sourceUrl);
		sponsorCounted++;
		}
	
	countedUrls++;				
	}

	if(runsCommercial()==true) 
	{
		var c = clipObj(comId, comTitle, ' ', comInfo, true, ' ', 'com', comEndPlakat);
		if (isSetComTitle == 0) 
		{
			isSetComTitle = 1;
			countShow(c);
		}
		setTimeout("infoPolle()",300);
		return;
	}

}






function setAnbefal() {
	var anbefalCont = document.getElementById('tipLnk');  
	anbefalCont.innerHTML = "<INPUT TYPE=\"image\" src=\"./images/icons/anbefal.gif\" onmouseover=\"this.src='./images/icons/anbefal-over.gif'; \" 	onmouseout=\"this.src='./images/icons/anbefal.gif'\"  title=\"Anbefal dette klip\" id=\"tipLnk\" class=\"lnk\" OnClick=\"openTipWin();\" Onfocus=\"this.blur()\">";
}

function isNull(a) 
 {
      return typeof a == 'object' && !a;
 }

function countClip() {
	if (!runsCommercial()) {
		if(hasCountedSp != clip.type) {
			countShow(clip);
		}
	} else {
		setTimeout("countClip()",2000);
	}
}


function clipObj(_id, _titel, _url, _info, _isCommercial, _oprettetDen, _type, _endplakat) {

	obj = new Object;
	
	obj.id = _id;
	obj.titel = _titel;
	obj.url = _url;
	obj.isCommercial = _isCommercial;
	obj.oprettetDen = _oprettetDen;
	obj.info = _info;
	obj.type = _type;
	obj.endplakat = _endplakat;
	
	return obj;
}

function openfaq() {
	window.open("http://www.xstream.dk/1-110-faq.html","mm_faq","height=600, width=800, scrollbars=yes");
}

function openXstream() {
	window.open("http://www.xstream.dk","xstraemFaq","height=600, width=800, scrollbars=yes");
}

function openMediamakerBackendWmv( _width, _height, _player) {

	
	popUp = window.open(_player, "popUp", "top=0,left=" + ((screen.availWidth/2) - (_width / 2)) + ",width="+_width+",height="+_height+",resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
	
}

function openMediamakerFlash( _width, _height, _parameter) {

	if (_parameter==undefined) {
		_parameter="";
	}
	
	popUp = window.open("players/mediamaker_flash.php"+_parameter, "popUpFlash", "top=0,left=" + ((screen.availWidth/2) - (_width / 2)) + ",width="+_width+",height="+_height+",resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0");
	popUp.focus();
	return popUp;
	
}

function sureDelete(_id,_charName) {
	if(confirm("Er du sikker på du vil slette " + _charName +" !")) {
	 	window.location='?sLoc=del&id=' + _id;
	} else {
 		return false;
	}
}


function disableKey( _key) {
	if (	window.event ) {
		if (window.event.keyCode==_key) {
			window.event.keyCode=0;
			window.event.returnValue=false;
		}
	}
}

function cutTofit( _size, object ) {
	if (object.value.length >_size) {
		object.value=object.value.substring(0,_size);
	}
}

function blinkIt() {
 if (!document.all) return;
 else {
   for(i=0;i<document.all.tags('blink').length;i++){
      s=document.all.tags('blink')[i];
      s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
   }
 }
}

function checkClick(pos) {
	posx=pos.x;
	posy=pos.y;
	
	
	var player = document.getElementById('playerCont');  
	var xStart = player.getAttribute('offsetLeft');
	var yStart = player.getAttribute('offsetTop');
	var width  = player.getAttribute('offsetWidth');
	var height = player.getAttribute('offsetHeight');
	
	
	
	if (runsCommercial() && posx > xStart && posx < xStart+width && posy > yStart && posy < yStart + height )
		videoClick();
	
}

function openWhenComRuns() {
	
	// now we dont need to check runsCommercial, 
	
	//if (runsCommercial())
		videoClick();
}

function mouseEventHandler(mEvent) {
	obj = new Object;
	posx = 0;
	posy = 0;
	
	
  // Internet Explorer
  if (mEvent.srcElement)
  {
    
		posx = mEvent.clientX + document.body.scrollLeft;
		posy = mEvent.clientY + document.body.scrollTop;
   
    
  }
  // Netscape and Firefox
  else if (mEvent.target)
  {
		posx = mEvent.pageX;
		posy = mEvent.pageY;   
  	
  }
  obj.x =  posx;
  obj.y =  posy;
  
  //checkClick(obj);
}

var hasCounted = 0;
	
function videoClick() {
	
	//if (runsCommercial()) {
		if (!isPlaying()) {	
			return;
		}
		
		// we check the url being played and confirm whether we have this URL and then fetch the link and increment the hits
		
		var currentUrl = document.player1.currentMedia.sourceUrl;
		
		// get the link based on this Url
		recordID = fetchLinkAndId(currentUrl);
	
		if(recordID != -1) { // check if the no of hits is less than the max allowed hits
			
			if(DATA[recordID][4] > 0) {
			
				if(DATA[recordID][3] < DATA[recordID][4]) {
				
					talAnnonce(DATA[recordID][0]); // pass the commercial id to increment the hits on it
					
					url = DATA[recordID][2];
					
					var annonceLink = ((url.indexOf('http://') != -1) || (url.indexOf('https://') != -1)) ? (url) : ('http://' + url);
				
					var _width = window.screen.width - 10;
					var _height = window.screen.height - 202;
					var startX = 0;
					var startY = 0;
					
					newwindow=window.open(annonceLink,'_blank','height='+ _height +',width='+ _width +',left='+ startX +',top='+ startY +',resizable=yes,scrollbars=yes,toolbar=yes,status=yes,menubar=yes,resizable=yes,location=yes');
					window.focus();
				
				}
				
			} else if(DATA[recordID][4] == 0) {
				
					talAnnonce(DATA[recordID][0]); // pass the commercial id to increment the hits on it
					
					url = DATA[recordID][2];
					
					var annonceLink = ((url.indexOf('http://') != -1) || (url.indexOf('https://') != -1)) ? (url) : ('http://' + url);
				
					var _width = window.screen.width - 10;
					var _height = window.screen.height - 202;
					var startX = 0;
					var startY = 0;
					
					newwindow=window.open(annonceLink,'_blank','height='+ _height +',width='+ _width +',left='+ startX +',top='+ startY +',resizable=yes,scrollbars=yes,toolbar=yes,status=yes,menubar=yes,resizable=yes,location=yes');
					window.focus();
				
				
			}
		}
		
		//visAnnonce(); -> disabled
}

// this function fetches the record unique ID which has the id and link based on the url of the clip

function fetchLinkAndId(URL) {
	
	var recordID = -1;
	
	for(i = 0; i < DATA.length; i++) {
		
		if(URL.indexOf(DATA[i][1]) != -1) { // this is the record :)
			
			recordID = i;			
			break;
		
		}
	}
	
	return recordID;
	
}


// talAnnounce updated to check on the comId which is being played at the moment

function talAnnonce(comID)  {
	
	// tjekker om der er et sponsor ID
	if(sponsor_id.innerHTML != "") {
		comId = sponsor_id.innerHTML;
	}
	
	if(comID>0) 
	{
	
		html = '<iframe style="display:none" src="counter.php?loc=countClick&id=' + comID + '&sid=' + sid + '&req_uri=' + req_uri + '"></iframe>';
		document.getElementById('counterCont').innerHTML=html; 
		
	}
}

function isPlaying() {
	if (document.player1.playState==-1)
		return false;
	return true;
}

// if the current clip is of type radio
// hide player and show a picture

function switchBackgroundImage() {
	
	if ( !runsCommercial() ) {		
		hidePlayer();
		scaleScreener();
		showImage();
		centerImage();
		
	} else {
		showPlayer();
		hideImage();		
	}
	
	if (screener != null ) {
		setTimeout("switchBackgroundImage()",500);
	} 
}

function centerImage() {
	
	//center the image using padding
	var widthOffset = (document.player1.width - screenerWidth) / 2;
	var heightOffset = (document.player1.height - screenerHeight) / 2;
	
	
	canvas = document.getElementById('screenerImg');
	
	if (canvas.height<540) {
		document.getElementById('screenerImg').style.top= heightOffset;
		document.getElementById('screenerImg').style.left = widthOffset;
		
	}
}

function showImage() {
	
	canvas = document.getElementById('screenerImg');
	canvas.src = screener.src;
	canvas.width= screenerWidth;
	canvas.height= screenerHeight;	
}

function hideImage() {
	canvas = document.getElementById('screenerImg');
	canvas.src = screener.src;
	canvas.width= 0;
	canvas.height= 0;	
}

function hidePlayer() {
	
	if (document.player1.style.visibility != 'hidden' ) {
		document.player1.style.visibility='hidden';
	}
}


function showPlayer() {
	
	if (player1.style.visibility != '' ) {
		player1.style.visibility='';
	}
}

function restorePlayer() {
	if (document.player1.width == 0 ) {
		document.player1.width = playerWidth;
		document.player1.height = playerHeight;
	}
}

// hvis billedet er mindre en 320*240, rezise billedet op til 320*240 uden at skalere det.
// hvis billedet er større en 320*240,  rezise billedet op til 512*384 uden at skalere det.
// standarg jpg skal dog altid skalers til max størrlese.

function scaleScreener() {
	
	if ( screenerWidth<=320 && screenerHeight<=240 && screener.src.indexOf('standard.jpg')==-1) {
		
		wScale = 320/screenerWidth;
		hScale = 240/screenerHeight;
		
	} else {
		wScale = 512/screenerWidth;
		hScale = 384/screenerHeight;
		
	}
	if (wScale < hScale) {
		scale	= wScale;
	} else {
		scale	= hScale;
	}
	screenerWidth = screenerWidth*scale;
	screenerHeight = screenerHeight*scale;
	
}

function detectBrowser() {
  if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') ) {
    if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') ) {
      $browser = 'Netscape (Gecko/Netscape)';
    } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )   {
      $browser = 'Mozilla Firefox (Gecko/Firefox)';
    } else {
      $browser = 'Mozilla (Gecko/Mozilla)';
    }
  } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) {
    if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') )  {
      $browser = 'Opera (MSIE/Opera/Compatible)';
    } else {
      $browser = 'Internet Explorer (MSIE/Compatible)';
    }
  } else {
    $browser = 'Other browsers';
  }
  return $browser;
} //end func detect browser

function clearTnBorders() {
	for (i=0,n=document.images.length;i<n;i++){
		if (document.images[i].className == "thumb_current" || document.images[i].className == "thumb"){
			document.images[i].style.border = "2px solid white";
		}
	}
}

function toggleSplashDiv(id,flagit) {
	if (flagit=="1"){
		if (document.layers)
			document.layers[''+id+''].visibility = "show"
		else if (document.all)
			document.all[''+id+''].style.visibility = "visible"
		else if (document.getElementById)
			document.getElementById(''+id+'').style.visibility = "visible"
	} else	if (flagit=="0"){
		if (document.layers)
			document.layers[''+id+''].visibility = "hide"
		else if (document.all)
			document.all[''+id+''].style.visibility = "hidden"
		else if (document.getElementById)
			document.getElementById(''+id+'').style.visibility = "hidden"
	}
}

function changeInfo(func) {
	
	if( func == "stop" ) {
		document.getElementById("klikk_her").innerHTML="klikk og se...";
		document.getElementById("info_titel").style.visibility='hidden';
		document.getElementById("info_complete").style.visibility='hidden';
		document.getElementById("info_related").style.visibility='hidden';
		document.getElementById("info_url").style.visibility='hidden';
	} else {
		document.getElementById("klikk_her").innerHTML="";
		document.getElementById("info_titel").style.visibility='visible';
		document.getElementById("info_complete").style.visibility='visible';
		document.getElementById("info_related").style.visibility='visible';
		document.getElementById("info_url").style.visibility='visible';
	}
}

// we pass additional parameters from the SESSION in mediamaker_cliplist so as to fix 
// that small problem <IE random script error>



/*function include(file)   
{   
  
  var script  = parent.xstream_cliplist.document.createElement('script');   
  script.src  = file;   
  script.type = 'text/javascript';   
  script.defer = true;   
  
  parent.xstream_cliplist.document.getElementsByTagName('head').item(0).appendChild(script);   
  
}   


function addJavascript(jsname) {
	
	var th = parent.xstream_cliplist.document.getElementsByTagName('head')[0];
	var s = parent.xstream_cliplist.document.createElement('script');
	
	s.setAttribute('type','text/javascript');
	s.setAttribute('src',jsname);
	
	th.appendChild(s);

} */


function auto_play(clipID, autoplay, compList, prevID, current_page, total_pages, catIDx) { // method called on auto play 
			
		//addJavascript("scripts/global.js");
		//include("scripts/global.js");
		
		
	
		/*setClipsPerPage(parent.xstream_cliplist.document.getElementById("clips_per_page").value);s
		setClipsRemainingPerPage(parent.xstream_cliplist.document.getElementById("clips_remaining_per_page").value);
		setCurrentPage(parent.xstream_cliplist.document.getElementById("current_page").value);
		setCategoryID(parent.xstream_cliplist.document.getElementById("categoryID").value);
		setSearchTerm(parent.xstream_cliplist.document.getElementById("search_term").value);
		setTotalPages(parent.xstream_cliplist.document.getElementById("total_pages").value);
		setClipList(parent.xstream_cliplist.document.getElementById("clip_list").value);
		setClipListComplete(parent.xstream_cliplist.document.getElementById("clip_list_complete").value);*/
		
		
				
		if(autoplay == "stop") {
		
			if(parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility == "visible") {
	
				parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility = "hidden";
				
				// to ensure we could check the onmouseout and onmouseover events
				// ??
			}		
		
		}
		
		/*http_request = '';
		
			if (window.XMLHttpRequest) { // Mozilla, Safari, ...
				
				try {
			    http_request = new XMLHttpRequest();
				} catch (e) {
					
					alert("exception in firefox :: "+e);
					
				}

			} else if (window.ActiveXObject) { // IE
				
				try {
			    http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
					
					alert("exception in explorer :: "+e);
					
				}
			
			}*/
	
	if(autoplay == "start") {
	
		if(parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility == "hidden") {
			
			parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility = "visible";			
			
		} else {
			
			parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility = "hidden";
			
		}
		
	}
			
	// converting the ajax call to clean straight
	
	if(parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility == "visible") { 
		
		//document.getElementNodeById(”message”);
		completelist = parent.xstream_cliplist.document.getElementById("clip_list_complete").value;
		
		setElements(completelist);
		
		current_page = parent.xstream_cliplist.document.getElementById("current_page").value;
		//alert("current page :: "+current_page);
		//total_pages = tags[2];
		total_pages = parent.xstream_cliplist.document.getElementById("total_pages").value;
		//alert("total pages :: "+total_pages);
		//catID = tags[3];
		catID = parent.xstream_cliplist.document.getElementById("categoryID").value;
		//alert("cat id :: "+catID);
		
		parent.xstream_cliplist.document.getElementById("kliplist_div1_"+prevID).style.background = '#DFE7F1';
		
		parent.xstream_cliplist.document.getElementById("kliplist_div1_"+prevID).onmouseout = function() {
			
			parent.xstream_cliplist.document.getElementById("kliplist_div1_"+prevID).style.backgroundColor = '#DFE7F1';
			
		}
		
		parent.xstream_player.location = "mediamaker_player.php?id="+prevID+"&selectCategoryId="+catID;
		
		
	
	}
	
	
	
	
// callback
	/*http_request.onreadystatechange = function() {
	
 	if (http_request.readyState == 4) {
			
		if (http_request.status == 200 && autoplay != "stop") {
				
				
				//alert(http_request.responseText);
			
				response = http_request.responseXML;         	
               	
            	//tags = extractTagsFromResponse(response, prevID, current_page, total_pages, catIDx); -> disabled now
				
				//completelist = tags[4];
				completelist = getClipListComplete();
					
				//alert("completelist :: "+completelist);
				
				if(parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility == "visible") {
				
				//tags = extractTagsFromResponse(response);
				
				// do one more thing here. 
				// get the complete list, leave the first element and for the rest of the Ids
				// set the onmouseover and onmouseout events and set the background color 
		
				setElements(completelist);
				
				//prevID = tags[0];
				
				//current_page = tags[1];
				current_page = getCurrentPage();
				//alert("current page :: "+current_page);
				//total_pages = tags[2];
				total_pages = getTotalPages();
				//alert("total pages :: "+total_pages);
				//catID = tags[3];
				catID = getCategoryID();
				//alert("cat id :: "+catID);
				
				parent.xstream_cliplist.document.getElementById("kliplist_div1_"+prevID).style.background = '#DFE7F1';
				
				parent.xstream_cliplist.document.getElementById("kliplist_div1_"+prevID).onmouseout = function() {
					
					parent.xstream_cliplist.document.getElementById("kliplist_div1_"+prevID).style.backgroundColor = '#DFE7F1';
					
				}
				
				parent.xstream_player.location = "mediamaker_player.php?id="+prevID+"&selectCategoryId="+catID;
				
            	} // if we opt to autplay 
            	

            	
            	  	
			}

		}

	}
	
	
	http_request.open('POST', 'manage_clip_play_new.php', true);
	//http_request.open('POST', 'test1.php', true);
	
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	
	if(autoplay == "stop") { // set the formatting of the list
		
		reformatClipList(clipID,compList);
	
	}
	
	if(parent.xstream_cliplist.document.getElementById("auto_afspil_img").style.visibility == "visible") {
		
		//alert("visible");
					
		http_request.send('increment=no&visible=yes&from=linkpage');	
	
	} else {
		
		//alert("invisible");
				
		http_request.send('increment=no&visible=no&from=linkpage');	
	}
	
	
	return false; */
		
}

// method to handle IE and other browsers xml DOM response handling

function extractTagsFromResponse(response, prevIDp, current_pagep, total_pagesp, catIDp) {
	
	tags = new Array();
	
	// check if the browser is IE or not 
	//browser = checkBrowser();

	//if(browser == "IE") {
		
		for(i = 0; i < response.getElementsByTagName('result')[0].childNodes.length; i++) {
			
			if(response.getElementsByTagName('result')[0].childNodes[i].nodeType == 3) // TEXT_NODE
				continue;	
			else if(response.getElementsByTagName('result')[0].childNodes[i].nodeType == 1) { // ELEMENT_NODE
				
				// check for the node name and store in the variable
				switch(response.getElementsByTagName('result')[0].childNodes[i].nodeName) {
					
					case "prevID" : prevID = response.getElementsByTagName('result')[0].childNodes[i].firstChild.data; break;
					//case "nextID" : nextID = response.getElementsByTagName('result')[0].childNodes[i].firstChild.data; break;
					case "current_page" : current_page = response.getElementsByTagName('result')[0].childNodes[i].firstChild.data; break;
					case "total_pages" : total_pages = response.getElementsByTagName('result')[0].childNodes[i].firstChild.data; break;		
					case "selectCategoryID" : catID = response.getElementsByTagName('result')[0].childNodes[i].firstChild.data; break;			
					case "completelist" : completelist = response.getElementsByTagName('result')[0].childNodes[i].firstChild.data; break;			
					
				}
						
			}
		
		}
		
	tags[0] = prevID;
	tags[1] = current_page;
	tags[2] = total_pages;
	tags[3] = catID;
	tags[4] = completelist;
	
	return tags;
	
}

function setElements(completelist) {

	var myArray = completelist.split(' ');

	for(i = 0; i < myArray.length; i++) {
		
		// for each of the clipIDs we have to clear the background and set the onmouseover and 
		// onmouseout events
		
		if(i == 0)
			continue;
				
		parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).style.background = '#F7F8F9';
		
		// now setting the onmouseover and onmouseout events
		
		parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).onmouseout = out;
		
		parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).onmouseover = over;
		
		
	}
	
}

function out() {
	
	this.style.backgroundColor = "#F7F8F9";
	
}

function over() {
	
	this.style.backgroundColor = "#DFE7F1";

}

function reformatClipList(clipID,compList) {
	
	var myArray = compList.split(' ');
	
	for(i = 0; i < myArray.length; i++) { 
		
		if(myArray[i] == clipID) {
		
			parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).style.background = '#DFE7F1';
			parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).onmouseout = over;
			
		} else {
			
			parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).style.background = '#F7F8F9';

			parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).onmouseover = over;
			parent.xstream_cliplist.document.getElementById("kliplist_div1_"+myArray[i]).onmouseout = out;
					
		}
		
		
	}
}
