/* Autor: Adrian Zenteno Lara */
/* $Id: functions.js,v 1.24 2002/05/24 09:28:14 loic1 Exp $ */
/**
 * Displays an confirmation box beforme to submit a "DROP/DELETE/ALTER" query.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the sql query to submit
 *
 * @return  boolean  whether to run the query or not
 */
function confirmLink(theLink)
{
    var confirmMsg  = 'Continue Logout?';
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
    var is_confirmed = confirm(confirmMsg);  //+ ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }
    return is_confirmed;
} // end of the 'confirmLink()' function

function valConfirmLink(theLink,intFormId,confirmMsg,TypeLink)
{
    // or browser is Opera (crappy js implementation)
    if (typeof(window.opera) != 'undefined') { return true; }
    var is_confirmed = true;
	switch(intFormId)
	{
	 case 4:
	 var PrevdocEnt=document.insertForm.PrevdocEnt.value;
	 if(PrevdocEnt)
	 {
	  window.alert(confirmMsg);
	  is_confirmed = false;
	 }
	 break;
	 case 411:
	 var PrevBillEnt = document.insertForm.PrevBillEnt.value;
	 if(PrevBillEnt)
	 {
	  window.alert(confirmMsg);
	  is_confirmed = false;
	 }
	 break;
	 default:break;
	}
	switch(TypeLink)
	{
	 case 1:break;
	 case 2:break;
	 case 3://LOGOUT
	 if(is_confirmed)
	 {
	  is_confirmed = confirm('Continue Logout?');
	  if (is_confirmed) { theLink.href += '&is_js_confirmed=1'; }
	 }
	 break;
	 default:break;
	}
    return is_confirmed;
} // end of the 'valConfirmLink()' function


function strDefaultStatus() {
 window.defaultStatus = "::TRACOMS::";
}

function confirmUrl(theLink,Msg)
{
    var confirmMsg  = Msg;
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }
    var is_confirmed = confirm(confirmMsg);  //+ ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }
    return is_confirmed;
} // end of the 'confirmUrl()' function

function launchWindow(url, features) 
{
  window.open(url, "_blank", features);
}

function strStatus() {
 window.status = "::TRACOMS::";
}

function load()
{
window.status = "Technosoft Inc. Mexico"
}

function setMenuFocus() {
        document.pageMenu.pageMenuOpc.focus();
        return;
}

function CA(isOnload)
{
 var trk=0;
 for (var i=0;i<insertForm.elements.length;i++)
 {
  var e = insertForm.elements[i];
  if ((e.name != 'allbox') && (e.type=='checkbox'))
  {
   if (isOnload != 1)
   {
    trk++;
    e.checked = insertForm.allbox.checked;
   }
   else
   {
    e.tabIndex = i;
    if (folderID != "")
    e.parentElement.parentElement.children[2].children[0].tabIndex = i;
   }
  }
 }
}
 
 function markAll(f,chkName)
 {
  var strLength=0;
  var nameChk='';
  for(i=0;i<f.elements.length;i++)
  {
   if(f.elements[i].type=='checkbox')
   {
    if(chkName)
	{
	 strLength = chkName.length;
     nameChk = f.elements[i].name;
	 if(nameChk.substring(0,strLength)==chkName)
	 { if(!f.elements[i].checked) f.elements[i].click(); }
	}
	else { if(!f.elements[i].checked) f.elements[i].click(); }
   }
  }
 }

//please wait message functions 
 function xoopsGetElementById(id) {

if (document.getElementById(id)) {
	return document.getElementById(id);
	} else if (document.all[id]) {
		return document.all[id];
		} else if (document.layers && document.layers[id]) {
			return (document.layers[id]);
			} else {
				return fake_element;
			}
}
function toggle_visibility(id, flag)  {

if (xoopsGetElementById(id)) {
	xoopsGetElementById(id).style.visibility = (flag) ? 'visible' : 'hidden';
	}
}

 function countChecked(f)
 {
 var countChk=0;
 var chkName='';
 for(i=0;i<f.elements.length;i++)
  {
   if(f.elements[i].type=='checkbox')
    {
	 chkName = f.elements[i].name;
	 if((chkName.substring(0,5)=='strdt') || (chkName.substring(0,2)=='dt'))
	 { if(f.elements[i].checked) { countChk++; } }
    }
  }
 return countChk;
 }


function fncKeyStop() 
{
 if (window.event.ctrlKey) 
 {
  if (window.event.keyCode == 67 || window.event.keyCode == 86 || window.event.keyCode ==88) 
  { 
   //Do nothing if Contol x, c, v (copy functions)
  }
  else 
  {
   event.keyCode = 0;
   event.returnValue = false;
  }
 }
 //Cancel F5 and F11
 if (window.event.keyCode == 122 || window.event.keyCode == 116) 
 {
  window.event.keyCode = 0;
  event.returnValue = false;
 }
 if (window.event.altKey) 
 {
  //Cancel right arrow, left arror, and home key
  if (window.event.keyCode == 36 || window.event.keyCode == 39 || window.event.keyCode == 37) 
   {
   //For some reason putting the alert in cancels the keystroke
   alert('(c) TRACOMS 2004');
   window.event.keyCode = 0;
   event.returnValue = false;
  }
 }
}

//

 var message="(c) TRACOMS 2005";
 ///////////////////////////////////
 function clickIE4()
 {
  if (event.button==2)
  {
   alert(message);
   return false;
  }
 }

 function clickNS4(e)
 {
  if (document.layers||document.getElementById&&!document.all)
  {
   if (e.which==2||e.which==3)
   {
    alert(message);
    return false;
   }
  }
 }

 //please wait message
 var fake_element; 
 
 function StatusMouseDown(flag)
 {
  if(flag)
  {
	 if (document.layers)
	 {
	  document.captureEvents(Event.MOUSEDOWN);
	  document.onmousedown=clickNS4;
	 }
	 else if (document.all&&!document.getElementById)
	 {
	  document.onmousedown=clickIE4;
	 } 
//   document.oncontextmenu=new Function("return false")
  } 
 }
 
 function changeBgColor(color,id) { document.getElementById(id).style.background=color; } 

 function confirmKyRcd()
 {
  var confirmMsg='This will take you to a Subscription Only site that provides full online access' +'\r\n'+
  'to Clerk records, documents and images. Please make sure popups are not blocked' +'\r\n'+
  'and cookies are enabled for the site';
  var is_confirmed = confirm(confirmMsg);
  if(is_confirmed) { window.open('http://www.campbellcountykyrecords.org'); }
 }

