
var FBPUILib=new Object();FBPUILib.Framework=new Object();FBPUILib.Framework.Validation=function()
{this.type='validation';this.AT_SIGN='@';this.ML_DOMAIN='ml.com'
this.AT_ML_DOT_COM=this.AT_SIGN+this.ML_DOMAIN;this.PROFILE_MAX_CHAR=2100;this.ADDPROFILE_MAX_CHAR=5850;}
var jsFBPUI;
// **********************************************************************************

//***************  Global error messages ********************************************
//***********************************************************************************
var prvTemaplate,checkTemaplate=true;
  var divTemplate,left,top,objImage,imgDiv,offsetHeight,scrollHt,image;
  
  function ExpandImage(objImg)
  { 
    left = objImg.getBoundingClientRect().right + 5;
    top = objImg.getBoundingClientRect().top;
    scrollHt = objImg.document.body.scrollTop;
    objImage = objImg;
    if(objImg.className!='showMouseSelected')
       objImg.className='showMouseOver';
    divTemplate = document.getElementById("dvTemplate");
    if(divTemplate.innerHTML == '')
    {
       CreateImage(objImg);
    }  
    else
    {
       //removeClass();	
       divTemplate.innerHTML = '';
       imgDiv.innerHTML = '';
       imgDiv.style.display = 'none';
       CreateImage(objImg);
    }
    
    
  }
   
  function closeImage(objImg)
  {
    if(objImg.className!='showMouseSelected'){objImg.className='showMouseOut';}  
    divTemplate.style.display = "none";
    imgDiv.style.cssText='';
    imgDiv.style.display = "none";
    imgDiv.style.height='0px';
    imgDiv.style.width='0px';
    imgDiv.innerHTML = '';    
  }
   
   function trim(str, chars) {
        return ltrim(rtrim(str, chars), chars);
    }
     
    function ltrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    }
     
    function rtrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    }

   function selectImage(objImg)
   {
         
         removeClass();
         objImg.className='showMouseSelected'
         var rdbtnImg = document.getElementsByTagName('input');
         for(i=0;i<rdbtnImg.length;i++)
         {
            rdbtnImg[i].checked=false;
         }        
         var currentTemplate=objImg.parentNode.getElementsByTagName('span')[0].innerHTML;
         currentTemplate = trim(currentTemplate,' ');
         if(typeof(templateName)!='undefined')
         {
             if(templateName==currentTemplate)
               {
		              if(document.getElementById(dvError).innerHTML!='')
                    {
                        document.getElementById(dvError).innerHTML='';
                        document.getElementById(dvError).innerHTML='This Template is already selected For FA';                        
                    }
                    else
                    {
                        document.getElementById(dvError).innerHTML='This Template is already selected For FA';
                        document.getElementById(dvError).style.display ="block";
                    }
                    document.getElementById(lnkNext).disabled = true;
               }
               else
               {
                    document.getElementById(dvError).innerHTML='';
                    document.getElementById(dvError).style.display ="none";
                    document.getElementById(lnkNext).disabled = false;
               }
	   	}
         objImg.parentNode.getElementsByTagName('input')[0].checked = true;
   }
   function removeClass()
   {
     var imgTag = document.getElementsByTagName('img');
            for(i=0;i < imgTag.length;i++)
            {
                if(imgTag[i].parentNode.className == 'showMouseSelected')               
                    imgTag[i].parentNode.className ='';                                                       
            }
   }
    function CreateImage(objImg)
{  
        loadimage = document.createElement('img');
        loadimage.src ='/publish/FA/Images/FBPUI/wait.gif';
        divTemplate.className = "loading";
        top += scrollHt; 
        divTemplate.style.cssText = "left:"+ left +"px;top:"+ top +"px;";
        divTemplate.appendChild(loadimage);
        imgDiv=document.createElement('div');
        imgDiv.id='imgDivId';
        document.body.appendChild(imgDiv);
        imgDiv.className = "loading";
        
        imgDiv.style.cssText='left:'+ left +'px;top:'+ top +'px;position:absolute;z-index:9998;';
        imgDiv.style.display='none';
        image =document.createElement('img')
        image.style.width = '0px';
        image.style.height= '0px';
        imgDiv.appendChild(image);
        image.onload = function(){showImg(objImg);};
        image.src =objImg.getElementsByTagName('img')[1].src;                
}

  function showImg(objImg)
  {
  imgDiv.style.width="0px";
  imgDiv.style.height="0px";
  setTimeout('divTemplate.style.display="none";imgDiv.style.display="block";',1000);
    $(document).ready(function(){
    $(image).ready(function(){
    $(image)
     .animate({ 
        width: "300px",
        height: "400px"}, 1500 );
    });
    });   
  }
  
  function Goback()
  {
   window.history.go(-1);
   
   return false; 
  }
   function closeWindow()
   {
        self.close();
   }
   
   function changeHeight() 
{    
      if (divTemplate)
       {
          divTemplate.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
          //var docHt = getDocHeight(iframeWin.document);
          // need to add to height to be sure it will all show 
      
          divTemplate.style.cssText ='background-color:#FFFFFF;position:absolute;left:'+left+'px;top:'+top+'px;width:150px;height:150px;display:none';    
          toggleAnim(divTemplate,1000,0,500);  
          }
}



var currentContent = null;
var currentIndex;
function toggleAnim(id, interval,closeFlag,maxheight)
{
var content=id;
Closeflag=closeFlag;
currentIndex=id;
    // wait for another animated expand/collapse action to end
           
        currentContent = content;
           content.style.display = "block";                      
        var max_height = maxheight;      
       var step = 2;
        var step_height = step + (true ? 0 : -max_height);
        var step_width = step_height;        
        content.style.height = "50px";
        content.style.width = "50px";
        initialvalue = true;
        setTimeout("toggleStatusHeight("+ interval + "," + step+ "," + max_height + "," + step_height +  ")", interval);        
}

 function toggleStatusHeight( interval, step,max_height, step_height )
{
    var step_height_abs = Math.abs(Math.ceil(step_height));    
    if(true)
    {
        if(step_height_abs  < max_height)
        {
            step_height += step;            
            if(step_height > max_height)
            {
                step_height = max_height;
            }
        }       
            currentContent.style.height =Math.abs(step_height)+ "px";             
            currentContent.style.left = left + "px";
            currentContent.style.top = top + "px";           
            currentContent.style.position = "absolute";          
    }     
        setTimeout("toggleStatusHeight(" + interval + "," + step+ "," + max_height + ","  + step_height +")", interval);      
  }