// Contains Copyrighted Materials by (c) ISPRODUCTIONS 2008

var iFrstImg = 1;
var imgPerPage = 5;
// defined in image template:: var _1stActPos = $$ImageNumSelected$$;
if (typeof _1stActPos == 'undefined') _1stActPos=1;
var slider;
var bIsScrollCreated = false;
var panelH = 130;
var arDistO = new Array(), arDist = new Array();
arDistO[0] = 0;
arDist[0] = 0;
 var bAnyNav = false;
 var igNavArrW = 80;
 var iObjH = 700;
 var gcMinTxtWidth = 250;
 var gcMinTopTblWidth = 875;
 var gcMinFrameWidth = gcMinTopTblWidth - 2*30 - 2*5 -4 - igNavArrW; //730;
 var gcImgBox = 580;
 var arIFields = ['MyCont', 'ImgDesc', 'ImgInfo', 'imagePrv', 'imageNxt', 'ImgInFBlock'];
 var gsDocBodyBg;


function ChangeThPanelHeight(){
   var oDvCont, arA, iImgH;
   oDvCont = document.getElementById("MyCont"); 
   if (oDvCont){
        arA = oDvCont.getElementsByTagName('img')
        if (arA) {
            iImgH = parseInt(arA[0].height);
            if (iImgH > 425) {
                document.getElementById('thumbcontainer').style.height = iImgH+'px';  
                document.getElementById('frame').style.height = (iImgH-70)+'px'; // 2x25+2x10=70 -> the up & down arrows   
            }    
            else {
                document.getElementById('thumbcontainer').style.height = 425+'px';  
                document.getElementById('frame').style.height = (425-70)+'px';
            }
            
            //** update the thumbs scroller
            SetDistLimit();
            SetNavigDisplay();
        }   
   }
}

function ChangeImage(link, ind){
   
    //** if user has select the active image - no need to reload it
   if ( ind && (ind==iCurImg) ) return; 
   iCurImg = ind;

    //ShowLoadSymb('MyCont');
    ShowLoadSymb('tdMyCont');

    var callback = fn_callback(link);
    var conn = YAHOO.util.Connect.asyncRequest("POST", link+'&ajx=1', callback);   
}
function fn_callback(target){
    
    var callback = {
            success : function(o) {
                var rst = o.responseText;
                
                var otemp = document.createElement("div");
                otemp.innerHTML = rst;
				
                for (i=0; i< arIFields.length; i++){
                    SetDataFromTo(otemp, arIFields[i]);

                    if (arIFields[i] == 'MyCont'){
                        var v = GE('MyCont').getElementsByTagName("img")
                        var aN=0;
                        var Lim = v.length;
                        if (Lim>0)
                            YAHOO.util.Event.on(v, 'load', function(){
                                      aN++;
                                      if (aN==Lim) ChangeThPanelHeight();
                                    }, 
                              '', true);
 
                   }
               }
               
               HideLoadSymb('tdMyCont');
               SetImageALTColor();
               
                 // initializing
                sContHTML = ""
                sActive = ""
                oCont=null; 
               
            },
            failure : function(o) {alert('fal')}
       }
    return callback;
}

function SetDataFromTo(oSrc, tgt_F){

        if (oSrc && YAHOO.util.Dom.get(tgt_F)){
            var arO, i;
            arO = oSrc.getElementsByTagName('div');
            
           
           for (i=0; i< arO.length; i++){
                
                if (arO[i].getAttribute('id') == tgt_F) 
                    {
                        var p = arO[i].innerHTML;
                        
                        YAHOO.util.Dom.get(tgt_F).innerHTML = p;
                         
                         return;
                     }
                
           }

        }
          
    }

function MoveImage(dir){

    var old1stActPos = _1stActPos;
    var top = GS('content', 'top');

    var mv = 0;
    if (dir>=0) {//next
        _1stActPos = _1stActPos + dir;
        mv = arDist[_1stActPos-1]; 
        if (_1stActPos>arDist.length-1)
             mv = arDist[arDist.length-1] ;
    }else {//prev
        if( (Math.abs(top) - arDist[_1stActPos-1]) > 0){//*** image is visible partially i.e the _1stActPos does not change
             mv = arDist[_1stActPos-1]; 
       }else  {
            _1stActPos = _1stActPos + dir;
            mv = arDist[_1stActPos-1]; 
        }   
    }

    var c_offset = - mv - top;     //left = GS('content', 'left');

    var anim = new YAHOO.util.Motion('content', { points: { by: [0, c_offset] } }, 1);
    anim.animate();
    //** 04.03.09 anim.onComplete.subscribe(checkConstraints) ;
    anim.onComplete.subscribe(checkStatus) ;
    
}

