﻿// JScript File

var isMozilla;
var objDiv = null;
var X = 0;
var Y = 0;
var DivID; // = "divpopup";
var over = false;
var popupshown=false;
var divContentID;

function MouseDown(e) 
{
var PopupdivID;
if (popupshown_O == true)
{    PopupdivID = "divpopup_O";
DivID="divpopup_O";
}
else
{   
    PopupdivID = "divpopup";
    if((DivID!=null)&&(DivID.indexOf("section")<0))
    {   
        DivID="divpopup";
    }
}


    if(DivID!=PopupdivID && DivID!="TopFrame1_pnlIMPopUp" && DivID!=null)
    { 
      MyHomeMouseDown(e);
      return;
    }

	if (over)
	{
		if (isMozilla) {
		    if(DivID!=null)
		    {
			    objDiv = document.getElementById(DivID);
			    X = e.layerX;
			    Y = e.layerY;
			    return false;
			}
		}
		else 
		{
		    if(DivID!=null)
		    {
			    objDiv = document.getElementById(DivID);
			    objDiv = objDiv.style;
			    X = event.offsetX+event.srcElement.offsetLeft;
			    Y = event.offsetY+event.srcElement.offsetTop;
			}
			//alert(X);
		}
	}
}

function MouseMove(e) 
{

var PopupdivID;
if (popupshown_O == true)
{    PopupdivID = "divpopup_O";
    DivID="divpopup_O";
}
else
{   PopupdivID = "divpopup";
    if((DivID!=null)&&(DivID.indexOf("section")<0))
    {   
        DivID="divpopup";
    }
}

// if(DivID!="divpopup" && DivID!="TopFrame1_pnlIMPopUp" && DivID!=null)
//    {
//        MyHomeMouseDown(e);
//        return;
//    }
    
    if(DivID!=PopupdivID && DivID!="TopFrame1_pnlIMPopUp" && DivID!=null)
    {
        MyHomeMouseMove(e);
        return;
       
    }

	if (objDiv) {
		if (isMozilla) {
			objDiv.style.top = (e.pageY-Y) + 'px';
			objDiv.style.left = (e.pageX-X) + 'px';
			return false;
		}
		else 
		{
			objDiv.pixelLeft = event.clientX-X + document.documentElement.scrollLeft;
			objDiv.pixelTop = event.clientY-Y + document.documentElement.scrollTop;
	return false;
		}
	}
}

function MouseUp() 
{
var PopupdivID;
if (popupshown_O == true)
{    PopupdivID = "divpopup_O";
DivID="divpopup_O";
}
else
{   
   PopupdivID = "divpopup";
    if((DivID!=null)&&(DivID.indexOf("section")<0))
    {   
        DivID="divpopup";
    }
}
    if(DivID!=PopupdivID && DivID!="TopFrame1_pnlIMPopUp" && DivID!=null)
    {
      
         MyHomeMouseUp();
         return;
        
    }
//    if(typeof(DivID_O) != 'undefined'   && DivID_O != "divpopup_O" )
//       {
//         MyHomeMouseUp();
//         return;
//        }
	objDiv = null;
}

function init()
{
	// check browser
	isMozilla = (document.all) ? 0 : 1;

	if (isMozilla) 
	{
		document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
	}

	document.onmousedown = MouseDown;
	document.onmousemove = MouseMove;
	document.onmouseup = MouseUp;
	//buildFlashDivTag();
	
}

// calling init
var Path; 
var PageName;
Path = self.location.href ;
PageName = Path.substring(Path.lastIndexOf("/")+1 ,Path.length);

//If condition added by Archana on 11th Sep to skip the below code for MyHomePage    
//if (PageName  != "MyHomePage.aspx")
{    
    init();
}


function DisableBackground()
{
    //Code for making the background gray
    //Create empty image tag for graying out the background
    var objBlankImage;
    objBlankImage=document.getElementById("bg_image");
    var Path = self.location.href;
    var PageName = Path.substring(Path.lastIndexOf("/")+1 ,Path.length);
    //Check if the popup is already created
    if(objBlankImage==null)
    {
        try
        {
            //For IE
            if (Path.indexOf("/Event/") == -1)
            {
                 objBlankImage=document.createElement('<div id="bg_image" style="z-index: 900; left: 0px; width: 100%; position: absolute; top: 0px; height: auto; background-color:#000000; display:none; border-right: 0px solid; border-top: 0px solid; border-left: 0px solid; border-bottom: 0px solid;">');     
            }
            else
            {
                objBlankImage=document.createElement('<div id="bg_image" style="z-index: 900; left: 0px;position: absolute; top: 0px; height: auto; background-color:#000000; display:none; border-right: 0px solid; border-top: 0px solid; border-left: 0px solid; border-bottom: 0px solid;">');     
            }
           
        }
        catch(e)
        {
            //for firefox
            objBlankImage=document.createElement("div");
            objBlankImage.setAttribute("id", "bg_image");
            //objBlankImage.setAttribute("src", "images/activetab.gif");
             if (Path.indexOf("/Goultra/Event/") == -1)
             {
                objBlankImage.setAttribute("style", "z-index: 900; left: 0px; width: 100%; position: absolute; top: 0px; height: 100%; background-color:#000000; display:block; border-right: 0px solid; border-top: 0px solid; border-left: 0px solid; border-bottom: 0px solid;");
                
             }
             else
             {
                objBlankImage.setAttribute("style", "z-index: 900; left: 0px; position: absolute; top: 0px; height: 100%; background-color:#000000; display:block; border-right: 0px solid; border-top: 0px solid; border-left: 0px solid; border-bottom: 0px solid;");
             }
        }
    }
    
    objBlankImage.style.filter="alpha(opacity=50)";
    objBlankImage.style.MozOpacity="0.5";
    objBlankImage.style.opacity="0.5";
    objBlankImage.style.display='block';
    document.body.appendChild(objBlankImage);
    if (Path.indexOf("/Goultra/Event/") == -1)
    {
        objBlankImage.style.height=(document.body.offsetHeight)*70 +"px";
    }
    if(document.all)
    {
	    objBlankImage.style.width=(document.body.offsetWidth)+ (document.body.offsetLeft*2)+"px";
	}
	
	if (Path.indexOf("/SetUpVolunteerRegistration.aspx") != -1)
    {
        objBlankImage.style.height=(document.body.offsetHeight)*90 +"px";
    }
	//alert("document.body.offsetHeight = "+document.documentElement.clientHeight+"document.body.offsetWidth = "+document.body.offsetWidth);
	
	//make all drop down lists invisible
	var arrobj=document.getElementsByTagName("select");
	//alert(arrobj.length);
	for(i=0;i<arrobj.length;i++)
	{
	    //alert(arrobj[i].name);
	    arrobj[i].style.display = "none";
	}
	if(document.getElementById('ddlSecurityQuestion')!=null)
	    document.getElementById('ddlSecurityQuestion').style.display='block';
	    
	if(document.getElementById('ddlSearchDistance')!=null)
	    document.getElementById('ddlSearchDistance').style.display='block';
	    
   var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
	 
	//Newly added to make all objects invisible for safari browser.
    var is_Safari = navigator.userAgent.indexOf('Safari');
	if((is_Safari >0)&&(is_chrome==false))
	{
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {
	        //alert(arrobj[i].name);
	        arrobj[i].style.visibility = "hidden";
	    }
	}
	
}



