// Contains Copyrighted Materials by (c) ISPRODUCTIONS 2008

/** Common variables */
var gWSLogoWidth = 400;
var gImgPadL = 12, gImgPadR = 13; 
var gMedBorderW = 0;
if (navigator.appName) if (navigator.appName.indexOf('Internet Explorer')>-1) gMedBorderW = 1;
var gMenuLineWidth; //global var having the width value of 'menuline'

/* Frontpage variables */
var arHs, arWs;
var scrW, srcH;
/* end of Frontpage variables */

/* variables used in another files */
var customFileBottomNavCloseImage = "CommonFiles/templates/santiago/close.gif";
/* end of another variables */

/* inside pages variables */ /* end of inside pages variables */
    
    scrW = getBrowserW();
    scrH = getBrowserH();

/**************************************  FRONT PAGE *****************************************/
// frontpage init function
function init_FP(){

    init();
 //moved to 555   
// instantiateScroller(0, "scroll0", 0, 0, iContWidth, iContHeight, iImgWSum, iIMG_THUMB_HEIGHT+iImgTopMargin+ iNameBottom + 25, 'H', 8, 245,'pfHolder'); 


}
function init_InsidePage(){     // init function for inside image and gallery pages
    
    init();
    CheckForNoImages();
 //moved to 555   
    //instantiateScroller(0, "scroll0", 0, 0, iContWidth, iContHeight, iImgWSum, iIMG_THUMB_HEIGHT+iImgTopMargin+ iNameBottom + 25, 'H', 8, 245,'pfHolder'); //35, 265
}

   
function ShowHideInfoBlock(el,bAction){
    var act = '';
    if (bAction) act='block'; else act = 'none';
    if (GE(el+'Cover')) GE(el+'Cover').style.display = act;
    if (GE(el+'Cont'))  GE(el+'Cont').style.display  = act;
    
    if (bAction) act='visible'; else act = 'hidden';
    if (GE(el+'Cover')) GE(el+'Cover').style.visibility = act;
    if (GE(el+'Cont'))  GE(el+'Cont').style.visibility  = act;
}

var arIWs = new Array();
var arNames = new Array();


/*************************************** common functions ***************************/
function change(id,clas) {
    GetElement(id).className = clas;
}

 // returns an array of id-s
function getElementsByClassName(className, parent){
    var oParent;
    var arr = new Array();
    if (parent) oParent = GetElement(parent); else oParent=document;
    var elems = oParent.getElementsByTagName("div");
    for(var i = 0; i < elems.length; i++)
    {
        var elem = elems[i];
        var id = elem.getAttribute("id");
        var cls = elem.className
        if(cls == className){
            arr[arr.length] = id;
        }
    }
    return arr;
}

//returns an array of objects
function getObjectsByClassName(className, parent){
    var oParent;
    var arr = new Array();
    if (parent) oParent = GetElement(parent); else oParent=document;
    var elems = oParent.getElementsByTagName("div");
    for(var i = 0; i < elems.length; i++)
    {
        var elem = elems[i];
        var cls = elem.className
        if(cls == className){
            arr[arr.length] = elem;
        }
    }
    return arr;
}
	
function getBrowserH() {
    return screen.height-20;
}
function getBrowserW() {   
    return YAHOO.util.Dom.getViewportWidth()
}

function maximize() {
    var offset = (navigator.userAgent.indexOf("Mac") != -1 || 
                  navigator.userAgent.indexOf("Gecko") != -1 || 
                  navigator.appName.indexOf("Netscape") != -1) ? 0 : 4;
    window.moveTo(-offset, -offset);
    window.resizeTo(screen.width, screen.height);
}
function GetElement(id){
    return document.getElementById(id);
}
function GE(id) { return GetElement(id); }

function togDisp(e,ind){
    stopB(e);
    var elems = getObjectsByClassName('HMoreButton');
    for(var i=0;i<elems.length;i++){
        var obj=elems[i];
        var dp="none";
       // var dp = 'hidden';

       if (obj.id == ('more'+ind)){
           // if(obj.style.visibility == 'visible') dp='hidden'; else { dp = 'visible'; }
            if(obj.style.display=='block') dp='none'; else dp = 'block';
        }
//          obj.style.visibility = dp;
        obj.style.display=dp;
    }
    return false;
}
function stopB(e){
    if(!e) e=window.event;
    e.cancelBubble=true;
}

