// Common functions to pubic interfase
// Copyright (C) 2006 Ezhermatic, S.A. de C.V.

var Navigator_IsIE = (navigator.appName.indexOf('Microsoft')!=-1);

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
	if (Locale == "es") {
		alert("Presione CTRL-D (Netscape) o CTRL-T (Opera) para guardar en los favoritos");
	} else {
		alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
	}
  }
}
function pageScrollTop() {
    	window.scrollTo(0,0);
}
function PrintContent(){
	var a='PRINT';
	if(Action!='')a=Action+',PRINT';
    var URL = sessionurl+'Screen='+Screen+'&Action='+a+'&feature_Id='+feature_Id+'&Id='+Id;
	window.open( URL, 'PrintContent', 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=580').focus();
}
function SubmitForm( screen_code, action_code, feature_code, Id ){
    document.forms[ Screen ].elements[ 'Screen' ].value = unescape( screen_code );
    document.forms[ Screen ].elements[ 'Action' ].value = unescape( action_code );
    document.forms[ Screen ].elements[ 'client_Id' ].value = client_Id;
    document.forms[ Screen ].elements[ 'feature_Id' ].value = feature_code;
    document.forms[ Screen ].elements[ 'Id' ].value = Id;
    document.forms[ Screen ].elements[ 'UI_List_Stack' ].value = '';
    document.forms[ Screen ].elements[ 'UI_List_Offset' ].value = '';
    doSubmit();
}

function LocationReplace( url ){
    document.location.replace(url);
}

function ListPrevious(){
    var stackvalue = document.forms[ Screen ].elements[ 'UI_List_Stack' ].value;
    var pos = stackvalue.indexOf( ':' );
    var offset = stackvalue.substring( 0, pos );
    stackvalue = stackvalue.substring( pos + 1 );

    document.forms[ Screen ].elements[ 'Action' ].value = '';
    document.forms[ Screen ].elements[ 'UI_List_Stack' ].value = stackvalue;
    document.forms[ Screen ].elements[ 'UI_List_Offset' ].value = offset;
    doSubmit();
}

function ListNext( offset ){
    document.forms[ Screen ].elements[ 'UI_List_Stack' ].value = document.forms[ Screen ].elements[ 'UI_List_Offset' ].value + ':' + document.forms[ Screen ].elements[ 'UI_List_Stack' ].value;
    document.forms[ Screen ].elements[ 'UI_List_Offset' ].value = offset;
    doSubmit();
}

function AlertError( message ){
    if( message.length ) alert( message );
}

function doSubmit(){
    document.forms[ Screen ].submit();    
}

var Loaded = 0;
function LoadDone(){ 
    AlertError(JsStartError_Message);
    Loaded = 1; 
}