function MoveImageSet(dir){

    var old1stActPos = _1stActPos;
    var top = GS('content', 'top');
    var moveStep = GS('frame', 'height');

    var mv = arDist[_1stActPos-1]+ dir*moveStep;

    if (dir>=0) {//next
        
        for (a=_1stActPos-1; a<arDist.length; a+=dir){  
           _1stActPos = a;
           if (arDist[a]>=mv){       
                _1stActPos = a-dir;
                break;
           }
        }
                     
    }else {//prev
    
       for (a=0; a<arDist.length; a++){  
           _1stActPos = a;
           if (arDist[a]>=mv) break;
        }  
    }
    
    mv = arDist[_1stActPos];
        
    var c_offset = - mv - top;     
    //alert(c_offset)
    //c_offset = -dir*GS('frame', 'height');

    var anim = new YAHOO.util.Motion('content', { points: { by: [0, c_offset] } }, 1);
    anim.animate();
    anim.onComplete.subscribe(checkStatus) ;
    
}
/* moved to Gallery && Image templates
var f = window.onload; 
if (typeof f == 'function'){
    window.onload = function() {
        f();
        init();
    }
}else window.onload = init;
*/
var iCount=0;
var gcImagesC = 0; //number of images
var ImagesCount = 0;
var igImgLoadInt;
var isFirstInst=false;
var MM_p=new Array();
var iImgWSum = 0;
var initCntW;
var isVisblScroll = false;

function MM_preloadImages() { 
    var d=document; 
    var r = GE('content');
    var a = r.getElementsByTagName('img')
    
    var i,j=MM_p.length

    gcImagesC = a.length;
    
    for(i=0; i<a.length; i++){
        MM_p[j]=new Image; 
        MM_p[j++].src=a[i].src; 
        
    }
    
    checkEffect();
    igImgLoadInt = setTimeout('setIBox()', 100);
}

function setIBox(){
    var a=1,oo;
    
    iImgWSumOLD = iImgWSum;
    iImgWSum = 0;
    ImagesCount = 0;

    while (GE('th'+a)){
        oo = MM_p[a-1];
        var iH = GetDims(oo,a);
        if (panelH<iH) {
            panelH = iH;
          //  GE('frame').style.height = panelH + 'px';
        }
        
        arDistO[a] = iImgWSum;
       // if (GE('content') ) GE('content').style.width = iImgWSum + 'px';
       // if (GS('content','width') < GS('frame','width')) 
        //    GE('content').style.left = (GS('frame','width') - GS('content','width'))/2  + 'px';
               
        a++;
        ImagesCount++;
    }

    clearTimeout(igImgLoadInt);
    // check if clearTimeout is required and no need to put another
    if (gcImagesC>-1){
        igImgLoadInt = setTimeout('setIBox()', 100);
    }
  
}


var padding = 5;
var imageborder = 1;
var cellspacing = 10;
var iIMG_THUMB_WIDTH = 130;
var iIMG_THUMB_HEIGHT = 70;
var arWs = new Array();
var arHs = new Array();

function GetDims(oImg, ind){
    //iImgSum carries the sum of the widths of the images
    
    var t1 = oImg;  //GE('th'+ind)
    if (t1) {
        arWs[ind-1] = t1.width+ 2*padding+ 2*imageborder;     //t1.offsetWidth;
        arHs[ind-1] = t1.height+ 2*padding+ 2*imageborder+ cellspacing;
        //iImgWSum += arWs[ind-1] ;
        iImgWSum += arHs[ind-1] ;
    }
    else {
        arWs[ind-1] = 0;    //t1.offsetWidth;
        arHs[ind-1] = 0;
        //iImgWSum += iIMG_THUMB_WIDTH+ 2*padding;
        
        //*** stef check THIS case *****************
        iImgWSum += iIMG_THUMB_HEIGHT+ 2*padding;
    }
    //return the height of the image
    return arHs[ind-1];
}