function ShowModalPopup(popupContentID,title,size)
{      

    var popupcontrol;
    popupcontrol=document.getElementById("divpopup");
    
    
            
    var contentObj=document.getElementById(popupContentID);
    divContentID = popupContentID;
//    if(title == "Default Workout Settings")
//            contentObj.style.height = "350px";
  
    document.getElementById("hidContentID").value=popupContentID;
    
    if(contentObj!=null)
    {        
        document.getElementById("popupcontentholder").appendChild(contentObj);
        
        document.getElementById("popupHeader").innerHTML=title;
        //document.body.appendChild()
        contentObj.style.display="block";
        popupcontrol.style.display="block";
        
    }
    
    //Display the window in the center of the screen
    var pleft,ptop;
    var isMozilla = (document.all) ? 0 : 1;
    
    if(isMozilla)
    {
        pleft=(document.body.offsetWidth/2)-(popupcontrol.offsetWidth/2) + window.pageXOffset;
        ptop=(window.innerHeight/2)-(popupcontrol.offsetHeight/2) + window.pageYOffset;
    }
    else
    {
        pleft=(document.documentElement.offsetWidth/2)-(popupcontrol.offsetWidth/2) + document.documentElement.scrollLeft;
        ptop=(document.documentElement.offsetHeight/2)-(popupcontrol.offsetHeight/2) + document.documentElement.scrollTop;
    }
//  alert("title="+title.substring(0,15));  
//  str.substring(1,15));  
    if(ptop < 0)
    {   
         if(title.indexOf("Workout Log For")!=-1 )
         {
                if(ptop < document.getElementById("topAds").offsetHeight)
                {
                    ptop=150;
                      
                 }
                 else
                 {
                    ptop = 0;
                 }
         }
         else
         {
            ptop = 0;
         }
              
    }
    if(title.indexOf("Workout Log")!=-1 || title.indexOf("Plan a workout")!=-1 )
         {
                    ptop=450;
         }
    if( title=="Log Report Summary")
    {  
         if(ptop < document.getElementById("topAds").offsetHeight)
         {
            
             ptop=150;
          }
          else
          {
              ptop = 0;
          }
    }
//    if(title.indexOf("Workout Log For")!= -1 )
//    {
////        if (document.getElementById("tblLeftColumn") != null)
////        {            
////             if(pleft < document.getElementById("tblLeftColumn").offsetWidth)
////             {
////                pleft=document.getElementById("tblLeftColumn").offsetWidth + parseInt('25');
////             }
////         }
////         if (document.getElementById("tblLeftColumn") != null)
////        {            
////             if(pleft < document.getElementById("tblLeftColumn").offsetWidth)
////             {
////                pleft=document.getElementById("tblLeftColumn").offsetWidth + parseInt('25');
////             }
////         }
//        pleft = pleft - (pleft/2);
//        ptop = ptop - ptop/2;
//    }
    if (Path.indexOf("/Goultra/Event/") != -1)
    {
        pleft = pleft - (pleft/2);
        ptop = ptop - ptop/2;
    } 
    else
    {
         DisableBackground();
          if(title == "Default Workout Settings")
          {
             var objBlankImage;
             objBlankImage=document.getElementById("bg_image");
             if(objBlankImage != null)
             {
                var height = objBlankImage.style.height;
                height = height.replace("px","");
                objBlankImage.style.height  = height*10 +"px"
             }
          }   
             else if(title.indexOf("Workout Log For")!=-1)
          {
             var objBlankImage;
             objBlankImage=document.getElementById("bg_image");
             if(objBlankImage != null)
             {
                var height = objBlankImage.style.height;
                height = height.replace("px","");
                objBlankImage.style.height  = height*1.2  +"px"
             }
          }
          else if(title.indexOf("Completed Workout Log")!=-1)
          {
             var objBlankImage;
             objBlankImage=document.getElementById("bg_image");
             if(objBlankImage != null)
             {
                var height = objBlankImage.style.height;
                height = height.replace("px","");
                objBlankImage.style.height  = height*1.2  +"px"
             }
          }
          else if(title.indexOf("Import Workout Data")!=-1)
          {
             var objBlankImage;
             objBlankImage=document.getElementById("bg_image");
             if(objBlankImage != null)
             {
                var height = objBlankImage.style.height;
                height = height.replace("px","");
                objBlankImage.style.height  = height*10  +"px"
             }
          } 
           else if(title.indexOf("Plan a workout")!=-1)
          {
             var objBlankImage;
             objBlankImage=document.getElementById("bg_image");
             if(objBlankImage != null)
             {
                var height = objBlankImage.style.height;
                height = height.replace("px","");
                objBlankImage.style.height  = height*1.2  +"px"
             }
          } 
           else if(title.indexOf("Event Details")!=-1)
          {
             var objBlankImage;
             objBlankImage=document.getElementById("bg_image");
             if(objBlankImage != null)
             {
                var height = objBlankImage.style.height;
                height = height.replace("px","");
                objBlankImage.style.height  = height*10  +"px"
             }
          }
        
    }   
    popupcontrol.style.left=pleft+"px";
    popupcontrol.style.top=ptop+"px";
    //alert(window1.pageYOffset);
    
    
    
   
    //popupcontrol.style.zIndex=1000;
    
    popupshown=true;
    //alert(popupcontrol);
    
    //make all drop down lists visible by ritesh for log settings
	var arrobj=document.getElementsByTagName("select");
	//alert(arrobj.length);
	for(i=0;i<arrobj.length;i++)
	{
	    //alert(arrobj[i].name);
	    arrobj[i].style.display = "none";
	}
	
	if(document.getElementById("ddLstAlbumVisibility") != null)
	    document.getElementById("ddLstAlbumVisibility").style.display = "block";

    var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
   //Newly added to make all objects invisible for safari browser.
	var is_Safari = navigator.userAgent.indexOf('Safari');
	
	if((is_Safari >0)&&(is_chrome==false))
	{  
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {
	        //alert(arrobj[i].name);
	         arrobj[i].style.visibility = "hidden";
	    }
	}		
	// Change the class According to popup size
	if((size == 'L') || (size == 'l'))
	{
	    document.getElementById("trContaintHolder").className="clsModalPopupLargeMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupLargeTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupLargeBottom";
        document.getElementById("trContaintHolder").style.width = "765px";
        document.getElementById("trPopUpTop").style.width = "765px";
        document.getElementById("trPopUpBottom").style.width = "765px";
	}
	else if((size == 'S') || (size == 's'))
	{
	    document.getElementById("trContaintHolder").className="clsModalPopupSmallMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupSmallTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupSmallBottom";
        document.getElementById("trContaintHolder").style.width = "366px";
        document.getElementById("trPopUpTop").style.width = "366px";
        document.getElementById("trPopUpBottom").style.width = "366px";
	}
	else if ((size == 'C') || (size == 'c'))
	{
	    
	    document.getElementById("trContaintHolder").className="clsModalPopupCustomMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupCustomTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupCustomBottom";
        document.getElementById("trContaintHolder").style.width = "460px";
        document.getElementById("trPopUpTop").style.width = "460px";
        document.getElementById("trPopUpBottom").style.width = "460px";
	}
	else
	{
	    document.getElementById("trContaintHolder").className="clsModalPopupMediumMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupMediumTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupMediumBottom";
	    document.getElementById("trContaintHolder").style.width = "566px";
	     document.getElementById("trPopUpTop").style.width = "566px";
        document.getElementById("trPopUpBottom").style.width = "566px";
	}
	  
	 // GPSPopupload();
    return(false);
}

