// JavaScript Document
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

//Home Page 
function TransferRequest(TargetLocation)
{
window.location.href=TargetLocation;

return false;
}

function resizeMe(obj){ 

    try
    {
        docHeight = window.frames[0].document.body.scrollHeight
        
        if(docHeight<=0)
        {         
            docHeight = '2500';         
        }
        
        obj.style.height = docHeight + 'px'
    }
    catch (e)
    {
        //docHeight = window.frames[1].document.body.scrollHeight
    }  
        
        
         
         
 } 
  function ShowConfirmPublish()
    {
    
    var r=confirm("Please make sure you have previewed your site before publishing, click 'OK' to continue.");
    return r;

    }
    function ShowTestWebsitePublishError()
    {
    
    confirm("This website is only intended for testing purposes and cannot be published. This website can only run in preview mode.");
    return false;

    }
 //End Home Page
 
 //Select Tem
function EndRequestHandler(sender, args)
{

   if (args.get_error() == undefined)
   {
    SetSelected();
    }
}

function SetSelected()
{ //v3.0o
     
      var CurrentSelected;
      CurrentSelected=document.getElementById("Selected");
      if(CurrentSelected)
        CurrentSelected.style.backgroundImage = 'url(/WebsiteBuilderV2/Images/bg-glow.gif)';
}

function HookHandler()
{
    SetSelected();
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}
function ShowConfirmChangeTemplateLayout()
    {
    
    var r=confirm("This action will change layout of selected template of your site(Preview-Mode).Home page content will be changed.You may find your existing page contents in 'Webpage Components' area of 'Edit Pages' section.Click 'OK' to continue.");
    return r;

    }
function ShowConfirmChangeTemplate()
    {
    
    //var r=confirm("This action will change template of your site(Preview-Mode).Home page content will be changed.You may find your existing page contents in 'Webpage Components' area of 'Edit Pages' section.Click 'OK' to continue.");
    var r=confirm("Please note - choosing a new design will completely override any other design you may have already built or had built for you. \nWould you like to proceed?");
    return r;

    }
 
 function ShowConfirmCustomInnerBG()
    {
    
    var r=confirm("This action will remove your uploaded background image for inner body.Click 'OK' to continue.");
    return r;

    }
  
 
 //End Select Tem
 
 //Change Logo
 
 
        function startCallback() 
        {
            document.getElementById("processDiv").style.display = "block";// the progress div
            return true;
        }

        function completeCallback(response) 
        {
          
          
           document.getElementById("processDiv").style.display = "none";// hide progresss div
          // document.getElementById("ImgLogo").src=response;
        }
  


 //End change logo
 
 //Change Banner
 
 function ShowConfirmUseBanner()
    {
    
    var r=confirm("This action will replace banner of all the pages with current banner, click 'OK' to continue.");
    return r;

    }
 
 //End Change Banner
 
  //Header & Footer
function limit(what,chars,counter) { 

if (what.value.length > chars) { 
what.value=what.value.substr(0,chars); 
//alert('max chars' + chars); 
} 

counting = (chars - what.value.length); 
c = document.getElementById(counter); 
c.innerHTML = 'Characters left: ' + counting; 
} 




    function onEditWidgetTitle(sender, e) {
       Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestWidgetTitle);

            
           __doPostBack(sender,e); 
          


        }

 function BindEndRequest(sender, e) {
       Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestWidgetTitle);

            
           
          


        }
        