function init() {
    var a=1;
  
    //*** if function has been called when setIBox() has just finished
    if (gcImagesC == ImagesCount) {
        clearTimeout(igImgLoadInt);
        iImgWSum = 0;
        while (GE('th'+a)){
            oo = MM_p[a-1];
            var iH = GetDims(oo,a);
            if (panelH<iH) {
                panelH = iH;
                //GE('frame').style.height = panelH + 'px';
            }
            arDistO[a] = iImgWSum;
            //if (GE('content')) GE('content').style.width = iImgWSum + 'px';
            a++;
        }
        SetNavigation();
    }
    //**** if the function init() has been called while setIBox() is executing, then
    //***  call it one last time and set flag (gcImagesC = -1) to stop
    else {
        gcImagesC = -1;
        igImgLoadInt = setTimeout('setIBox()', 100);
        setTimeout('SetNavigation()', 115);    
       }
       
    //*** No Lightbox in Sofia 1 HTML
    //if (typeof initLightbox != "undefined") PrepareInitLightbox();
    
    //** cut the top margin of the first thumbnail in the column
    var pp = document.getElementById('shown1');
    if (pp){
        pp.style.marginTop = '0px';
    }
    
    //** set the text color of the <a> of the image the same as the background of the template body. This way when new image is loaded by ajax the alt text will not be visible while the image is loading and is not visible.
    gsDocBodyBg = $('.DocBody').css('background-color');
    SetImageALTColor();
    
     
     var iFr_h = parseInt( $('#frame').css('height'));
     var iCo_h = parseInt( jQuery.css( GE('content'), 'height', false ));
     var iMyCo_h = parseInt( jQuery.css( GE('MyCont'), 'height', false ));
     //  alert(iMyCo_h+nl+'content: '+iCo_h+'\n frame: '+ iFr_h)
     if (iCo_h < iMyCo_h) {
     //** if there is no need of up and down arrows because we have all the thumnails visible
        $('#iprev').css('display', 'none');
        $('#inext').css('display', 'none');
        
        $('#frame').css('height', iMyCo_h+'px');
     }
     else {
         //** added on 14.10.2010
         var pp = jQuery.css( GE('content'), 'width', false ); // =offsetWidth
         pp -= 2*10; // 10 - margin
         GE('iprev').style.width = pp + 'px';
         GE('inext').style.width = pp + 'px'; //** ends here
    }
    
}


function SetNavigation(){

    //SetNewFrameWidth();
    SetDistLimit();
    
    if (typeof iCurImg != 'undefined') _1stActPos = iCurImg;
    
     //*** check if there is need of Previous/Next arrows or do nothing
    if (parseInt( jQuery.css( GE('content'), 'height', false )) < GS('frame','height')) {
        bAnyNav = false;
    }
    else {
        GE('content').style.top = '0px';
        bAnyNav = true;
        if (_1stActPos!=1) MoveImage(0); else checkConstraints();
    }
 

     //set events for prev/next buttons clicked
    YAHOO.util.Event.on('iprev', 'mousedown', MoveStrip, true);
    YAHOO.util.Event.on('inext', 'mousedown', MoveStrip, true);
    YAHOO.util.Event.on('iprev', 'mouseup', StopMoveStrip, true);
    YAHOO.util.Event.on('inext', 'mouseup', StopMoveStrip, true);
    
}

var iMSind, iSMSind;
var s=new Date();
var e=s;
var Limit;
var gSlideStep = 3;
var curSlideStep = gSlideStep;


function MoveStrip(){
    s = new Date()
    //this.className = this.id+'_hover';
    //*** wait 400ms before start continuously sliding
   // iSMSind = setTimeout('StartMoveStrip("'+this.id+'")',400);
    StartMoveStrip(this.id)
}
function StartMoveStrip(id){

   if (id == 'iprev') {
        par=-1; 
        Limit = 0; }
   else {
        par=1;
        Limit = arDist[arDist.length-1]; }
 
 //**  no continuosly move  for a start
 //**  iMSind = setInterval('MoveOne('+par+')',1);
}

function StopMoveStrip(){
    var par;
    
    e = new Date()
    //*** if the mouse button has been released within 400ms - then this is just single mose click
    //*** else - continuously click = sliding
    if (Math.ceil(e.getTime()-s.getTime()) < 400) {
        //*** if single click - stop the execution of the sliding function, only one position is needed
       // clearTimeout(iSMSind);
        if (this.id == 'iprev') par=-1; else par = 1;
        //** MoveImage(par);
        MoveImageSet(par);
    }
    else {
      checkConstraints(); 
    }
    //clearInterval(iMSind);
    
    //this.className = this.id;

}

