var __scrollTop = 0;
var __scrollLeft = 0;
var __initval = null;
var thewizcaller = null;
var __editsingletarget = null;
var __editsingletype = null;
var __editsinglelang = null;
var __editsingleprop = null;
var __editsingleuid = null;
var __editsinglelocked = false;

function getWizardMultiData(cssclass, sep) {

        var checkboxes = getElementsByClass(cssclass);
        var ret = '';

        for(i=0; i < checkboxes.length; i++) {
  
                if (checkboxes[i].checked) {
                        ret = ret + checkboxes[i].value + sep;
                }
        }

        if (ret == '')
                return ret;

        return ret.substring(0, ret.length-1);
}
function getWizardMultiDataAttrib(attr, cssclass, sep) {
        var checkboxes = getElementsByClass(cssclass);
        var ret = '';

        for(i=0; i < checkboxes.length; i++) {

                if (checkboxes[i].checked) {
                        ret = ret + checkboxes[i].getAttribute(attr) + sep;
                }
        }
        //alert(ret);
        if (ret == '')
                return ret;

        return ret.substring(0, ret.length-1);

}
function getCookie(c_name) {
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) + "; path=/";
}
function addOnLoad(newFunction){
        var oldOnLoad = window.onload;
        
        if(typeof oldOnLoad == "function"){
                window.onload = function(){
                        if(oldOnLoad){
                                oldOnLoad();
                        }
                        newFunction();
                }
        }
        else{
                window.onload = newFunction;
        }
}
function __scrollHandlerTop() {
       iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
        __scrollTop=document.all? iebody.scrollTop : pageYOffset    
}
function allEve(e){
        var ev= (window.event)? window.event: e;
        if(!ev || !ev.type) return false;

        var ME= ev;       
        if(ME.type.indexOf('key')!= -1){
                if(document.all || ME.type.indexOf('keypress')!= -1){
                        ME.key= (ev.keyCode)? ev.keyCode: ((ev.charCode)? ev.charCode: ev.which);
                }
                else ME.key= ev.charCode;
                if(ME.key) ME.letter= String.fromCharCode(ME.key);
        }
        return ME;
}
function str_replace(haystack, needle, replacement) {
    var temp = haystack.split(needle);
    return temp.join(replacement);
}
function ignoreEnter(e, formId, isa){
        theform = document.getElementById(formId);
        
        var c=allEve(e).key;
       
        if ( isa )
            return false;
        else if ( typeof c == "undefined" )
                theform.submit();
        else {
                if ( c && e && c == 13 )
                        return false;
        }
        return false;
}
function toUnixTime( dateStr ) {        // DateStr format: dd-mm-yyyy
       
        temp = dateStr.split('-');
        var foo = new Date(); // Generic JS date object
        y = temp[2];
        m = temp[1];
        m = parseInt(m);
        m = m - 1;
        d = temp[0];
        foo.setYear(y);
        foo.setMonth(m);
        foo.setDate(d);
        foo.setMinutes(0);
        foo.setHours(0);
        foo.setSeconds(0);

        if (temp[3] != null)
                foo.setHours(parseInt(temp[3]));    

        if (temp[4] != null)
                foo.setMinutes(parseInt(temp[4]));

        var unixtime_ms = foo.getTime();
        var unixtime = Math.round(parseFloat(unixtime_ms / 1000));   
        return unixtime;
}
function fromUnixTime( timestamp ) {
        timestamp = parseInt(timestamp);
        ms = 1000 * timestamp;  
        var foo = new Date();
        foo.setTime(ms);
        foo.setMonth(parseInt(foo.getMonth()));
        return formatDate(foo, "dd-mm-yyyy");
}
function fromUnixTimeHours( timestamp ) {
        timestamp = parseInt(timestamp);
        ms = 1000 * timestamp;
        var foo = new Date();
        foo.setTime(ms);
        foo.setMonth(parseInt(foo.getMonth()));        
        return formatDate(foo, "dd-mm-yyyy-hh-nn");
}
var formatDate = function (formatDate, formatString) {
if(formatDate instanceof Date) {
var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var yyyy = formatDate.getFullYear();
var yy = yyyy.toString().substring(2);
var m = formatDate.getMonth();
var mm = m < 10 ? "0" + m : m;
var mmm = months[m];
var d = formatDate.getDate();
var dd = d < 10 ? "0" + d : d;
var h = formatDate.getHours();
var hh = h < 10 ? "0" + h : h;
var n = formatDate.getMinutes();
var nn = n < 10 ? "0" + n : n;
var s = formatDate.getSeconds();
var ss = s < 10 ? "0" + s : s;
formatString = formatString.replace(/yyyy/i, yyyy);
formatString = formatString.replace(/yy/i, yy);
formatString = formatString.replace(/mmm/i, mmm);
formatString = formatString.replace(/mm/i, mm);
formatString = formatString.replace(/m/i, m);
formatString = formatString.replace(/dd/i, dd);
formatString = formatString.replace(/d/i, d);
formatString = formatString.replace(/hh/i, hh);
formatString = formatString.replace(/h/i, h);
formatString = formatString.replace(/nn/i, nn);
formatString = formatString.replace(/n/i, n);
formatString = formatString.replace(/ss/i, ss);
formatString = formatString.replace(/s/i, s);
return formatString;
} else {
return "";
}
}