function resizeFrame()
{
    var obj=window.parent.document.getElementById('iframeChilePage');
    
    if(obj==null)
        return;
    
    try
    {       
        docHeight = window.parent.frames[0].document.body.scrollHeight
        
        if(docHeight<=0)
        {         
            docHeight = '2500';         
        }
        obj.style.height = docHeight + 'px'
     
        var obj=window.parent.document.getElementById('iframeMembersPage');
        if(obj==null)
            return;

        docHeight = window.parent.frames['iframeMembersPage'].document.body.scrollHeight            
        if(docHeight<=0)
        {         
            docHeight = '2500';         
        } 
        obj.style.height = docHeight + 'px'
    }
    catch (e)        
    {
        //docHeight = window.parent.frames[1].document.body.scrollHeight
    }    
 } 
 
 function resizeFrameAbs()
 {      
    var obj=window.parent.document.getElementById('iframeChilePage');
    if(obj==null)
        return;
    
    try
    {   
        docHeight = window.parent.frames[0].document.body.scrollHeight
        
        if(docHeight<1500)
        {         
            obj.style.height = '1500px';         
        }
         
        var obj=window.parent.document.getElementById('iframeMembersPage');
        if(obj==null)
            return;
        
        docHeight = window.parent.frames['iframeMembersPage'].document.body.scrollHeight
        
        if(docHeight<1500)
        {         
            obj.style.height = '1500px';
        }
    }
    catch (e)        
    {
        //docHeight = window.parent.frames[1].document.body.scrollHeight
    }         
             
 }  
 
  function EndRequestWidgetTitle(sender, args)
  {
  
    if (args.get_error() == undefined)
    {
   
        resizeFrame();
        
         
    
    }
    
  }
 
  //End Header & Footer
  
  //Widget Library
  function ShowConfirmDelete()
    {
    
    var r=confirm("This action will delete the widget permanently, click 'OK' to delete.");
    return r;

    }
    function DenyDelete()
    {
    
    alert("Sorry, You can't delete a widget which is used in any page.");
    return false;

    }
  
  //End Widget Library
  //Change Menu
  function ShowConfirmMenuDelete()
    {
    
    var r=confirm("This action will delete the selected menu permanently, click 'OK' to delete.");
    return r;

    }
  function ShowConfirmLinkDelete()
    {
    
    var r=confirm("This action will delete the selected link permanently, click 'OK' to delete.");
    return r;

    }
  //End change menu
  //Edit Pages
  
   function ShowConfirmPageDelete()
    {
    
    var r=confirm("This action will delete the page permanently, click 'OK' to delete.");
    return r;

    }
    function DenyPageDelete()
    {
    
    alert("Sorry, You can't delete Home Page.");
    return false;

    }
   function WidgetAdded()
    {
    
    alert("Webpage Component Successfully added.");
    

    }
    function SSLRequiredWarning()
    {
    
    var r=confirm("Are you sure you want to change security settings of this page? click 'OK' to proceed.");
    return r;

    }
  //For Collapsible panel events

function attachCpeHandler()
    {
	
	//Sys.Application.remove_load(attachCpeHandler);
	var cpe = $find('CP1');
	cpe.add_collapseComplete(cpeCollapseComplete);
	cpe.add_expandComplete(cpeExpandComplete);
    }

    function cpeCollapseComplete()
    {
	
	 resizeFrame();
	 
    }

    function cpeExpandComplete()
    {
	
	 resizeFrame();
    }

    
 function OnApplicationLoad() 
        {
        
            Sys.Application.add_load(attachCpeHandler);
           
            return false;
        }

function ManageLinks(ManagePath)
{

window.parent.SelectedTab="Header1_imgBtnChangeMenu";

var item=window.parent.document.getElementById("Header1_ImgBtnEditPages");
item.src="/WebsiteBuilderV2/Images/icon-edit-page-00.gif";

var item1=window.parent.document.getElementById("Header1_imgBtnChangeMenu");
item1.src="/WebsiteBuilderV2/Images/icon-change-logo-01.gif";


window.location.href=ManagePath;

return false;
}

function ManageWidgetTurnedOffWizard()
{
    alert("You can not manage this widget using Wizard, Please use advanced website builder");
    return false;
}

//end claapsible panel
  /* UnUsed function for settings modal popup position
  function onEditClicked(sender, e) {
  var mouseX = event.clientX;
var mouseY = event.clientY;

alert(mouseX);
alert(mouseY); 
  } */
  
  //End Edit Pages