function GetQueryStringParam( paramName, url ) {

    var i;
    var len;
    var idx;
    var queryString;
    var params;
    var tokens;

    url = url || top.location.href;

    idx = url.indexOf( "?" );
    queryString = idx >= 0 ? url.substr( idx + 1 ) : url;
    params = queryString.split( "&" );

    for ( i = 0, len = params.length ; i < len ; i++ ) {
        tokens = params[i].split( "=" );
        if ( tokens.length >= 2 ) {
            if ( tokens[0] === paramName ) {
                return unescape( tokens[1] );
            }
        }
    }

    return null;
}


//*!!!!!!!!!!!!!!!*****************  end common functions  ********/
/* temporary here*/

function HideDropMenus(){
    var elems = getObjectsByClassName('HMoreButton');
    for(var i=0;i<elems.length;i++){
        var obj=elems[i];
        obj.style.display = "none";
    }
}

function GetUsefulData(o, field){
    
    var arO = o.childNodes;
    var a;

    for (a=0; a< arO.length; a++) {
        if (arO[a].nodeType == 1){
            if (arO[a].getAttribute('id') == field)
                return arO[a].innerHTML;
        }
    }
    return '';
}

function Load_InfoBox(sNewContent, sLink) {
    // hide Assets or Portfolios drop-down menu
    HideDropMenus();
   
    
   var target = 'ImIPaD';
   /*
   var doAft = "obj.innerHTML = GetUsefulData(obj, '"+ sNewContent +"c');"   
       doAft += "AddBGRClass(divID);setInfo_box('" + target + "');"
       doAft +=  "ShowHideInfoBlock('IP',true);";
       doAft += "InitASB(3);";

   DoTheJob(sLink, target, doAft);
   */    
   var doAft = function(t){

       o = GE(t);
       o.innerHTML = GetUsefulData(o, sNewContent +'c');   
       
       AddBGRClass(t);
       setInfo_box(t );
       ShowHideInfoBlock('IP',true);
       
       //** added 10-dec-2010. Wait for all images(if any) to load before create the scrollbar
        //var v = $("img",$('#IPCont'));
        var v = GE("IPCont").getElementsByTagName("img")
        var aN=0;
        var Lim = v.length;
        if (Lim>0)
            /*
            v.bind('load', function(){
              aN++;
              if (aN==Lim) InitASB(3);
            });
            */
            YAHOO.util.Event.on(v, 'load', function(){
                      aN++;
                      if (aN==Lim) InitASB(3);
                    }, 
              '', true);
        else
            InitASB(3);
     }
   
   var callback = DefCallback(target, doAft);
   var conn = YAHOO.util.Connect.asyncRequest("POST", sLink, callback, 'z=1');
   
   
}
function DefCallback(target, doAfter){
    var callback = {
            success : function(o) {
                YAHOO.util.Event.onContentReady('IPCont', function(){doAfter(target)}, '', false)

                var rst = o.responseText;
    		    GE(target).innerHTML = rst;
        
                //if (doAfter!='') doAfter(target);
                
            },
            failure : function(o) { alert('Error loading')
            }
        }
    return callback;

}

function Load_Asset(sLink, sItem){
    if (sLink.indexOf('http://')>-1){
    //** external llink
        window.open(sLink.replace('&ajx=1',''));
        return;
    }

     // hide Assets or Portfolios drop-down menu
    HideDropMenus();

    var par='z';
    var target = 'assetinfo';
    var doAfter = "ShowHideInfoBlock('A',true);";
    if (sItem == 'A') doAfter += "InitASB(2);";
    if (sItem == 'G') doAfter += 'fixGBTblWidth();';
    
    postGetData(sLink, par, target, doAfter);
}

function DoTheJob(obj,target,doAfter){
    var href, ds, par='z';
          
    if (obj){
        // ShowLoading(target);

        // get & set the template content
        postGetData(obj, par, target, doAfter);
    }
}

