// RECYCLEZONE COMMON JS FUNCTIONS
// Chameleon Net Ltd.
// Authors: Will James, Tom Scott


// BROWSER DETECT
function Is()
{
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns4 = (this.ns && (this.major >= 4));
	this.ie   = (agent.indexOf("msie") != -1);
	this.ie4  = (this.ie && (this.major >= 4));
	this.win   = (agent.indexOf("win")!=-1);
	this.mac   = (agent.indexOf("mac")!=-1);
}
var is = new Is();



// FLASH DETECT
function showFlashOrImage(width,height,name,imgSrc,flashSrc,flashVer){
	
	var MM_contentVersion = flashVer;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	
	if (plugin) {
			
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");

		for (var i = 0; i < words.length; ++i)
		{
			if (isNaN(parseInt(words[i])))
				continue;
			var MM_PluginVersion = words[i]; 
		}

		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
		
		var e;
		
		try{
			var t = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + MM_contentVersion);
			MM_FlashCanPlay = true;
		}
		catch(e) {
			MM_FlashCanPlay = false;
		}
	}

	if (MM_FlashCanPlay) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
		document.write(' id="' + name + '" width="' + width + '" height="' + height + '">');
		document.write(' <param name="movie" value="' + flashSrc + '">'); 
		document.write(' <param name="quality" value="high">'); 
		document.write(' <embed src="' + flashSrc + '" quality=high bgcolor=#ffffff  ');
		document.write(' swliveconnect="false" width="' + width + '" height="' + height + '" name="' + name + '"');
		document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </embed>');
		document.write('</object>');
	}
	else{
		document.write('<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="' + imgSrc + '" width="' + width + '" height="' + height + '" name="' + name + '" border="0" alt="Click here to get the Flash plugin" /></a>');
	}
}



// For swapping rollover image objects

function hiLite(imgDocID, imgObjName)
{
	if( !document.images ) return
	{
		document.images[imgDocID].src = eval(imgObjName + ".src")
	}
}


// for image transparance change (used for rollovers)

function lightup(imageobject, opacity){
 if (navigator.appName.indexOf("Netscape")!=-1 && parseInt(navigator.appVersion)>=5)
    imageobject.style.MozOpacity=opacity/100;
 else if (navigator.appName.indexOf("Microsoft")!= -1 &&parseInt(navigator.appVersion)>=4)
    imageobject.filters.alpha.opacity=opacity;
}





// POP-UP WINDOWS - positions pop-up in center of screen 

var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=yes';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


// Return an item's ID value
function getId(id)
{
  return document.getElementById(id)
}
 

// swaps the content of one block with the content of another
function showIt(putThisItem, intoThisItem){ 
	var y,z;
	z = getId(putThisItem);
	y = getId(intoThisItem);
	y.innerHTML = z.innerHTML;
}

// swaps the content of one block with a string
function showIt2(string,intoThisItem){
	var string,z;
	z = getId(intoThisItem);
	z.innerHTML = string;
}

// returns an the sum of all values of a specifed input type in the specified form
function sumFormInputs (form, inputType){
	var total = 0;
	for (var e = 0; e < form.elements.length; e++) {
		if (form.elements[e].type == inputType && form.elements[e].checked) {
			total += parseInt(form.elements[e].value);
		}
	}
	return total;
}

// changes the string in the specified form input
function sendToInput(theString,theInput){ 
	var z;
	z = getId(theInput);
	z.value = theString;
}

// takes a complete path and returns just the filename
function getFilename(thePath){ 
	return thePath.substring(thePath.lastIndexOf('\\')+1);
}

// shows a delete confirmation message,sends the filename to a hidden field and submits the current form
function deleteItem(fileName, theform) {
	
	var z = getId('itemName');
	if (!confirm("This will permanently delete the selected item - do you wish to continue?"))
		return false;

	z.value = fileName;
	document.forms[0].submit();
}


// on mouseOver colour
function hiLightItem(item){
	item.style.backgroundColor='#FFD100'
}

// on mouseOut colour
function loLightItem(item){
	item.style.backgroundColor=''
}


function fadeOut(obj) {
    obj.style.filter="blendTrans(duration=1)";
	// Make sure filter is not playing.
	if ((obj.visibility != "hidden")) {
        obj.filters.blendTrans.Apply();
        obj.style.visibility="hidden";
	    obj.filters.blendTrans.Play();
	}
}

function fadeIn(obj) {
    obj.style.filter="blendTrans(duration=1)";
	// Make sure filter is not playing.
	if ((obj.visibility != "visible")) {
      obj.filters.blendTrans.Apply();
      obj.style.visibility="visible";
	  obj.filters.blendTrans.Play();
	}
}

/* use this HTML for above funtions
<table ID="tabel" width="500" border="0" cellspacing="2" cellpadding="0">
  <tr>
    <td ID="tabeltext" width="50%">Blaat dit roleert</td>
    <td ID="tabelachtergrond" bgcolor="#0099FF"><div id="divje">Blauwe achtergrond! </div></td>
  </tr>
</table>
<P>
<BUTTON onclick="fadeOut(tabel)" STYLE="background-color: green">Fade Table out</BUTTON> 
<BUTTON onclick="fadeIn(tabel)" STYLE="background-color: green">Fade Table In</BUTTON>
*/