function closepopup(popupContentID)
{   

    var popupcontrol=document.getElementById("divpopup");
    //var contentObj=document.getElementById(popupContentID);
    
    var ContentId=document.getElementById("hidContentID").value;
    var contentObj;
    if(ContentId !="")
    {
        contentObj=document.getElementById(ContentId);
    }
    if(contentObj!=null)
    {  
        contentObj.style.display="none";
    }      
      
    if(popupcontrol!=null)
    {   
        popupcontrol.style.display="none";
    }
    
   
     
    var txtboxObj = document.getElementById("txtTopicName");
    if(txtboxObj!= null && txtboxObj != "")
    {
        txtboxObj.value = "";   
    }
    
    txtboxObj = document.getElementById("txtTopicDescription");
    if(txtboxObj!= null && txtboxObj != "")
    {
        txtboxObj.value = "";   
    }
    var hidReplyEditObj = document.getElementById("hid_ReplyEdit")
        if(hidReplyEditObj != null && hidReplyEditObj!= "")
        {
            hidReplyEditObj.value = "";
        }
    var topicIdObj = document.getElementById("hid_TopicId");
        if(topicIdObj != null && topicIdObj!= "")
        {
            topicIdObj.value = "";
        }

     //To reset the value of the RSS title 
     var _RSSTitle = document.getElementById("txtRSSHeader");
     if(_RSSTitle != null && _RSSTitle!= "")
     { 
         _RSSTitle.value = "";
     }
     
     //To reset the value of the RSS URL 
     var _RSSURL = document.getElementById("txtRSSUrl");
     if(_RSSURL != null && _RSSURL!= "")
     { 
        _RSSURL.value = "";
     }
     
     //To reset the value of the cell containing Invalid RSS message
     var _RSSInvalidMsgCell = document.getElementById("tdInvalidRSS");
     if(_RSSInvalidMsgCell != null && _RSSInvalidMsgCell != "")
     {
       _RSSInvalidMsgCell.style.display = "none";
     
       //To reset the value of Invalid RSS message label
       var _RSSInvalidMsg = document.getElementById("WarningMsgs_RegistrationErrors");
       if(_RSSInvalidMsgCell != null && _RSSInvalidMsgCell != "")
       {
        _RSSInvalidMsg.value = "";
       }
     }
        
        if(document.getElementById("bg_image") != null)
        {
            document.getElementById("bg_image").style.display="none";
        }
    
    //make all drop down lists invisible
	var arrobj=document.getElementsByTagName("select");
	//alert(arrobj.length);
	for(i=0;i<arrobj.length;i++)
	{
	    //alert(arrobj[i].name);
	    arrobj[i].style.display = "block";
	}
	
	var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
	
	//Newly added to make all objects invisible for safari browser.
	var is_Safari = navigator.userAgent.indexOf('Safari');	
	if((is_Safari >0)&&(is_chrome==false))
	{
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {	       
	        //alert(arrobj[i].name);
	        arrobj[i].style.visibility = "visible";  
	    }
	}
    popupshown=false;
    
//    if(document.getElementById("hiddenLogPopupStatus")!=null)
//    {   //To allow again logcalendar popup visible
//        document.getElementById("hiddenLogPopupStatus").value="";
//    }

    var temp = document.getElementById("hiddenEditLogPopupStatus");
	if(temp != null)
	{
		temp.value = "true";
	}
	
	var Url;
    Url=String(self.location);

    if( Url.indexOf("LogDetails.aspx") > 0)
    {
      //alert("perfect");
      if(document.getElementById("divlblLogSettings") != null && document.getElementById("divlnkLogSettings") != null)
    {
        document.getElementById("divlblLogSettings").style.display="none";
        document.getElementById("divlnkLogSettings").style.display="block";
        document.getElementById("divlblViewLog").style.display="block";
        document.getElementById("divlnkViewLog").style.display="none";
        
        document.getElementById("td1liLogSetttings").className = "clsLHSMenuLight";
        document.getElementById("td2liLogSetttings").className = "clsLHSMenuLight";
        
        document.getElementById("td1liLogView").className = "clsLHSSelectedMenuArrows";
        document.getElementById("td2liLogView").className = "clsLHSSelectedMenu";
      
        document.getElementById("imgViewLogArrow").src = "../../Images/LHSMenus/red_arrow.png";
        document.getElementById("imgLogSettingsArrow").src = "../../Images/LHSMenus/arrow-bullets.png";
    }
    }

    return false;
}


