// $Revision: 2.1.2.3 $

/*********************************************************/
/* Enable accesskeys in IE                               */
/*********************************************************/

var accessKeyEnabled = true;

function useAccessKey (evt) {
	if (accessKeyEnabled == true) {
		if (event.altKey) {
			event.srcElement.click();
		}
	} else {
		event.srcElement.blur();
		accessKeyEnabled = true;
	}
}

function releaseAccessKey() {
	if (accessKeyEnabled == false) {
		accessKeyEnabled = true;
	}
}

function initAccessKey() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		for (i=0;i<document.all.length;i++) {
			a = document.all(i);
			if (a.tagName == 'A' && a.accessKey != '') {
				a.blur();
				a.onfocus = useAccessKey;
			}
		}
		if (event.altKey) {
			accessKeyEnabled = false;
			document.onkeyup = releaseAccessKey;
			setTimeout ('releaseAccessKey()', 100);
		}
	}
}


/*********************************************************/
/* General functions                                     */
/*********************************************************/

function resize() {
	var bod = document.getElementById("content-body");
	var htmlheight = document.body.parentNode.scrollheight;
	var windowheight = window.innerheight;
	if ( htmlheight < windowheight ) {
		document.body.style.height = windowheight + "px";
		bod.style.height = windowheight + "px";
	} else {
		document.body.style.height = htmlheight + "px";
		bod.style.height = htmlheight + "px";
	}
}

function preloadImages() {
	var d = window.document;
	if(d.images) {
		if(!d.MM_p) d.MM_p = new Array();
		var i, j, a = preloadImages.arguments;
		for(j = d.MM_p.length, i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
	}
}

function findObj(n, d) {
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n);
	return x;
}

function popupWindow(theURL) {
	return openWindow(theURL,'_blank', 'directories=0,location=0,menubar=0,toolbar=0,scrollbars=1');
}

function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
  //return false;
}

function setTextOfLayer(objName,newText) {
	while (obj = document.getElementById(objName)) {
		with (obj)
			if (document.layers) {document.write(unescape(newText)); document.close();}
			else innerHTML = unescape(newText);
		obj.id = '';
	}
}

function showLayer(obj) {
	alert('hola');
	if (obj.style)
		obj=obj.style;

	obj.display = 'block'
}

function hideLayer(obj) {
	alert('hola');
	if (obj.style)
		obj=obj.style;

	obj.display = 'none'
}

function switchLayer(objName) {
	var obj = findObj(objName);
	if (obj.style)
		obj=obj.style;
	obj.display = ((obj.display == 'none') ? 'block': 'none');
}

function switchRollover(obj, checkName) {
	var iMore, iLess, a = switchRollover.arguments;
	var objCheck = findObj(checkName);

	iMore = ((a.length > 2) ? a[2]: 0);
	iLess = ((a.length > 3) ? a[3]: 1);
	if (objCheck.style)
		objCheck=objCheck.style;
	if (objCheck.display == 'none') {
		obj.src = document.MM_p[iLess].src;
		showLayer(objCheck);
	} else {
		obj.src = document.MM_p[iMore].src;
		hideLayer(objCheck);
	}
}

function markCheckBoxes(obj, coll_name) {
  var elems = obj.form.elements;
  if (elems != null) {
    for (i=0; i<elems.length; i++)
      if (elems.item(i).name == coll_name)
        elems.item(i).checked = obj.checked;
  }
}

/*********************************************************/
/* Confirm form submit                                   */
/*********************************************************/

function confirm_submit(o, str)
{
	f = findObj(o);
	if(confirm(str)) f.submit();
}

/*********************************************************/
/* Open Search window                                    */
/*********************************************************/

function search_window(keyword, where)
{
	path = where+'?keyword='+keyword;
	SearchWindow = window.open("","Search","toolbar=no,location=no,status=no,scrollbars=yes,width=600,height=500,innerheight=50,screenX=100,screenY=100,pageXoffset=100,pageYoffset=100,resizable=yes");

	if (SearchWindow.frames.length == 0)
	{
		SearchWindow = window.open(path,"Search","toolbar=no,location=no,status=no,scrollbars=yes,width=700,height=600,innerheight=50,screenX=100,screenY=100,pageXoffset=100,pageYoffset=100,resizable=yes");
	}
	else
	{
		SearchWindow.location.href = path;
		SearchWindow.focus();
	}
}

/*********************************************************/
/* Copy the contents of a field to the clipboard         */
/*********************************************************/

function phpAds_CopyClipboard(obj)
{
	obj = findObj(obj);

	if (obj) {
		window.clipboardData.setData('Text', obj.value);
	}
}


/*********************************************************/
/* Copy the contents of a field to the clipboard         */
/*********************************************************/

function boxrow_over(obj)
{
	obj.style.backgroundColor='#F6F6F6';
}

function boxrow_leave(obj)
{
	obj.style.backgroundColor='#FFFFFF';
}

function boxrow_nonbubble()
{
	if (event.stopPropagation)
	{
		event.stopPropagation();
	}
	else
	{
		event.cancelBubble = true;
	}
}