///////////////////////////////////////////////
// Use this function to set inner HTML of <select> tag
///////////////////////////////////////////////

function copy_clip( tex ) {

        // IE
        if (window.clipboardData) {

                window.clipboardData.setData("Text", tex);
                return true;
        } 

        /*
        // If it.s FireFox, then set the
        // .signed.applets.codebase_principal_support. to TRUE
        if (navigator.userAgent.indexOf('Firefox')!=-1) {

                previousset = user_pref('signed.applets.codebase_principal_support');
                user_pref('signed.applets.codebase_principal_support', true); 
                var ta= document.getElementById ('clipboardarea');
                var d= document.getElementById ('clipboardtext');
                d.innerHTML = tex;
                ta.innerText= d.innerText;
                // create the text range
                var t= ta.createTextRange ();
                // do this if you wanna remove the format of the text within
                t.execCommand('RemoveFormat');
                // Then execute the copy command
                t.execCommand('Copy');
                user_pref('signed.applets.codebase_principal_support', previousset); 
        
        }
        */
        // We do not know how to copy in other browsers...      
        return false;

} 

function findParentForm(childObj) {
    var testObj = childObj.parentNode;
    var count = 1;
    while(testObj.tagName != 'BODY') {
        testObj = testObj.parentNode;
        count++;
    }
    return testObj;


}

function select_innerHTML(objeto,innerHTML){
    document.body.style.cursor = "wait";
    if (objeto == null)
        return;
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/gi,"<span").replace(/<\/option/gi,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp);
 selTemp = null;
 document.body.style.cursor = "default";
}