//For LogDetails.aspx this window.onresize function is not required
var currUrl;
currUrl=String(self.location);

//if( currUrl.indexOf("LogDetails.aspx") > 0)
//{
//  alert("perfect");
//}
var logUrl= currUrl.indexOf("LogDetails.aspx");

var planUrl= currUrl.indexOf("CreatePlan.aspx");

if((logUrl > 0)||(planUrl > 0))
{
    //alert(currUrl);
}
else
{
    window.onresize=window.onscroll=function()
    {
        isMozilla = (document.all) ? 0 : 1;
        if(popupshown)
        {
            var popupcontrol;
            popupcontrol=document.getElementById("divpopup");
        
        
            if(popupcontrol!=null)
            {
                //Display the window in the center of the screen
                var pleft,ptop;
                var isMozilla = (document.all) ? 0 : 1;
                
                if(isMozilla)
                {
                    pleft=(document.body.offsetWidth/2)-(popupcontrol.offsetWidth/2)+window.pageXOffset;
                    ptop=(window.innerHeight/2)-(popupcontrol.offsetHeight/2)+window.pageYOffset;
                }
                else
                {
                    pleft=(document.documentElement.offsetWidth/2)-(popupcontrol.offsetWidth/2)+document.documentElement.scrollLeft;
                    ptop=(document.documentElement.offsetHeight/2)-(popupcontrol.offsetHeight/2)+document.documentElement.scrollTop;
                }
                popupcontrol.style.left=pleft+"px";
                popupcontrol.style.top=ptop+"px";    
                
                if(!isMozilla)
                {
                    var objBlankImage=document.getElementById("bg_image");
                    if(objBlankImage)
                    {
                        objBlankImage.style.width=(document.body.offsetWidth)+ (document.body.offsetLeft*2)+"px";
                    }
                }
            }
        
        }

        //Added to refresh the menus to avoid the window resize problem
        if(!isMozilla)
        {
            if(document.getElementById("menu")!=null)
            {
                //document.getElementById("menu").style.display="none";
                //document.getElementById("menu").style.display="block";
              }
        }     
        
    };
}


/******************************************************************/