function MoveOne(dir){

    var stopCond, changePosCond, changeEl;
 
    if (dir>0){ //*** next
          stopCond = ((Limit + GS('content', 'top')) <= 0 )
          changePosCond = ((arDist[_1stActPos] + GS('content', 'top')) <= 0 )  
          changeEl = changeActivePos(1, dir);
    }      
    else { //*** prev
        stopCond = ((Limit - GS('content', 'top')) <= 0 )
        changePosCond = ((arDist[_1stActPos-1] + GS('content', 'top')) >= 0 )  
        changeEl = changeActivePos(-1, dir);
   }
   
   //*** if 'Next' sliding..  
   if (dir>0) if (changePosCond) _1stActPos = changeEl;
  
   if ( stopCond ) { 
        clearInterval(iMSind);
        checkConstraints();
        return;
    }
    
     //*** if 'Prev' sliding..  
    if (dir<0) if (changePosCond) _1stActPos = changeEl;
    
    GE('content').style.top = GS('content', 'top')-dir*curSlideStep + 'px';
    //*** if after the latest movement has left less pixels than the fixed step (gSlideStep)
    //*** set the movement to take value the pixels that has left
    if (Math.abs(Limit-dir*GS('content', 'top'))< gSlideStep) curSlideStep = Math.abs(Limit-dir*GS('content', 'top'));
    else curSlideStep = gSlideStep;
    
}

function changeActivePos(step, dir){
    var _new1stActPos = _1stActPos+step;
    
 /*   if (dir*(_new1stActPos-Limit) >=0) {//dissappear arrow
        if (dir<0) ShowHideE('iprev', 'none'); else ShowHideE('inext', 'none');
    }
    
    // if strip has just left the first position in continuous 'next' sliding OR
    // the last position in continuous 'prev' sliding THEN
    //
    if (_new1stActPos != arDist[arDist.length-1]*(1-dir)/2) 
        if (dir>0) ShowHideE('iprev', 'block'); else ShowHideE('inext', 'block');
*/        
    return _new1stActPos;
}
      
var nl = '\n';
function SetDistLimit(){
   var p = jQuery.css( GE('content'), 'height', false );
   var slideLimit = p - GS('frame','height');
   
   arDist = new Array();
   arDist[0]=0;
   for (a=1; a<arDistO.length; a++){
        if (arDistO[a]<slideLimit) {
            arDist[a]= arDistO[a];
        }        
        else {
            arDist[a]= slideLimit;
            break;
         }
   }
}


function  SetNewFrameWidth(){
    //*** get the width of the box in which appeares the big image. This width depends on the width of the image
    //*** igNavArrW is left for the navigation arrows
    // set that width to the block that contains the thumbnails

  //  newW = (newW<gcMinFrameWidth? gcMinFrameWidth : newW) 
    
    if (exists('boxImg') && exists('boxText')){
        var iBoxImg = GE('boxImg').offsetWidth;
        var sBoxText = GE('boxText').offsetWidth;
      
        if (gcImgBox < iBoxImg){
            if (GE('tblTop')){
                GE('tblTop').style.width = gcMinTopTblWidth +(iBoxImg - gcImgBox )+'px';}
            GE('dvBxTxt').style.width = gcMinTxtWidth+'px';
       }else {
            GE('dvBxTxt').style.width = gcMinTxtWidth + (gcImgBox - iBoxImg)+'px';
            GE('tblTop').style.width = gcMinTopTblWidth+'px'
            }
        
    }else
        GE('tblTop').style.width = gcMinTopTblWidth+'px'
        
    var newW = GE('tbl_MI').offsetWidth - igNavArrW;
    newW = (newW<gcMinFrameWidth? gcMinFrameWidth : newW);
     GE('frame').style.width = newW + 'px';

    var newH = GE('tbl_MI').offsetHeight;
    GE('mainimage').style.height = newH + 'px';
}

 
    