function postGetData(dataSource, data, divID, doAfterFinish)
{
    var XMLHttpRequestObject;
    if (window.XMLHttpRequest) {
        XMLHttpRequestObject = new XMLHttpRequest();
    }else if (window.ActiveXObject){
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
        }

    if(XMLHttpRequestObject) {
        var obj = document.getElementById(divID);
        try{
            XMLHttpRequestObject.open("POST", dataSource, true);
            XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
            XMLHttpRequestObject.onreadystatechange = function()
                {   if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                            var cnt = XMLHttpRequestObject.responseText;
                            
                            updateScripts(cnt, true);
                            
                            obj.innerHTML = cnt;

                            if (doAfterFinish!='') eval(doAfterFinish);
                           
                   /*   
                     for (a=0 ; a< obj.innerHTML.length; a=a+2000)
                         alert(obj.innerHTML.substr(a, 2000))
                   */   
                    }
                }
            XMLHttpRequestObject.send(data);
       }
        catch (e) {
            window.open(dataSource)
       }
    }
}

function ShowLoading(target){
    if (imgLoadingFile) {
        oMI = document.getElementById(target);
        if (oMI){
            var objILoading = document.createElement("div");
		    objILoading.setAttribute('id','imgLoading');
		    oMI.appendChild(objILoading);
		    
		    objILoading.innerHTML = "<img src='CommonFiles/spacer.gif' />"
        }
    }
 }