var popupshown_O=false;
function ShowModalPopup_O(popupContentID,title)
{
    var popupcontrol;
    popupcontrol=document.getElementById("divpopup_O");
    
    var contentObj=document.getElementById(popupContentID);
    divContentID = popupContentID;
  
    document.getElementById("hidContentID_O").value=popupContentID;
    
    if(contentObj!=null)
    {        
        document.getElementById("popupcontentholder_O").appendChild(contentObj);
        
        document.getElementById("popupHeader_O").innerHTML=title;
        //document.body.appendChild()
        contentObj.style.display="block";
        popupcontrol.style.display="block";
        
    }
    
    //Display the window in the center of the screen
    var pleft,ptop;
    var isMozilla = (document.all) ? 0 : 1;
    
    if(isMozilla)
    {
        pleft=(document.body.offsetWidth/2)-(popupcontrol.offsetWidth/2) + window.pageXOffset;
        ptop=(window.innerHeight/2)-(popupcontrol.offsetHeight/2) + window.pageYOffset;
    }
    else
    {
        pleft=(document.documentElement.offsetWidth/2)-(popupcontrol.offsetWidth/2) + document.documentElement.scrollLeft;
        ptop=(document.documentElement.offsetHeight/2)-(popupcontrol.offsetHeight/2) + document.documentElement.scrollTop;
    }
  
    if(ptop < 0)
    {   
          if(title.indexOf("Workout Log For")!=-1 )
         {
                if(ptop < document.getElementById("topAds").offsetHeight)
                {
                    ptop=150;
                 }
                 else
                 {
                    ptop = 0;
                 }
         }
         else
         {
            ptop = 0;
         }
              
    }
    if( title=="Log Report Summary")
    {  
         if(ptop < document.getElementById("topAds").offsetHeight)
         {
            
             ptop=150;
          }
          else
          {
              ptop = 0;
          }
    }
    if(title.indexOf("Workout Log For")!=-1 )
    {
        if (document.getElementById("tblLeftColumn") != null)
        {            
             if(pleft < document.getElementById("tblLeftColumn").offsetWidth)
             {
                pleft=document.getElementById("tblLeftColumn").offsetWidth + parseInt('25');
             }
         }
         if (document.getElementById("tblLeftColumn") != null)
        {            
             if(pleft < document.getElementById("tblLeftColumn").offsetWidth)
             {
                pleft=document.getElementById("tblLeftColumn").offsetWidth + parseInt('25');
             }
         }
    }
        
    popupcontrol.style.left=pleft+"px";
    popupcontrol.style.top=ptop+"px";
    //alert(window1.pageYOffset);
   
    
    
    DisableBackground();
    //popupcontrol.style.zIndex=1000;
    
    popupshown_O=true;
    //alert(popupcontrol);
    
    //make all drop down lists visible by ritesh for log settings
	var arrobj=document.getElementsByTagName("select");
	//alert(arrobj.length);
	for(i=0;i<arrobj.length;i++)
	{
	    //alert(arrobj[i].name);
	    arrobj[i].style.display = "none";
	}
	
	

    var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
   //Newly added to make all objects invisible for safari browser.
	var is_Safari = navigator.userAgent.indexOf('Safari');
	
	if((is_Safari >0)&&(is_chrome==false))
	{  
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {
	        //alert(arrobj[i].name);
	         arrobj[i].style.visibility = "hidden";
	    }
	}
	  
	 // GPSPopupload();
    return(false);
}

function closepopup_O(popupContentID)
{   //alert("Closing popup2");

    var popupcontrol=document.getElementById("divpopup_O");
    //var contentObj=document.getElementById(popupContentID);
    
    var ContentId=document.getElementById("hidContentID_O").value;
    var contentObj;
    if(ContentId !="")
    {
        contentObj=document.getElementById(ContentId);
    }
    if(contentObj!=null)
    {  
        contentObj.style.display="none";
    }      
      
    if(popupcontrol!=null)
    {   
        popupcontrol.style.display="none";
    }   
        
    document.getElementById("bg_image").style.display="none";
    
    //make all drop down lists invisible
	var arrobj=document.getElementsByTagName("select");
	//alert(arrobj.length);
	for(i=0;i<arrobj.length;i++)
	{
	    //alert(arrobj[i].name);
	    arrobj[i].style.display = "block";
	}
	
	var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
	
	//Newly added to make all objects invisible for safari browser.
	var is_Safari = navigator.userAgent.indexOf('Safari');	
	if((is_Safari >0)&&(is_chrome==false))
	{
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {	       
	        //alert(arrobj[i].name);
	        arrobj[i].style.visibility = "visible";  
	    }
	}
    popupshown_O=false;    
    var temp = document.getElementById("hiddenEditLogPopupStatus");
	if(temp != null)
	{
		temp.value = "true";
	}
    return false;
}

//For LogDetails.aspx this window.onresize function is not required
var currUrl;
currUrl=String(self.location);
var logUrl= currUrl.indexOf("LogDetails.aspx");

var planUrl= currUrl.indexOf("CreatePlan.aspx");

if((logUrl > 0)||(planUrl > 0))
{
    
}
else
{
    window.onresize=window.onscroll=function()
    {
        isMozilla = (document.all) ? 0 : 1;
        if(popupshown_O)
        {
            var popupcontrol;
            popupcontrol=document.getElementById("divpopup_O");
        
        
            if(popupcontrol!=null)
            {
                //Display the window in the center of the screen
                var pleft,ptop;
                var isMozilla = (document.all) ? 0 : 1;
                
                if(isMozilla)
                {
                    pleft=(document.body.offsetWidth/2)-(popupcontrol.offsetWidth/2)+window.pageXOffset;
                    ptop=(window.innerHeight/2)-(popupcontrol.offsetHeight/2)+window.pageYOffset;
                }
                else
                {
                    pleft=(document.documentElement.offsetWidth/2)-(popupcontrol.offsetWidth/2)+document.documentElement.scrollLeft;
                    ptop=(document.documentElement.offsetHeight/2)-(popupcontrol.offsetHeight/2)+document.documentElement.scrollTop;
                }
                popupcontrol.style.left=pleft+"px";
                popupcontrol.style.top=ptop+"px";    
                
                if(!isMozilla)
                {
                    var objBlankImage=document.getElementById("bg_image");
                    if(objBlankImage)
                    {
                        objBlankImage.style.width=(document.body.offsetWidth)+ (document.body.offsetLeft*2)+"px";
                    }
                }
            }
        
        }

        //Added to refresh the menus to avoid the window resize problem
        if(!isMozilla)
        {
            if(document.getElementById("menu")!=null)
            {
                //document.getElementById("menu").style.display="none";
                //document.getElementById("menu").style.display="block";
            }
            
        }     
        
    };
}