function getElementsByClass( searchClass, domNode, tagName) {
        if (domNode == null) domNode = document;
        if (tagName == null) tagName = '*';
        var el = new Array();
        var tags = domNode.getElementsByTagName(tagName);
        var tcl = " "+searchClass+" ";
        for(i=0,j=0; i<tags.length; i++) {
                var test = " " + tags[i].className + " ";
                if (test.indexOf(tcl) != -1)
                        el[j++] = tags[i];
        }
        return el;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// REQUESTER FUNCTIONS - BEGIN
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"
var req;
var bouncelimit=32 //(must be divisible by 8)
var direction="up"
var __eId;

function windowsize() {

var w = 0;
var h = 0;

//IE
if(!window.innerWidth)
{
//strict mode
if(!(document.documentElement.clientWidth == 0))
{
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
}
//quirks mode
else
{
w = document.body.clientWidth;
h = document.body.clientHeight;
}
}
//w3c
else
{
w = window.innerWidth;
h = window.innerHeight;
}
return {width:w,height:h};
}

function initbox( requesterid ){

document.body.style.cursor = "wait";

if (!dom&&!ie&&!ns4)
return;
req = requesterid;
//alert(requesterid);
try {
        crossobj=(dom)?document.getElementById( requesterid ).style : ie? eval('document.all.'+requesterid) : eval('document.'+requesterid);
} catch(e) {}

//alert(__scrollTop);

//t = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.scrollTop;
t = __scrollTop;
x = windowsize();
w = x['width'];
h = x['height'];
//alert(t);
t = ((screen.height - 315) / 2) + t; // 315 is the global Requester Height !

if (isNaN(t))
        t = 0;

l = (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : window.scrollX;

if (isNaN(l))
    l = 0;

l = l + ((w-500)/2);  // 500 is the global Requester Width !

bod = document.getElementById('thebody');
o = document.getElementById(requesterid);
xxx = document.getElementById('reqcontainer');
try {
        xxx.appendChild(o);
        bod.className = "page fadedown";
        o.className = "notfaded";
} catch(ex) {}
/*
if ( t > h ) {
        scrollamount = t - h;
        t = scrollamount - 315;
} else {
        t = t - 315;
}    
*/

crossobj.top = parseInt(t) + "px";
crossobj.left = parseInt(l) + "px";
crossobj.visibility=(dom||ie)? "visible" : "show"
//crossobj.zIndez = 1000;

if ( __wiz != null && typeof __wiz != 'undefined' )
        __handleWizardOnload(__wiz, null);

document.body.style.cursor = "default";

//dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<100+scroll_top)
crossobj.top=parseInt(crossobj.top)+40+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
y = parseInt(crossobj.top)-bouncelimit;
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1

if ( y > 500 && bouncelimit == -8 ) {
        crossobj.top = (y/2) + calunits;
}

if (bouncelimit==0){
clearInterval(bouncestart)


        /*
        if ( y < 500 && y > 400 ) {
                if (typeof _rq == 'undefined')
                        crossobj.top = (y*2) + calunits;
        } else if ( y > 500 ) {
                crossobj.top = (y/2) + calunits;
        }
        */
        t = 0;

        if ( __wiz != null && typeof __wiz != 'undefined' )
                __handleWizardOnload(__wiz, null);      

        if (req) {
                t = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.scrollTop;
                t = t + ((window.screen.height/2)-300); // FIX 300
                l = (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : window.scrollX;
                l = l + ((window.screen.width/2)-250);  // FIX 250
                document.getElementById(req).setAttribute('style', 'z-index: 1000; position:absolute; top:'+t+calunits+'; left: '+l+calunits);
        
        }

        if (req) {
                
                if (typeof _rq != 'undefined')
                        return;

                o = document.getElementById(req + '_a');
                //if (o) {
                //        o.scrollIntoView(); 
                //        t = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : window.scrollTop;
                //        crossobj.top = (parseFloat(t)) + (window.screen.height/2)-250) + calunits; 
                //}
        }

}

}

function dismissbox(){
        document.body.style.cursor = "wait";
        __initval = null;

        if (window.bouncestart) clearInterval(bouncestart)
        if (window.dropstart) clearInterval(dropstart)
        try {
                //document.getElementById(req).setAttribute('style','visibility:hidden');
                crossobj=(dom)?document.getElementById( req ).style : ie? eval('document.all.'+req) : eval('document.'+req);
                crossobj.visibility = 'hidden';

                // Fade up
                bod = document.getElementById('thebody');
                bod.className = "page";

        } catch(e) {
                document.location.reload();
        }
        //crossobj.visibility="hidden"
        document.body.style.cursor = "default";
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function requesterJS( objid ) {
        document.body.style.cursor = "wait";
        initbox( objid );
        document.body.style.cursor = "default";
}
var dataid;
function requesterJSWithID( objid, data, initialvalue) {
        __wiz = null;
        dataid = data;
        if (initialvalue != null)
                document.getElementById(objid+'_ff').value = initialvalue;  
        initbox( objid );
}
function showDateEditor( objid, data, thedate) {
        __wiz = null;
        dataid = data;
        initbox( objid );
        temp = fromUnixTime(thedate);
        temp2 = temp.split('-');

        if ( parseInt(temp2[0]) < 10 )
            temp2[0] = temp2[0].substring(1, temp2[0].length);

        if ( parseInt(temp2[1]) < 10 )
                temp2[1] = temp2[1].substring(1,temp2[1].length);

        document.getElementById(objid+'_day').value = temp2[0];
        document.getElementById(objid+'_mon').value = parseInt(temp2[1]) + 1;
        document.getElementById(objid+'_year').value = temp2[2];
}
function showDateEditorHours( objid, data, thedate) {
        __wiz = null;
        dataid = data;
        initbox( objid );
        temp = fromUnixTimeHours(thedate);

        temp2 = temp.split('-');
        
        if ( parseInt(temp2[0]) < 10 )
            temp2[0] = temp2[0].substring(1, temp2[0].length);

        if ( parseInt(temp2[1]) < 10 )
                temp2[1] = temp2[1].substring(1,temp2[1].length);

        if ( parseInt(temp2[3]) < 10 )
                temp2[3] = temp2[3].substring(1,temp2[3].length);

        if ( parseInt(temp2[4]) < 10 )
                temp2[4] = temp2[4].substring(1,temp2[4].length);

        document.getElementById(objid+'_day').value = temp2[0];
        document.getElementById(objid+'_mon').value = parseInt(temp2[1]) + 1;
        document.getElementById(objid+'_year').value = temp2[2];
        document.getElementById(objid+'_hour').value = temp2[3];
        document.getElementById(objid+'_min').value = temp2[4];
}

function requesterJSWithIDField( objid, data, defval) {
        __wiz = null;
        dataid = data;
        initbox( objid );
        document.body.style.cursor = "default";
        document.getElementById(objid+'_ff').focus();

        if (defval != null && defval != '')
                document.getElementById(objid+'_ff').value = defval;
}
var __otype;
var __data;
var __objid;
var __wiz;

function showTextAreaWizardWithEmail(sid, wizardId, data, objtype, initv ) {
        // This will make sure that the wizard has a cleared state before it is shown
        __otype = objtype
        __data = data;
        dataid = data;
        __initval = initv;
        __objid = wizardId + 'textareafieldemail';
        __wn = 'textareafieldemail';
        //alert("OTYPE: "+__otype + " - DATA: "+__data + " - DATAID: "+dataid+" - OBJID: "+__objid+" - WN: " + __wn);
        cb = document.getElementById(__wn+'__cb').value;
        ex = document.getElementById(__wn+'__ex').value;
        cbex = document.getElementById(__wn+'__cbex').value;
        fields = '__cc=1&__sid=' + sid + '&__class=' + __wn + '&__cbex=' + cbex + '&__ex= ' + ex + '&__cb=' + cb;
        //alert(fields);
        new ajax('/ajax/wizards/genericwizardhandler.php', {postBody: ''+fields, onComplete: requesterJSWizardWithID2});
}

function editSingleLanguageValue(objid, objtype, lang, uid, property, containerObj) {

        if (__editsinglelocked == true)
                return;

        __editsingletarget      = containerObj;
        __editsingleid          = objid;
        __editsingletype        = objtype;
        __editsingleuid         = uid;
        __editsingleprop        = property;
        __editsinglelang        = lang;
        fields = '&mode=get&lang='+lang+'&uid='+uid+'&prop='+property+'&objtype='+objtype+'&oid='+objid;
        new ajax('/ajax/editsingleobjectproperty.php?', {postBody: ''+fields, onComplete: editSingleLanguageValue2});

}        

function editSingleLanguageValue2(req) {

        blur = "editSingleLanguageValue3(__editsingleid, __editsingletype, __editsingleuid, __editsingleprop, __editsinglelang, this.value)";
        html = '<input type="text" value="'+req.responseText+'" onblur="'+blur+'" class="formfield-90percent">';

        __editsingletarget.innerHTML = html;
        __editsinglelocked = true;
}

function editSingleLanguageValue3(objid, objtype, uid, prop, lang, newval) {

        fields = '&mode=save&lang='+lang+'&uid='+uid+'&prop='+prop+'&objtype='+objtype+'&oid='+objid+'&newval='+URLEncode(newval);
        new ajax('/ajax/editsingleobjectproperty.php?', {postBody: ''+fields, onComplete: editSingleLanguageValue4});
}        

function editSingleLanguageValue4(req) {
        __editsinglelocked = false;
        __editsingletarget.innerHTML = req.responseText;
}

function showTextAreaWizard(sid, wizardId, data, objtype ) {
        // This will make sure that the wizard has a cleared state before it is shown
        __otype = objtype
        __data = data;
        dataid = data;
        __objid = wizardId + 'textareafield';
        __wn = 'textareafield';
        cb = document.getElementById(__wn+'__cb').value;
        ex = document.getElementById(__wn+'__ex').value;
        cbex = document.getElementById(__wn+'__cbex').value;        
        fields = '__cc=1&__sid=' + sid + '&__class=' + __wn + '&__cbex=' + cbex + '&__ex= ' + ex + '&__cb=' + cb;
        new ajax('/ajax/wizards/genericwizardhandler.php', {postBody: ''+fields, onComplete: requesterJSWizardWithID2});
}

function requesterJSWizardWithID(sid, wizardname, data, objtype, extraId ) {
        
        // This will make sure that the wizard has a cleared state before being shown
        __otype = objtype
        __eId = extraId;
        __data = data;
        dataid = data;
        __wiz = wizardname;
        __objid = 'wiz_' + wizardname;
        __wn = wizardname;
        cb = document.getElementById(__wn+'__cb').value;
        ex = document.getElementById(__wn+'__ex').value;
        cbex = document.getElementById(__wn+'__cbex').value;
        fields = '__cc=1&__sid=' + sid + '&__class=' + __wn + '&__cbex=' + cbex + '&__ex=' + ex + '&__cb=' + cb + '&__ex2=' + extraId;
        new ajax('/ajax/wizards/genericwizardhandler.php', {postBody: ''+fields, onComplete: requesterJSWizardWithID2});
}

function requesterJSWizardWithID2(request) {
        //alert(request.responseText);
        // This will show the wizard once its state has been cleared
        initbox( __objid );
        
        if ( __otype != null )
                document.getElementById(__wn+'__otype').value = __otype;
        if ( __data != null )
                document.getElementById(__wn+'__tobj').value = __data;
        if ( __eId != null )
                document.getElementById(__wn+'__ex2').value = __eId;

        dragobjectW.initialize();        
        __handleSubmit(__wn, document.getElementById('form_'+__wn), __wn, '');

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// REQUESTER FUNCTIONS - END
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS TO SHOW/HIDE CONTENT DIVS - BEGIN
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/***********************************************
* Switch Content script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on"          //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no"       //Collapse previously open content when opening present? (yes/no)

var contractsymbol='<img vspace="0" hspace="0" height="10" width="10" border="0" src="/gfx/minus.gif">';//HTML for contract symbol. For image, use: <img src="whatever.gif">
var expandsymbol='<img vspace="0" hspace="0" height="10" width="10" border="0" src="/gfx/plus.gif">';           //HTML for expand symbol.


if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}


function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(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 getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
//alert("ddd");
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS TO SHOW/HIDE CONTENT DIVS - END
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// confirmDelete ( message , nextpageurl )

function confirmDelete ( message , nextpageurl ) {

	if (confirm ( message ) ) {
		document.location.href = nextpageurl;
	}

} // func

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// WINDOW OPENING FUNCTIONS 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function open_win1(what_link){ 
var the_url;
var the_x = 350;
var the_y = 230
the_x -= 30;
the_y -= 30;
var how_wide = screen.availWidth;
var how_high = screen.availHeight;
if(what_link != ""){the_url=what_link;}
var the_toolbar = "no";
var the_addressbar = "no";
var the_directories = "no";
var the_statusbar = "no";
var the_menubar = "no";
var the_scrollbars = "no";
var the_do_resize =  "no";
var the_copy_history = "no";
top_pos = (how_high/2) -  (the_y/2);
left_pos = (how_wide/2) -  (the_x/2);
if (window.outerWidth ){
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open(the_url, "DisplayWindow", option);
var Opera = (navigator.userAgent.indexOf('Opera') != -1);
if(Opera){
site.resizeTo(the_x,the_y);
site.moveTo(0,0);
}
}
else
{
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open('', "DisplayWindow", option);
site.location=the_url;
if(site.open){site.focus();return false;}
site.resizeTo(the_x,the_y);
}
}

function open_win(what_link){ 
var the_url;
var the_x = 250;
var the_y = 320
the_x -= 30;
the_y -= 30;
var how_wide = screen.availWidth;
var how_high = screen.availHeight;
if(what_link != ""){the_url=what_link;}
var the_toolbar = "no";
var the_addressbar = "no";
var the_directories = "no";
var the_statusbar = "no";
var the_menubar = "no";
var the_scrollbars = "no";
var the_do_resize =  "no";
var the_copy_history = "no";
top_pos = (how_high/2) -  (the_y/2);
left_pos = (how_wide/2) -  (the_x/2);
if (window.outerWidth ){
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open(the_url, "DisplayWindow", option);
var Opera = (navigator.userAgent.indexOf('Opera') != -1);
if(Opera){
site.resizeTo(the_x,the_y);
site.moveTo(0,0);
}
}
else
{
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open('', "DisplayWindow", option);
site.location=the_url;
if(site.open){site.focus();return false;}
site.resizeTo(the_x,the_y);
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO SHOW FORM HELP
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
function showHelp ( formname, fieldname ) {
	url = '/showhelp.php/formname/'+formname+'/fieldname/'+fieldname;
	win = open_win( url );
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION TO DO FLASH INTRO (ADDISPLAY)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function flashintro(what_link){ 
var the_url;
var the_x = 600;
var the_y = 300
the_x -= 30;
the_y -= 30;
var how_wide = screen.availWidth;
var how_high = screen.availHeight;
if(what_link != ""){the_url=what_link;}
var the_toolbar = "no";
var the_addressbar = "no";
var the_directories = "no";
var the_statusbar = "no";
var the_menubar = "no";
var the_scrollbars = "no";
var the_do_resize =  "no";
var the_copy_history = "no";
top_pos = (how_high/2) -  (the_y/2);
left_pos = (how_wide/2) -  (the_x/2);
if (window.outerWidth ){
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open(the_url, "DisplayWindow", option);
var Opera = (navigator.userAgent.indexOf('Opera') != -1);
if(Opera){
site.resizeTo(the_x,the_y);
site.moveTo(0,0);
}
}
else
{
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open('', "DisplayWindow", option);
site.location=the_url;
if(site.open){site.focus();return false;}
site.resizeTo(the_x,the_y);
}
}

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
}

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function