function updateScripts( html, loadScripts){

        if(!loadScripts) return;
        
        var _parseScripts = function(){
            var docHead = document.getElementsByTagName("head")[0];
         
            var re = /(?:<style.*(?:src=[\"\'](.*)[\"\']).*>.*<\/style>)|(?:<style.*>([\S\s]*?)<\/style>)/ig; // assumes HTML well formed and then loop through it.
            var match;
            while(match = re.exec(html)){
                 var s0 = document.createElement("style");
                 if (match[1])
                    s0.src = match[1];
                 else if (match[2]){
                    s0.setAttribute("type", "text/css");
                    if(s0.styleSheet){// IE
                        s0.styleSheet.cssText = match[2];
                    } else {// w3c
                        var cssText = document.createTextNode(match[2]);
                        s0.appendChild(cssText);
                    }
                    }
                 else
                      continue;
                 docHead.appendChild(s0);
            }   
             
             
            var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img; 
            var sRe = /(?:<script.*?>)/i;
            var srcRe = /\ssrc=([\'\"])(.*?)\1/i;   
            
            var match, sTagMatch, srcMatch;
         
            while(match = re.exec(html)){
                sTagMatch = match[0].match(sRe);
                if (sTagMatch) {
                    srcMatch = sTagMatch[0].match(srcRe);
                    if(srcMatch && srcMatch[2]){
                       var s = document.createElement("script");
                       s.src = srcMatch[2];
                       docHead.appendChild(s);
                    }else if(match[1] && match[1].length > 0){
                               var s = document.createElement("script");
                               s.type = 'text/javascript';
                               if(navigator.userAgent.indexOf("Safari")!=-1){//code being in a variable is important - this is Safari hack ;)
                                    window.my_code = match[1]; 
                                    s.innerHTML = 'eval(window.my_code)';
                               }
                               s.text = match[1];   
                             
                              docHead.appendChild(s);
                              
                        }                     
                }
            }
            
        }
        
        // set timeout to give DOM opportunity to catch up
        setTimeout(_parseScripts, 20);
       

}

function fixGBTblWidth(){
    var gb_t = GE("GBtable");
    if (gb_t) {
        var t_cont = GE('acont1');
        if (t_cont){
            if (gb_t.offsetWidth > t_cont.offsetWidth);
                t_cont.style.width = gb_t.offsetWidth+50 + 'px';
        }
    }
}
function ckACW(){
    if (typeof iCont1W != 'undefined')
        if (iCont1W) if (GE('acont1')) GE('acont1').style.width = iCont1W+'px';
}

var sCloseBut = "<div id='info_boxClose'><A onclick='setInfo_box(); return false;' href='#'>close (x)</A></div><br><br>";
sCloseBut='';
var sActive = '';
var sOpener = '';
function setInfo_box( sNewContent, iAct, iOp) {

    if (document.getElementById) {
         var info_boxElement = GE('info_box');
         var infosource = GE(sNewContent);
         if (info_boxElement)
             if (infosource ) {  
  		        info_boxElement.innerHTML = infosource.innerHTML;
  		        infosource.innerHTML = '';
  		     }
  		    else
  		        info_boxElement.innerHTML = '';
     }
}

function myRemoveNode(obj){
  if (obj)   
      if (obj.removeNode)
                obj.removeNode(true);
       else { 
            var parent = obj.parentNode;
            parent.removeChild(obj);
        } 
}

function scream(){
    alert('aaaaaa')
}
var bPLay = false;
var oD, arImD, oIm
var iFIDEndP = 0;
var imgsP, iImgWSum = 0;
var iImgWSumOLD;
arHs = new Array();
arWs = new Array();

var nnn='';
function GetDims(obj, ind){
    //var arT = new Array(2);
    //arT = 
    GetODims(obj, 0, ind);
}
   
function GetDims2(arT, ind){    
    //arT[0] = obj.height; 
    //arT[1] = obj.width;
    
    var emp = false;
    if (arT[1]<5 )  { arT[0] = arT[1] = iIMG_THUMB_HEIGHT;/* emp = true; */}
    arHs[ind-1] = arT[0]; 
    arWs[ind-1] = arT[1];

    iFIDEndP++;
    iImgWSum += arWs[ind-1] + gImgPadL + gImgPadR + 2*gMedBorderW;
    

    GE('mi'+ ind).style.width = arT[1]+'px';
    GE('miw'+ ind).style.width = arT[1]+'px';
    if (arT[0] < iIMG_THUMB_HEIGHT) GE('mi'+ ind).style.height = arT[0]+'px';
    
    var LL = (arT[0] < iIMG_THUMB_HEIGHT? arT[0] : iIMG_THUMB_HEIGHT);
    if (parseInt(GE('mi'+ ind).offsetTop)>0)
        GE('mi'+ ind).style.marginTop = -LL/2+'px';
}
var gdTO;
function GetODims(o,c, i){
    var ar =  new Array(0,0);
    var res;
    if (o) {
        if (o.width>0){
            ar[0] = o.height; 
            ar[1] = o.width;
            //res = ar;
            GetDims2(ar,i)
        }
        else if(c>=1000)
                clearTimeout(gdTO);
             else {
                //gdTO = setTimeout('GetODims('+o+','+ (c+5) +','+ i+')', 5);
                gdTO = setTimeout(function(){GetODims(o, c+20, i);}, 50);
               }
    }
   // return res;    
}


function CheckForNoOpenImg(){
    var ix;

    for (ind=0; ind< MM_p.length; ind++){
        if (MM_p[ind].width < 5 )  {
            ix = ind+1;
            var z = document.createElement("div");
	        z.setAttribute('id','miE'+ix);
            GE('mi'+ ix).appendChild(z);
    	    
	        p = GE('il'+ix)
	        myRemoveNode(GE('il'+ix))
	        z.appendChild(p);
	        z.className = z.className+ ' ImgThumbE';
	    }
    }
}

 


/************/
function setEvents(iNum){

    YAHOO.util.Event.on('iltd'+iNum, 'mouseover', ShowStrip, GE('iltd'+iNum), true);
    YAHOO.util.Event.on('iltd'+iNum, 'mouseout', HideStrip, GE('iltd'+iNum), true);
}
function ShowStrip(code) {
    var a, px, arO, z;
    
   // change the class of the links
   var px = 'iltd'
   var arO = getObjectsByClassName('ilabels',this.id.replace(px,'il'))
  
   for (a=0; a< arO.length; a++)
        arO[a].className = 'ilabels_over';
   z = GE(this.id.replace(px,'PI'));
   if (z) z.style.visibility = 'visible';
   //set border around the image
   // if image is lower than height of the box
   if (arHs[eval(this.id.replace(px,''))-1] < iIMG_THUMB_HEIGHT) 
        change(this.id.replace(px,'mi'), 'img_thumb_over_small');
   else
        change(this.id.replace(px,'mi'), 'img_thumb_over');

}
function HideStrip(code){
    var a, px, arO, z;
    var px = 'iltd'
    var arO = getObjectsByClassName('ilabels_over',this.id.replace(px,'il'))
    for (a=0; a< arO.length; a++)
        arO[a].className = 'ilabels';
    z = GE(this.id.replace(px,'PI'));
    if (z) z.style.visibility = 'hidden';
    //set border around the image
    change(this.id.replace(px,'mi'), 'img_thumb');
    
}

var iCount=0;
var gcImagesC = 0; //number of images
var ImagesCount = 0;
var igImgLoadInt;
var isFirstInst=false;
var MM_p=new Array();

function MM_preloadImages() { 
   GE('scroll0Container').disabled = false;
    
    var d=document; 
    var r = GE('root0');
    var a = r.getElementsByTagName('img')
    var i,j=MM_p.length

    gcImagesC = a.length;
    for(i=0; i<a.length; i++){
        if (CheckParentDivClass(a[i], 'img_thumb')) continue;

        MM_p[j]=new Image; 
        MM_p[j++].src=a[i].src;
    }

   igImgLoadInt = setTimeout('setIBox()', 100);
}

function setIBox(){
    var a=1,oo;
    
    iImgWSumOLD = iImgWSum;
    iImgWSum = 0;
    ImagesCount = 0;
    while (GE('mi'+a)){
        oo = MM_p[a-1];
        GetDims(oo, a);
        if (GE('scroll0Content')) GE('scroll0Content').style.width = iImgWSum + 'px';
        a++;
        ImagesCount++;
    }

    clearTimeout(igImgLoadInt);
    // check if clear timeout is required and no need to put another
    if (gcImagesC>-1){
     
        if ( (iImgWSumOLD!=0) && (iImgWSumOLD != iImgWSum)) {
            RecalcSBLoad(0,'H', iImgWSum);
        }
        
        igImgLoadInt = setTimeout('setIBox()', 100);
        
    }else {
        CheckForNoOpenImg();
     }
      
    if ( (iImgWSum > iContWidth) && !isFirstInst ) {
            //instantiate Scrollbar()
          instantiateScroller(0, "scroll0", 0, 0, iContWidth, iContHeight, iImgWSum, iIMG_THUMB_HEIGHT+iImgTopMargin+ iNameBottom + 25, 'H', 8, 245,'pfHolder'); 
          LoadSB(0);
          isFirstInst = true;
    }
  
}

function init() {
    var a=1;
  
    if (gcImagesC == ImagesCount) {
        clearTimeout(igImgLoadInt);
        iImgWSum = 0;
        while (GE('mi'+a)){
            oo = MM_p[a-1];
            GetDims(oo, a);
            if (GE('scroll0Content')) GE('scroll0Content').style.width = iImgWSum + 'px';
            a++;
        }
        
        RecalcSBLoad(0,'H', iImgWSum);
        CheckForNoOpenImg();
       
        if (!isFirstInst) {     
            instantiateScroller(0, "scroll0", 0, 0, iContWidth, iContHeight, iImgWSum, iIMG_THUMB_HEIGHT+iImgTopMargin+ iNameBottom + 25, 'H', 8, 245,'pfHolder'); 
            LoadSB(0);
            isFirstInst = true;
        }
        init2();
    }
    else {
        gcImagesC = -1;
        igImgLoadInt = setTimeout('setIBox()', 100);
        setTimeout('init2()', 115);

    }
   
}
function init2(){

  //if (navigator.appName) if (navigator.appName.indexOf('Internet Explorer')>-1) iContWidth = scrW-4;
    if (GE('scroll0Container')) GE('scroll0Container').style.width = iContWidth + 'px';    //**tw+ 'px';
    if (GE('root0')) GE('root0').style.width = iContWidth + 'px'; 
    if ( (iContWidth > iImgWSum) && (iImgWSum!=0) && GE('scroll0Content')) {
       GE('scroll0Content').style.left =    (iContWidth - iImgWSum)/2 + 'px';   //(iContWidth - GE('scroll0Content').offsetWidth)/2 + 'px';
        }
        
//moved to  OnLoadFuncs1()   
gMenuLineWidth = setMenuLineWidth();

    setTimeout(SetOnResize,100);
    
//moved to OnLoadFuncs1()    ShowHideInfoBlock('FP',false);
}

function setFadeEffect(){
    var object;
    if (!oD) oD = GE('ibox');
    if (oD){
        if (!arImD) arImD = oD.getElementsByTagName('img');
        if (arImD.length > 0 ){
            if (!oIm) oIm = arImD[0];
            sIClass = oIm.className;
            if (sIClass.indexOf('effects_') < 0) {
                if (!oIm.id) oIm.id='iFE';
                PlayFadeEff(oIm.id);
           }
        }
    }
}

function CheckParentDivClass(child, pClass){
    
      //if ( a[i].parentNode.parentNode.className != 'img_thumb' )
      tmp = child;
      do {
          tmp = tmp.parentNode;
      }while (tmp.nodeName.toLowerCase() != 'div')

      return (tmp.className != pClass);
}

var iFeTo;//Fade Effect TimeOut
function setFadeOpacity(){
    var object;
    bPLay = false;
    oD = GE('ibox');
    if (oD){
        arImD = oD.getElementsByTagName('img');
        if (arImD.length > 0 ){
            oIm = arImD[0];
            sIClass = oIm.className;
            // check if there is class name for effect in the img tag then set the opacity  0 which is necessary for the default fade effect
            object = oIm.style;
            if (sIClass.indexOf('effects_') < 0 ){  
                object.opacity = 0;  
                object.MozOpacity = 0;
                object.KhtmlOpacity = 0;
                object.filter = "alpha(opacity=0)";
                bPLay = true;
                iFeTo = setTimeout('PlaySetFadeEffect(oIm, 5)',5);
           }
           else {
                object.visibility = "visible";
           }

        }
    }
    
}
function PlaySetFadeEffect(oIm, iCTime){
    if (iCTime > 1000)
       { clearTimeout(iFeTo); oIm.style.visibility = 'visible'; }
    else
        if (oIm.height>0) { oIm.style.visibility = 'visible'; setFadeEffect();}
        else iFeTo = setTimeout('PlaySetFadeEffect(oIm, '+(iCTime+5)+')',5);
}

/********** asset functions */
function SetViewportAsHeight(eID, margin){
    if (GE(eID)) GE(eID).style.height = YAHOO.util.Dom.getViewportHeight() -200 - margin + 'px';
}
/* end asset functions */

function GoG(link){
    if (link.length > 0 ) document.location.href = link;
}
function GoLink(link, obj){
    
    if (obj.getAttribute('target') && obj.getAttribute('target')=='_blank'){
        window.open(link);
   }else
        GoG(link)
}

function SetHeightInit1(){

    iContHeight = YAHOO.util.Dom.getViewportHeight() - 120; //60+60; 
    if (iContHeight < iIMG_THUMB_HEIGHT+iImgTopMargin+ iNameBottom + 25)  iContHeight = iIMG_THUMB_HEIGHT+iImgTopMargin+ iNameBottom +25;
    if (GE('scroll0Container'))  GE('scroll0Container').style.height = iContHeight + 'px';
    if (GE('noImgsTxt')) GE('noImgsTxt').style.height = iContHeight + 'px';
    
}
function SetHeightInit2(){
   
    var ind = 1;
    var z = (iContHeight - iIMG_THUMB_HEIGHT)/2 - 20 ;
    var z2 = iContHeight-z ;
    if (z>0){
        while (GE('iltd'+ind)){
        //**if (navigator.userAgent.indexOf('MSIE 7')>-1) z2 -= 16;
           GE('miw'+ind).style.paddingTop = z + 'px';
           GE('miw'+ind).style.height = z2 + 'px';
           ind++;
        }

        if (GE('fpcont1')) GE('fpcont1').style.marginTop = 60 +z/2 + 'px';
        if (GE('acont1')) GE('acont1').style.marginTop = 60 +z/2 + 'px';
        if (GE('acont2')) GE('acont2').style.marginTop = 60 +z/2 + 'px';

    }
   SetSBPos();
   var tw = scrW;
 // if (navigator.appName) if (navigator.appName.indexOf('Internet Explorer')>-1) tw = scrW-20;
   iContWidth  = tw;
  //if (navigator.appName) if (navigator.appName.indexOf('Internet Explorer')>-1) iContWidth+= 18;
  
}

function  setMenuLineWidth(){
        var tmp = getObjectsByClassName('websitetitle');
       if (tmp.length>0){
            tmp = tmp[0];
            var iSLW = tmp.offsetWidth //+ 40;    //20-wstitle padding-left
            if (0<iSLW && iSLW < gWSLogoWidth){
                tmp = getObjectsByClassName('fpimagewrap');
                if (tmp.length>0){
                    tmp = tmp[0];
                    tmp.style.width = (iSLW) + 'px';
                }
            }else iSLW =  gWSLogoWidth
       }
       
       var sMW = 0;
       var iMainMW = 0;
       var oML = getObjectsByClassName ('menuline');
       if (oML.length >0) { 
            oML = oML[0];
            var aMcN = oML.childNodes; 
            for (a=0; a < aMcN.length; a++)
                if (aMcN[a].nodeType == 1) {    
                    sMW += aMcN[a].offsetWidth;
                    if (aMcN[a].id != 'cl' && aMcN[a].id != 'wc')  iMainMW += aMcN[a].offsetWidth; 
                }
             
            if (sMW > 0) {
                sMW += 50;
                if (iSLW>0){
                    if ( iSLW + sMW > scrW ) {
                        sMW = scrW - iSLW -40;
                        z = sMW - iMainMW;
                        var a=b=0;
                        var oExtL = GE('cl'), oCliF = GE('wc');
                        if (oExtL) a = 1;
                        if (oCliF) b = 2;

                        switch (a+b) {
                            case 1: //only External link
                                oExtL.style.width = z -59+ 'px';
                                oExtL.style.marginRight = "14px";
                                break;
                            case 2: // only Client Folder link
                                oCliF.style.width = z-50 + 'px';
                                oCliF.style.marginRight = "5px";
                                break;
                            case 3: // both
                                var w1= z/2-50;
                                var w2= z/2-50;  
                                var b1=true, b2=true;
                                if (oExtL.offsetWidth<(z/2)) { 
                                    w1 = oExtL.offsetWidth; 
                                    w2 = z - w1 - 100;
                                    b1 = false;}
                                if (oCliF.offsetWidth<(z/2)) { 
                                    w2 = oCliF.offsetWidth; 
                                    w1 = z - w2 - 100;
                                    b2 = false; }
                                
                                
                                if (b1) {
                                    oExtL.style.width = w1 + 'px';
                                    oExtL.style.marginRight = "14px";
                                }
                                if (b2) {
                                    oCliF.style.width = w2 + 'px';
                                    oCliF.style.marginRight = "5px";
                                }

                        }
                    }
                }
                oML.style.width = sMW + 'px';
                GE('h_ML').style.width = sMW+'px';
            }
       }
        
       return sMW;
 }
 
 function  SetMenuLineLeftLimit(){
    var arLogo, iLogoW, iMLineW, iContW;
 
    arLogo = getObjectsByClassName('websitetitle');
    if (arLogo.length>0){
        arLogo = arLogo[0];
        if (arLogo) { 
                iLogoW = arLogo.offsetWidth;
                iMLineW = gMenuLineWidth;
                
                var oTW = getObjectsByClassName('topinfo');
                if (oTW.length>0) {
                    oTW = oTW[0];
                    iContW = oTW.offsetWidth;
                }
               var oML = getObjectsByClassName ('menuline');
               
               if (oML.length >0) { 
                   oML = oML[0];
                   if (iLogoW + iMLineW +50 > iContW)     
                        oML.style.left = (iLogoW+50) + 'px';     
                   else
                        oML.style.left = 'auto';
                }
                
        } 
    }
 }
 
function SetSBPos(){
    var o = GE('trackH0');
    if (o){
        var z = (iContHeight - iIMG_THUMB_HEIGHT)/2  ;
        o.style.bottom = (z/2-10) + 'px';
        o1 = GE('thumbH0');
        if (o1 && GE('sbname')) o1.style.bottom = (z/2-10 + o.offsetHeight + GE('sbname').offsetHeight) + 'px';
    }
}
   
   
function OnLoadFuncs1(){

   // gMenuLineWidth = setMenuLineWidth();
    ShowHideInfoBlock('FP',false);

    SetHeightInit1();
    SetHeightInit2();
}

function OnLoadFuncs2(){

    var osW = iContWidth;
    scrW = getBrowserW();
    iContWidth = scrW;
    //if (navigator.appName) if (navigator.appName.indexOf('Internet Explorer')>-1) iContWidth = scrW-4;    //scrW-20
    if (GE('scroll0Container')) GE('scroll0Container').style.width = iContWidth + 'px';    //**tw+ 'px';
    if (GE('root0')) GE('root0').style.width = iContWidth + 'px'; 
    var dim = 0;
    if ( (iContWidth > iImgWSum) && (iImgWSum!=0) && GE('scroll0Content')) 
        dim = (iContWidth - GE('scroll0Content').offsetWidth)/2
    GE('scroll0Content').style.left = dim + 'px';
    
    RecalcSB(0, iContWidth, false);

    SetHeightInit1();
    SetHeightInit2();

 }

function SetOnResize() {
    var fr = window.onresize;
    if (typeof fr == 'function')
        window.onresize = function (){
        fr();
        OnLoadFuncs2();}
    else window.onresize = OnLoadFuncs2;
  
}

function write_log(t){
    if (GE('logger')) GE('logger').innerHTML = GE('logger').innerHTML+t+'<br>';
 //   if (GE('FPCont')) GE('FPCont').innerHTML = GE('FPCont').innerHTML+t+'<br>';
}


/***********************************************************************/
 var http_request = false;
  function makePOSTRequest(url, parameters,method) {
    
      if (!method) method = 'POST';
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open(method, url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }


   function alertContents() {
        
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            updateScripts(result, true);
            GE('assetinfo').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function getC(obj) {
      var getstr = '';    //= "?";
      for (a=0; a<obj.elements.length; a++){
        getstr += obj.elements[a].name + "=" + encodeURIComponent(obj.elements[a].value) + "&";
        }
       
       makePOSTRequest(submitURL, getstr);
     
   }
   
   /*********************************************************/
   
    function InitASB(ind) {
        if (GE('scroll'+ind+'Container')){
            GE('scroll'+ind+'Container').style.height = iASbH + 'px';
            if (GE('root'+ind)) GE('root'+ind).style.width = iASbW + 'px';
            if (GE('scroll'+ind+'Container')) GE('scroll'+ind+'Container').style.width = iASbW-30 + 'px';
            if (GE('scroll'+ind+'Content')) instantiateScroller(ind, "scroll"+ind, 0, 0, iASbW, iASbH, GE('scroll'+ind+'Content').offsetWidth, GE('scroll'+ind+'Content').offsetHeight, 'V', 8, 50); //19, 35
            LoadSB(ind);
        }
    }

function AddBGRClass(ind){
    var otmp;
    otmp = GE('LeftSide');
    if (otmp) {
        otmp.id = otmp.id + ind;
        ChangeTRClass('datarowL', otmp.id, 0);
    }
    otmp = GE('RightSide');
    if (otmp) {
        otmp.id = otmp.id + ind;
        ChangeTRClass('datarowR', otmp.id, 0);
    }
    
}

function ChangeTRClass (clsName, parent, px){
    var oParent, elem, aElems;
    var i, k;
   
   clsName1 = clsName + px; 
   aElems = getObjectsByClassName(clsName1,parent);
   k = 0;
   for(i = 0; i < aElems.length; i++) {
        elem = aElems[i];
        if(elem.className == clsName1){
            elem.className = clsName + parseInt(k%2);
            k++;
        }
    }
}
function CheckForNoImages(){
    if (!GE('mi1')) {
        if (GE('noImgsTxt'))
            if (GE('scroll0Container') && GE('scroll0Content')) GE('scroll0Content').style.width = GE('scroll0Container').offsetWidth + 'px';
            GE('noImgsTxt').style.display = 'block';
    }
}

function DisplayList(item, e, iL){
    if (item.length > 0 )
        return togDisp(e,iL);
    else
        alert("Sorry this link doesn't exist!");
}
function wlog( content,flAddNew){
    var  id="logger";
    var dv = GE(id);
    
    if (!dv){
        dv = document.createElement('div');
        dv.setAttribute('id',id);
	    document.body.appendChild(dv);
    }
     
    if (flAddNew)
        dv.innerHTML =content+ "<br>"
    else
        dv.innerHTML =  dv.innerHTML +content+"<br>"
   
        
}

var gIsFPScrlLoaded = false;
function LoadFPBlock(){
    
    ShowHideInfoBlock('FP',true);
    if (!gIsFPScrlLoaded){
         instantiateScroller(1, "scroll1", 0, 0, scrolX, scrolY, GE('scroll1Content').offsetWidth, GE('scroll1Content').offsetHeight, 'V', 6, 50);
         LoadSB(1);
         gIsFPScrlLoaded = true;
    }
}