function DisplaySplashPopup()
{
     ShowSplashPopup("OuterPanel",'','');
     ShowFirstSplashScreen('');
}

var t;
var IsMouseover=false;
var IsMouseout=false;
var IsComplete=false;
var IsBegin=true;
function ShowFirstSplashScreen(mouseAction)
    {
         IsComplete=false;
         var panel = document.getElementById("OuterPanel");
        // document.getElementById("btnSplashScreen").style.display = "none";
         loopCounter = 0;
         elIdx = 0;
         arrStart = 0;
         document.getElementById('imgBtnNextScreen').style.visibility = "hidden";
//         document.getElementById('lnkPrevScreen').style.visibility = "hidden";
         
        document.getElementById('imgBtnPrevScreen').style.display = "none";
        document.getElementById('imgBtnNextScreen').style.display = "block";
         
          arrStart=0;
        arrEnd= 3;
        for(;arrStart <= arrEnd;arrStart++)
        {
           fadeElem = document.getElementById('spanContent' + arrStart);
           fadeElem.innerHTML = "";
        
           fadeElemTitle = document.getElementById('spanTitle' + arrStart);
           fadeElemTitle.innerHTML ="";
       
           setOpacity(document.getElementById('spanContent'+arrStart), 0);
         //  setOpacity(document.getElementById('spanTitle'+elIdx), 1);
      
        }
         fadeSteps = 50;
         fadeDelay = 30;
         nextSetDelay = 5000;
         arrStart=0;
         arrEnd= 3;
         i = arrStart - 4;
         FadeMessage("prev");
      
        // FadeMessage(mouseAction);
         return false;
    }
    
    


function closeSplashPopup()
{ 
    popupcontrol=document.getElementById("OuterPanel");
    popupcontrol.style.display="none";
    objBlankImage=document.getElementById("bg_image");
    objBlankImage.style.display="none";
    //document.getElementById("btnSplashScreen").style.display = "block";
    var index = 1;
    var tmpfadeElem;
    for(index = 0;index <= 3;index++)
   {
           tmpfadeElem = document.getElementById('spanContent' + index);
           tmpfadeElem.innerHTML = "";
        
           tmpfadeElem = document.getElementById('spanTitle' + index);
           tmpfadeElem.innerHTML ="";
           
//           fadeSteps = 50;
//           fadeDelay = 30;
//           nextSetDelay = 5000;


      
   }
    
   return false;
    
}


function ShowSplashPopup(popupContentID,title,size)
{    
    //document.getElementById("btnSplashScreen").style.display = "none";
	var popupcontrol;
    popupcontrol=document.getElementById(popupContentID);
    var contentObj=document.getElementById(popupContentID);
    divContentID = popupContentID;
    contentObj.style.display="block";
    popupcontrol.style.display="block";
    
    //Display the window in the center of the screen
    var pleft,ptop;
    var isMozilla = (document.all) ? 0 : 1;
    
    if(isMozilla)
    {
        pleft=(document.body.offsetWidth/2)-(popupcontrol.offsetWidth/2) + window.pageXOffset;
        ptop=(window.innerHeight/2)-(popupcontrol.offsetHeight/2) + window.pageYOffset;
    }
    else
    {
        pleft=(document.documentElement.offsetWidth/2)-(popupcontrol.offsetWidth/2) + document.documentElement.scrollLeft;
        ptop=(document.documentElement.offsetHeight/2)-(popupcontrol.offsetHeight/2) + document.documentElement.scrollTop;
    }
   
   
    ptop=300;
    pleft=210;
    
    popupcontrol.style.left=pleft+"px";
    popupcontrol.style.top=ptop+"px";
    DisableBackground();
    popupshown=true;
    //make all drop down lists visible by ritesh for log settings
	var arrobj=document.getElementsByTagName("select");
	for(i=0;i<arrobj.length;i++)
	{
	    arrobj[i].style.display = "none";
	}
    var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
   //Newly added to make all objects invisible for safari browser.
	var is_Safari = navigator.userAgent.indexOf('Safari');
	
	if(is_chrome == true)
	{
	    
	    ptop=580;
        pleft=195;
        popupcontrol.style.left=pleft+"px";
        popupcontrol.style.top=ptop+"px";
        
	}
	else if(isMozilla == 1)
	{
	    ptop=580;
        pleft=200;
        popupcontrol.style.left=pleft+"px";
        popupcontrol.style.top=ptop+"px";
        
	}
	if((is_Safari >0)&&(is_chrome==false))
	{  
	    
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {
	        //alert(arrobj[i].name);
	         arrobj[i].style.visibility = "hidden";
	    }
	}	
	var index = 0;
	var tmpFadeElemet;
	for(index =0;index <= 3;index++)
        {
           tmpFadeElemet = document.getElementById('icon' + index);
           tmpFadeElemet.style.visibility = "hidden";
        }	
	
	
    return(false);
}

var fadeSteps = 40;
var fadeDelay = 30;
var loopCounter=0;
var nextSetDelay = 4000;
var loopPrepend = true;
var arMessage = new Array("Share personal details with others. Follow us on twitter, view user facebook profile.", "Register events and  Host Websites with GoUltraSports ", "Set and track goal progress. Set challenges for others and view progress.", "Add your special activities.","Share your GoUltra data on your blog or external website. Use GoUltra badges to display on your blog or website.","","","");
var arTitleMsg = new Array("Public Profile", "Event Registration", "Goals and Challenges", "Achievements","Widgets and Badges","","","");
var arMsgImage = new Array("ico_publicprofile.png", "ico_event_registration.png", "ico_goalschallenegs.png", "ico_achievement.png","ico_widgetsbadges.png","","","");