function checkConstraints(){
/* this will be changed ****
    if (!bAnyNav){ //***if previously there have been some navigation arrows but we dont need it
        ShowHideE('iprev', 'hidden');
        ShowHideE('inext', 'hidden');
        return;
    }
    if (_1stActPos<=1 && GS('content','top')==0) ShowHideE('iprev', 'hidden'); else  ShowHideE('iprev', 'visible');
    if (_1stActPos>arDist.length) _1stActPos = arDist.length;
    if (_1stActPos == arDist.length ) ShowHideE('inext', 'hidden'); else  ShowHideE('inext', 'visible');
    
  *****/
   if (GE("assetpage")){
       if (_1stActPos<=1 && GS('content','top')==0) ShowHideE('iprev', 'hidden'); else  ShowHideE('iprev', 'visible');
       if (_1stActPos>arDist.length) _1stActPos = arDist.length;
       if (_1stActPos == arDist.length ) ShowHideE('inext', 'hidden'); else  ShowHideE('inext', 'visible');
   }
   else {
       if (_1stActPos<=1 && GS('content','top')==0)  $('#iprev').removeClass("iup"); else  $('#iprev').addClass("iup");
       if (_1stActPos>arDist.length) _1stActPos = arDist.length;
       if (_1stActPos == arDist.length ) $('#inext').removeClass("idown"); else  $('#inext').addClass("idown");
   
   }
   
}

function checkStatus(){
    //*** check which should be the _1stActPos index
   var left=Math.abs(GS('content','top'));
 
   for (a=_1stActPos; a<arDist.length; a++){
        if (arDist[a]<=left) _1stActPos=a+1;    //a;
        else break;
   };

    checkConstraints();
}

function SetImageALTColor(){
    //** set the text color of the <a> of the image the same as the background of the template body. This way when new image is loaded by ajax the alt text will not be visible while the image is loading and is not visible.
    $('#MyCont a').css('color', gsDocBodyBg);

}
//***
function checkEffect(){
    var z = YAHOO.util.Dom.getElementsByClassName('effects_th_1', 'img');
    if (z.length>0) imageborder += 1;
}

/****** common 1  **/
function ShowLoading(target){

    oMI = document.getElementById(target);
    if (oMI){
            var objILoading = document.createElement("div");
	        objILoading.setAttribute('id','imgLoading');
	        oMI.appendChild(objILoading);
    	    
	        var oL2 = document.createElement("div");
	        oL2.className = 'iL2';
	        objILoading.appendChild(oL2);
    	    
	        oL2.innerHTML = "<img src='CommonFiles/ajax-loader.gif' />"
	   
   }
 }
 function ShowLoadSymb(target){

    //oMI = document.getElementById(target);
    oMI = $('#'+target);
    if (oMI){
       bckgr = oMI.css('background');
       if (typeof bckgr=='undefined' || bckgr=='' || oMI.css('background-image') == 'none') 
                oMI.css('background', 'url(CommonFiles/ajax-loader.gif) center 85% no-repeat');
       
       //** set opacity to <a> element to make visible the background loading image of the <div id=target><a .../></div>
       $( 'a', '#'+target).css('opacity', '0.5'); 
   }
 }
 function HideLoadSymb(target){

    oMI = $('#'+target);
    if (oMI) oMI.css('background', 'none');
 }
 ///////////////////////////////////////////////////////////////////

 

function getClassProperty(sClass, sProperty, sETag){
      if (!sETag) sETag = 'div'
      var z = YAHOO.util.Dom.getElementsByClassName(sClass, sETag)
      z = z[0]
      z = YAHOO.util.Dom.getStyle(z, sProperty)
    
      return z;
}


/** Common Functions 2**/
function GE(id) {
    return document.getElementById(id)
}
function GS(id,style_property){
    return parseInt(YAHOO.util.Dom.getStyle(id, style_property) );
}
function myRemoveNode(obj){
  if (obj)   
      if (obj.removeNode)
                obj.removeNode(true);
       else { 
            var parent = obj.parentNode;
            parent.removeChild(obj);
        } 
}

function exists(id){
    if (GE(id)!=null) return true; else return false;
}

