﻿// JScript File

/////////////// Help mouse overs /////////////// 
/* NOT USED
var l = document.layers ? 1 : 0;
var d = document;
var popup
function showTooltip(name){
    //document.getElementById('keywordsPopup').style.display = 'block';
	popup = getE(name);
	var evt = window.event || arguments.callee.caller.arguments[0];
	var target = window.event ? evt.srcElement : evt.target;
	positionE(evt);
	showE(popup);
	if (!l) target.onmousemove = positionE;
}
function positionE(evt){
	if (popup){
		if (!evt) var evt = window.event;
		getMousePosition(evt);
		setX(popup,mouseX - 0); // was - 15
		if (navigator.userAgent.indexOf("MSIE") != -1) {
			setY(popup,mouseY - 15); // was - -15
		} else {
			setY(popup,mouseY - getH(popup) - 5);
		}
	}
}

function hideTooltip(name){
	if (popup){
		hideE(popup)
		popup = null;
	}
}

var mouseX = 0;
var mouseY = 0;
function getMousePosition(evt){
	var scrollX = window.innerHeight ? 0 : d.body.scrollLeft;
	var scrollY = window.innerHeight ? 0 : d.body.scrollTop;
	if (evt.pageX || evt.pageY){
		mouseX = evt.pageX;
		mouseY = evt.pageY;
	} else {
		mouseX = evt.clientX + scrollX;
		mouseY = evt.clientY + scrollY;
	}
}
if (l) {
	d.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN);
	d.onmousemove = positionE;
}

function getE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=getElement(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
function getH(e){if(l)return e.clip.height;else return e.offsetHeight;}
function setX(e,x){if(l)e.left=x;else e.style.left=x;}
function setY(e,y){if(l)e.top=y;else e.style.top=y;}
function showE(e){if(l)e.visibility='show';else e.style.visibility='visible';}
function hideE(e){if(l)e.visibility='hide';else e.style.visibility='hidden';}
*/
/////////////// Help mouse overs ///////////////          

/////////////// event treeview ///////////////          

function show_hide(name_id, img_id)
 {
    imgPlus = new Image();
    imgMin = new Image();
    imgPlus.src = '/NetApp/App/images/plus_a.gif';
    imgMin.src = '/NetApp/App/images/min_a.gif';

    var bloeb1 = document.getElementById(name_id);
    var bloeb2 = document.getElementById(img_id);

    if (bloeb1.style.display == 'block')
    {
       bloeb1.style.display = 'none';
       bloeb2.src = imgPlus.src;
    }
    else
    {
       bloeb1.style.display = 'block';
       bloeb2.src = imgMin.src;
    }
 }
/////////////// event treeview ///////////////          

/////////////// get url ///////////////          
function copy_clip(meintext)
{
 if (window.clipboardData) {   
       // the IE-manier
       window.clipboardData.setData("Text", meintext);
   
   } else { 
        //a cause of the tight security settings in mozilla you have to sign the javascript 
        //to make it work another way is to change your firefox/mozilla settings
        //to do this add this line to your prefs.js file in your firefox/mozilla user profile directory
        //user_pref("signed.applets.codebase_principal_support", true);
        //or change it from within the browser with calling the "about:config" page

       // dit is belangrijk maar staat nergens duidelijk vermeld:
       // you have to sign the code to enable this, or see notes below 
       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

       // maak een interface naar het clipboard
       var clip = Components.classes['@mozilla.org/widget/clipboard;1']
                     .createInstance(Components.interfaces.nsIClipboard);
       if (!clip) return;
       
       // maak een transferable
       var trans = Components.classes['@mozilla.org/widget/transferable;1']
                      .createInstance(Components.interfaces.nsITransferable);
       if (!trans) return;
       
       // specificeer wat voor soort data we op willen halen; text in dit geval
       trans.addDataFlavor('text/unicode');
       
       // om de data uit de transferable te halen hebben we 2 nieuwe objecten 
       // nodig om het in op te slaan
       var str = new Object();
       var len = new Object();
       var str = Components.classes["@mozilla.org/supports-string;1"]
                    .createInstance(Components.interfaces.nsISupportsString);
       var copytext=meintext;
       str.data=copytext;
       trans.setTransferData("text/unicode",str,copytext.length*2);
       
       var clipid=Components.interfaces.nsIClipboard;
       if (!clip) return false;
       
       clip.setData(trans,null,clipid.kGlobalClipboard);
   }
   return false;
}

function copy_url(url)
{
    copy_clip(url);
    //window.clipboardData.setData('Text', url);    
}
/////////////// get url ///////////////          

/////////////// openpopup ///////////////          
function openpopup(popurl) {
    winpops=window.open(popurl,"AssetViewerPopup","width=560,height=620,scrollbars,resizable=0,left=100,top=100")
}
/////////////// get url ///////////////          


/////////////// search ///////////////          
// encode search key
function setFormValues(){
//charset=utf-8 = unicode formating, ondersteunt alle karakters

/*    
    //charset=iso-8859-1
    var els = searchForm.elements;
    var params = '';
    for(i=0; i<els.length; i++){ 
        params += els[i].name + '=' + els[i].value + '&';
        if(els[i].name=='qt')
        {
            //replaceUnrecognizedCharacters(els[i].value);
            searchForm.qt.style.color = "#FFFFFF";
            searchForm.qt.value = _encode(searchForm.qt.value);
        }
    }
*/
    //_encode(searchForm.qt.value);
    //Run setFormValues every 2 second 
    //window.setTimeout("setFormValues();",1000);
}

//Start run ASProxyCheckAllForms after 1 second 
//window.setTimeout("setFormValues();",1000);

// private method for encoding
function _encode(string) {
    string = string.replace(/\r\n/g,"\n");
    var encodedText = "";

    for (var n = 0; n < string.length; n++) {
        //character to ascii
	    var c = string.charCodeAt(n);
	    if (c < 128) {
	        // ASCII Character Set [32-127]
	        // ascii to character
		    text = String.fromCharCode(c);
	    }
	    else if((c > 127) && (c < 2048)) {
	        // ISO Latin-1; ANSI [128-255] 
    
            //url syntax (verity)
            text = '%';
            
            // convert dec to hex
            text += c.toString(16);
            
		    //text = String.fromCharCode((c >> 6) | 192);
		    //text += String.fromCharCode((c & 63) | 128);
	    }
	    else {
		    text = String.fromCharCode((c >> 12) | 224);
		    text = String.fromCharCode(((c >> 6) & 63) | 128);
		    text += String.fromCharCode((c & 63) | 128);
	    }
        	    
	    encodedText += text; 
	    //alert(encodedText);
    }
    return encodedText;
}
/////////////// search ///////////////