//var arMessage = new Array("Fade-In Message 1", "Fade-In Message 2", "Fade-In Message 3", "Fade-In Message 4", "Fade-In Message 5", "Fade-In Message 6", "Fade-In Message 7");
var elIdx = 0, msgIdx = 0, fadeStep = 0;
var fadeElem,fadeElemTitle,iconSrc;
var msgLen = arMessage.length;
var arrStart = 0;

var arrEnd=3;
// arrStart = 0;
function FadeMessage(mouseAction)
{
    var i = 0;
    if(mouseAction =="next")
    {
        arrStart=4;
        arrEnd= 5;
        i = arrStart - 4;
        fadeSteps = 40;
        fadeDelay = 60;
    }
    
    else if(mouseAction =="prev")
    {
        arrStart=0;
        arrEnd= 3;
        fadeSteps = 40;
        fadeDelay = 60;
        
    }
   if((arrStart == (arrEnd + 1)) &&( arrStart == 4))
    {
     //  document.getElementById('imgBtnNextScreen').style.display = "block"; 
       document.getElementById('imgBtnNextScreen').style.visibility = "visible"; 
    }
    if((arrStart == arrEnd )&& (arrStart == 5))
    {
       document.getElementById('imgBtnPrevScreen').style.display = "block"; 
    }
    if(elIdx == 4)
    {
        elIdx = 0;
    }
      if(loopCounter>=4 )
    {
       
       return false;
    }
    if(elIdx == 5 || (!loopPrepend && (msgIdx == msgLen)))
     {
            if(elIdx != 5)
            {
                msgIdx = 0;
            }
            elIdx = 1;
            setTimeout('FadeMessage()', nextSetDelay);
      }
      else
     {
        
        if(msgIdx == msgLen)
        {
            msgIdx = 0;
        }
       
//         for(i=0;i<4 ;i++)
//        {
//            setOpacity(document.getElementById('spanContent'+i), 0.5);
//            setOpacity(document.getElementById('spanTitle'+i), 1);
//        }
      
        window.setTimeout("fadeIn()", fadeDelay);
        fadeStep = 20;
        fadeElem = document.getElementById('spanContent' + elIdx);
        fadeElem.innerHTML = arMessage[arrStart];
        fadeElemTitle = document.getElementById('spanTitle' + elIdx);
        fadeElemTitle.innerHTML = arTitleMsg[arrStart];
        iconSrc = document.getElementById('icon' + elIdx);
        if(arMsgImage[arrStart] != "")
        {
        iconSrc.style.visibility = "visible";
        iconSrc.src = "Images/home page/"+arMsgImage[arrStart];
        }
        else
        {
            iconSrc.style.visibility = "hidden";
        }
        fadeStep = 0;
        elIdx++;
        msgIdx++;
        loopCounter++;
        arrStart++;
   }
        return false;
}
var loopCounter=0;
function fadeIn(mouseAction) 
{
    if(fadeStep > fadeSteps)
    {
        FadeMessage(mouseAction);
        return;
    }
    
    setOpacity(fadeElem, (fadeStep/fadeSteps));
    fadeStep++;
    window.setTimeout("fadeIn()", fadeDelay);
    
}
function setOpacity( el, opacity)
{
    if(el.style.opacity != undefined)
    {
        el.style.opacity = opacity;
    }
    else if( el.style.MozOpacity != undefined)
    {
        el.style.MozOpacity = opacity;
    }
    else if ( el.style.filter != undefined)
    {
        el.style.filter="alpha(opacity=" + Math.round(opacity * 100) + ")";
    }
}


function showNextSplashScreenClick(screenId)
{
    if(screenId =="next")
    {
  //      document.getElementById('imgBtnPrevScreen').style.display = "block";
        document.getElementById('imgBtnNextScreen').style.display = "none";
        loopCounter = 0;
        elIdx = 0;
        fadeSteps = 50;
        fadeDelay = 30;
        nextSetDelay = 5000;
        fadeStep = 0;
        var index = 0;
        var tmpFadeElemet;
        for(index =0;index <= 3;index++)
        {
            
           tmpFadeElemet = document.getElementById('spanContent' + index);
           tmpFadeElemet.innerHTML = "";
        
           tmpFadeElemet = document.getElementById('spanTitle' + index);
           tmpFadeElemet.innerHTML ="";
           
           tmpFadeElemet = document.getElementById('icon' + index);
           tmpFadeElemet.style.visibility = "hidden";
       
       
        //   setOpacity(document.getElementById('spanContent'+index), 0);
         //  setOpacity(document.getElementById('spanTitle'+elIdx), 1);
      
        }
        FadeMessage("next");
    }
    
    else
    {
        document.getElementById('imgBtnNextScreen').style.display = "block";
        document.getElementById('imgBtnNextScreen').style.visibility = "hidden";
        document.getElementById('imgBtnPrevScreen').style.display = "none";
        loopCounter = 0;
        elIdx = 0;
        fadeStep = 0;
        fadeSteps = 50;
        fadeDelay = 50;
        nextSetDelay = 5000;
        var index = 0;
         var tmpFadeElemet;
        for(index =0;index <= 3;index++)
        {
           tmpFadeElemet = document.getElementById('spanContent' + index);
           tmpFadeElemet.innerHTML = "";
        
           tmpFadeElemet = document.getElementById('spanTitle' + index);
           tmpFadeElemet.innerHTML ="";
       
           setOpacity(document.getElementById('spanContent'+index), 0);
         //  setOpacity(document.getElementById('spanTitle'+elIdx), 1);
      
        }
        FadeMessage("prev");
    }
    return false;
       
}

