var contactIndex;
function showImage(img){
 
  leftPosition = (screen.width) ? (screen.width-200)/2 : 0;
  topPosition = (screen.height) ? (screen.height-200)/2 : 0;	 
  var media=window.open('imageviewer.asp?img='+img, 'imageviewer','top='+ topPosition  +',left='+ leftPosition +',width=200,height=200,menubar=no,location=no,resizable=no,scrollbars=no,status=no');
  media.focus();
  return false;
}
function delAlert(entity,data)
{
	return confirm("RESOURCE NAME: \""+data + "\"\n\nAre you sure, you want to delete this " + entity + "?");
}
function multiDelAlert(msg)
{
	return confirm("Are you sure, you want to delete selected " + msg + "?");
}

function getCookie(Name) { 
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
	offset = document.cookie.indexOf(search)
	if (offset != -1) { 
	offset += search.length
	end = document.cookie.indexOf(";", offset);
	if (end == -1) end = document.cookie.length;
	returnvalue=unescape(document.cookie.substring(offset, end))
	}
	}
	return returnvalue;
}
function saveCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires;
}
// this deletes the cookie when called
function deleteCookie(name) {
 saveCookie(name,"",-10000)	 
}
function copyToClipboard(meintext)
{
 if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("Text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // 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 openPopup(url,name,width,height,pscroll,resize)
{
   if(pscroll=="undefined")
   pscroll="yes";
   if(resize=="undefined")
   resize="no";
   leftPosition =(screen.width) ? (screen.width-width)/2 : 0;
   topPosition =(screen.height) ? (screen.height-height)/2 : 0;	
   window.open(url, name,'top='+topPosition+',left='+leftPosition+',width='+width+',height='+height+',menubar=no,location=no,resizable='+resize+',scrollbars='+pscroll+',status=no');
   return false;
}
function getBodyHeight() {
  return  getBodyHeightWidth(2);
}
function getBodyWidth() {
 
  return  getBodyHeightWidth(1);
}
function getBodyHeightWidth(type)
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(type==1)
  return myWidth;
  else
  return myHeight;
}


/*
Form field Limiter script

*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var input=eval(thename);
var l=thelimit-input.value.length;  
var limit_text='<b><span id="'+theform.toString()+'" style="color:#C61818">'+l+'</span></b> characters remaining on your input limit'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
document.body.addEventListener('load', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}