function togDisp(e,ind){
    stopB(e);
    var elems = getObjectsByClassName('moreButton');
    for(var i=0;i<elems.length;i++){
        var obj=elems[i];
       //  var dp="none";
       var dp = 'hidden';

       if (obj.id == (ind+'More')){
           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;
}
 // returns an array of id-s
function getElementsByClassName(className, parent){
    var oParent;
    var arr = new Array();
    if (parent) oParent = GE(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 = GE(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 ShowHideE(eID, state){
    if (GE(eID))
        GE(eID).style.visibility = state;
}
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>"
   
        
}
function alertProps(obj){
    var s='';
    for (a in obj)
        s += a+'='+obj[a]+'\t';
     
     for (a=0 ; a< s.length; a=a+2000)
           alert(s.substr(a, 2000))
}
/************************* end of common function *******************************/

function ShowHideInfoBlock(code){
    var oname = (this.id)? this.id.replace('closeB_','') : code;
     oname = eval ('o_'+ oname );
    if (oname) oname.hide();
}


function SetMarginTop(){
    var scrH = YAHOO.util.Dom.getViewportHeight();
    if (document.body) document.body.style.paddingTop = (scrH-iObjH)>0? (scrH-iObjH)/3 : 0 + 'px'; 
}
   

function GoL(link){
    if (link.length > 0) document.location.href = link;
}

function GetImagePage(z){
    // do nothing
    // do nothing - this function is refdefined in toledoNew_common.js
}
function ShowImgDetails(imgID){
    // do nothing - this function is refdefined in toledoNew_common.js
}
function changeClass(){

}


/******************** assets menu movement ********************/
var gItemsCurPage = 1;
//** the total number of the assets
var gItemsNUM = 1;
//** global variable that shows he acceptable asset items per 'page'
var gc_ItemsPerPage = 3;

function MoveAsset(dir){
    //** hide the current active items page
    var startP = (gItemsCurPage-1)*gc_ItemsPerPage + 1;
    for(a = startP; a<startP+gc_ItemsPerPage; a++){
        el = GE('c'+a);
        if (el) 
            YAHOO.util.Dom.replaceClass(el, 'ast_col_show', 'ast_col_hide');
    }
    //** set movement arrows visibility
    if (dir>0 && startP==1) YAHOO.util.Dom.setStyle(GE('prevasset'),'display','block');
    if (dir<0 && a-1>gItemsNUM) YAHOO.util.Dom.setStyle(GE('nextasset'),'display','block');

    //** set new active items page
    gItemsCurPage = gItemsCurPage+dir;
    startP = (gItemsCurPage-1)*gc_ItemsPerPage + 1;
    for(a = startP; a<startP+gc_ItemsPerPage; a++){
        el = GE('c'+a);
        if (el) 
            YAHOO.util.Dom.replaceClass(el, 'ast_col_hide', 'ast_col_show');
    }
    //** set movement arrows visibility
    if (dir>0 && a>gItemsNUM) YAHOO.util.Dom.setStyle(GE('nextasset'),'display','none');
    if (dir<0 && startP==1) YAHOO.util.Dom.setStyle(GE('prevasset'),'display','none');
}

function SetHideAssets(){
    var i=gc_ItemsPerPage+1;
    while (GE('c'+i)){
        YAHOO.util.Dom.replaceClass(GE('c'+i), 'ast_col_show', 'ast_col_hide');
        i++;
    }
    //** get in global variable the number of the assets
    gItemsNUM = i-1;
    //** show 'next' arrow if more assets than the visible on one page
    if (gItemsNUM > gc_ItemsPerPage)  YAHOO.util.Dom.setStyle(GE('nextasset'),'display','block');

}

function RemoveLastGalSep(){
   // alert($('td','#iens6div').length)
    var oo = $('span','#iens6div');
    if(oo) {
        oo = oo[oo.length-1];
        myRemoveNode(oo);
    }
}

function initA() {

     var iFr_h = parseInt( $('#frame').css('height'));
     var iCo_h = parseInt( jQuery.css( GE('content'), 'height', false ));
     var iMyCo_h = parseInt( $('#MyCont').css('height'));
     var iMI_h;
     if (GE('mainimage')){
        iMI_h = GE('mainimage').getElementsByTagName("img")[0].height;
        if ( iMI_h > iMyCo_h) {
            $('#MyCont').css('height', iMI_h+'px');
            $('#frame').css('height', (iMI_h - iMyCo_h + iFr_h)+'px');
        }
     }
     //  alert(iMyCo_h+nl+'content: '+iCo_h+'\n frame: '+ iFr_h)
     if (iCo_h < iMyCo_h) {
        $('#iprev').css('display', 'none');
        $('#inext').css('display', 'none');
        
        $('#frame').css('height', iMyCo_h+'px');
     }
     else {
        var a=0;
        while(++a){
            arDistO[a] = arDistO[a-1] + (iFr_h-10);
            if (arDistO[a]>iCo_h) {
                arDistO[a] = iCo_h;
                break;
            }
        }

        SetNavigation();
   
     }
   
    
}