function ShowWebsiteModalPopup(popupContentID,title,size)
{       
    var popupcontrol;
    popupcontrol=document.getElementById("divpopup");
    
    var contentObj=document.getElementById(popupContentID);
    divContentID = popupContentID;
  
    document.getElementById("hidContentID").value=popupContentID;
    
    if(contentObj!=null)
    {        
        document.getElementById("popupcontentholder").appendChild(contentObj);
        
        document.getElementById("popupHeader").innerHTML=title;
        //document.body.appendChild()
        contentObj.style.display="block";
        popupcontrol.style.display="block";
        
    }
    
    //Display the window in the center of the screen
    var pleft,ptop;
    var isMozilla = (document.all) ? 0 : 1;
    
    if(isMozilla)
    {
        pleft=(document.body.offsetWidth/2)-(popupcontrol.offsetWidth/2) + window.pageXOffset;
        ptop=(window.innerHeight/2)-(popupcontrol.offsetHeight/2) + window.pageYOffset;
    }
    else
    {
        pleft=(document.documentElement.offsetWidth/2)-(popupcontrol.offsetWidth/2) + document.documentElement.scrollLeft;
        ptop=(document.documentElement.offsetHeight/2)-(popupcontrol.offsetHeight/2) + document.documentElement.scrollTop;
    }
 
    if(ptop != 0)
    {
        ptop = (ptop/3);
       
    }
    if(pleft != 0)
    {
        pleft  = pleft  - (pleft /2);
    }
  
    if(ptop < 0)
    {   
         if(title.indexOf("Workout Log For")!=-1 )
         {
                if(ptop < document.getElementById("topAds").offsetHeight)
                {
                    ptop=150;
                 }
                 else
                 {
                    ptop = 0;
                 }
         }
         else
         {
            ptop = 0;
         }
              
    }
    if( title=="Log Report Summary")
    {  
         if(ptop < document.getElementById("topAds").offsetHeight)
         {
            
             ptop=150;
          }
          else
          {
              ptop = 0;
          }
    }
   if(title.indexOf("Workout Log For")!=-1 )
    {
        if (document.getElementById("tblLeftColumn") != null)
        {            
             if(pleft < document.getElementById("tblLeftColumn").offsetWidth)
             {
                pleft=document.getElementById("tblLeftColumn").offsetWidth + parseInt('25');
             }
         }
         if (document.getElementById("tblLeftColumn") != null)
        {            
             if(pleft < document.getElementById("tblLeftColumn").offsetWidth)
             {
                pleft=document.getElementById("tblLeftColumn").offsetWidth + parseInt('25');
             }
         }
    }
        
    popupcontrol.style.left=pleft+"px";
    popupcontrol.style.top=ptop+"px";
    //alert(window1.pageYOffset);
    
    
    //popupcontrol.style.zIndex=1000;
    
    popupshown=true;
    //alert(popupcontrol);
    
    //make all drop down lists visible by ritesh for log settings
	var arrobj=document.getElementsByTagName("select");
	//alert(arrobj.length);
	for(i=0;i<arrobj.length;i++)
	{
	    //alert(arrobj[i].name);
	    arrobj[i].style.display = "none";
	}
	
	

    var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
   //Newly added to make all objects invisible for safari browser.
	var is_Safari = navigator.userAgent.indexOf('Safari');
	
	if((is_Safari >0)&&(is_chrome==false))
	{  
	    var arrobj=document.getElementsByTagName("object");
	    //alert(arrobj.length);
	    for(i=0;i<arrobj.length;i++)
	    {
	        //alert(arrobj[i].name);
	         arrobj[i].style.visibility = "hidden";
	    }
	}		
	// Change the class According to popup size
	if((size == 'L') || (size == 'l'))
	{
	    document.getElementById("trContaintHolder").className="clsModalPopupLargeMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupLargeTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupLargeBottom";
        document.getElementById("trContaintHolder").style.width = "765px";
        document.getElementById("trPopUpTop").style.width = "765px";
        document.getElementById("trPopUpBottom").style.width = "765px";
	}
	else if((size == 'S') || (size == 's'))
	{
	    document.getElementById("trContaintHolder").className="clsModalPopupSmallMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupSmallTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupSmallBottom";
        document.getElementById("trContaintHolder").style.width = "366px";
        document.getElementById("trPopUpTop").style.width = "366px";
        document.getElementById("trPopUpBottom").style.width = "366px";
	}
	else if ((size == 'C') || (size == 'c'))
	{
	    
	    document.getElementById("trContaintHolder").className="clsModalPopupCustomMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupCustomTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupCustomBottom";
        document.getElementById("trContaintHolder").style.width = "460px";
        document.getElementById("trPopUpTop").style.width = "460px";
        document.getElementById("trPopUpBottom").style.width = "460px";
	}
	else
	{
	    document.getElementById("trContaintHolder").className="clsModalPopupMediumMiddle";
	    document.getElementById("trPopUpTop").className="clsModalPopupMediumTop";
	    document.getElementById("trPopUpBottom").className="clsModalPopupMediumBottom";
	    document.getElementById("trContaintHolder").style.width = "566px";
	     document.getElementById("trPopUpTop").style.width = "566px";
        document.getElementById("trPopUpBottom").style.width = "566px";
	}
	  
	 // GPSPopupload();
    return(false);
}

