﻿// JScript File
var myTimer;
var inoout=false;

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

/*
<!--

// Handle all the FSCommand messages in a Flash movie.
function menu_DoFSCommand(command, args) {
    var menuObj = isInternetExplorer ? document.all.menu : document.menu;
    //
    // Place your code here.
    //
    //alert(command);
    if(command=="ShowPage")
    {
        ShowPage(args);
    }
    else if(command=="Rollover")
    {
        document.getElementById("menu").style.zIndex=1000;
    }
    else if(command=="Rollout")
    {
        document.getElementById("menu").style.zIndex=0;
    }
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
    document.write('<script language=\"VBScript\"\>\n');
    document.write('On Error Resume Next\n');
    document.write('Sub menu_FSCommand(ByVal command, ByVal args)\n');
    document.write('	Call menu_DoFSCommand(command, args)\n');
    document.write('End Sub\n');
    document.write('</script\>\n');
}
//-->

*/

function AdjustMenuZIndex(str)
{
    window.menu = document.getElementById('menu');
    if(str=="Rollover")
    {
        //document.getElementById("menu").style.zIndex=1000;
        
        if(!document.all)
        {
            if(document.getElementById("topbanner"))
            {
                document.getElementById("topbanner").style.display="none";
            }
        }
        
        //This is added for stopping the scroll news, since in firefox the expanded menus are flickering
        //inoout = true;
    }
    else if(str=="Rollout")
    {
        //document.getElementById("menu").style.zIndex=0;
        
        if(!document.all)
        {
            if(document.getElementById("topbanner"))
            {
                document.getElementById("topbanner").style.display="block";
            }
        }
        
        //This is added for stopping the scroll news, since in firefox the expanded menus are flickering
        //inoout = false;
    }
}

function ShowPage(page)
{
    var currUrl;
    currUrl=String(self.location);
    var arr;
    var seperator = '/';
    arr=currUrl.split(seperator);
    var url;
    
    //Get the URL
    switch(page)
    {
//        case "Home":
//            url="HomePage.aspx";
//            break;
//        
//        case "My Home Page":
//            url="MyHomePage.aspx";
//            break;
//        
//        case "Online Registration":
//            url="WebPages/User/OnlineRegistration.aspx";
//            break;
//            
//        case "View Profile":
//        case "Profile Settings":
//            url="WebPages/User/EditProfile.aspx";
//            break;
//            
//        case "Public Profile":
//            var hidDisplayName = document.getElementById('TopFrame1_hidDisplayName');
//            if(hidDisplayName!=null)
//            {
//                url= hidDisplayName.value;
//            }
//            else
//            {
//                url="WebPages/User/PageNotFound.aspx";
//            } 
//            break;
//            
//        case "My Photos":
//            url="WebPages/User/MyPhotos.aspx";
//            break;
//            
//        case "Edit Profile":
//            url="WebPages/User/EditProfile.aspx";
//            break;
//            
//         case "Profile Settings":
//            url="WebPages/User/EditProfile.aspx";
//            break;
//            
//        case "RSS Feeds":
//            url="WebPages/RSSFeedViewer/RSSFeedViewer.aspx";
//            break;
//            
//        case "Coaching & Training Plans":
//            //url="WebPages/TrainingAndCoaching/ViewCoaches.aspx"; 
//            url="WebPages/Coaching/TrainingPlans.aspx"; 
//            break;
//            
//        case "Forums & Communities":
//            url="WebPages/Community/ViewForums.aspx"; 
//            break;
//        
//        case "Athlete Tools":
//        url="WebPages/AthleteTools/AthleteTools.aspx"; 
//        break;
//        
//        case "Pace Calculator":
//        //url="WebPages/AthleteTools/AthleteTools.aspx?calc=1"; 
//        SubmitQueryString("WebPages/AthleteTools/AthleteTools.aspx?calc=1");
//        return;
//        break;
//        
//        case "Heart Rate Calculator":
//        //url="WebPages/AthleteTools/AthleteTools.aspx?calc=2"; 
//        SubmitQueryString("WebPages/AthleteTools/AthleteTools.aspx?calc=2");
//        return;
//        break;
//            
//        case "Calorie Calculator":
//        //url="WebPages/AthleteTools/AthleteTools.aspx?calc=3"; 
//        SubmitQueryString("WebPages/AthleteTools/AthleteTools.aspx?calc=3");
//        return;
//        break;
//        
//        case "Race Time Predictor":
//        //url="WebPages/AthleteTools/AthleteTools.aspx?calc=3"; 
//        SubmitQueryString("WebPages/AthleteTools/AthleteTools.aspx?calc=5");
//        return;
//        break;
//        
//        case "Food Diary":
//            url="WebPages/FoodDiary/SearchFoodDiary.aspx";
//            break;
//            
//            
//        case "Conversion Calculator":
//        //url="WebPages/AthleteTools/AthleteTools.aspx?calc=4"; 
//        SubmitQueryString("WebPages/AthleteTools/AthleteTools.aspx?calc=4");
//        return;
//        break;
//        
//        case "Metric Conversion":
//        url="WebPages/AthleteTools/AthleteTools.aspx?calc=4"; 
//        break;
//        
//        case "My Events":
//            url="WebPages/SportsLifeEventsList/EventsList.aspx";
//            break;
//        
//        case "Newsletter":
//            url="WebPages/NewsLetters/ViewNewsLetters.aspx";
//            break;
//        
//        case "Blogs":
//            url="WebPages/Blogs/ViewBlogs.aspx";
//            break;
//            
//        case "Browse Users":
//            url="WebPages/User/UserList.aspx";
//            break; 
//            
//        case "Training Log":
//            url="WebPages/LogBook/LogDetails.aspx";
//            break;  
//            
//       case "Log Settings":
//            setCookie("CookieLogSettings", "LogSettings", 3600);
//            url="WebPages/LogBook/LogDetails.aspx?enc=1";
//            break; 
//            
//       case "Training Routes":
//            url="WebPages/LogBook/SearchTrainingRoutes.aspx";
//            break; 
//              
//        case "Shopping":
//            url="WebPages/Other/Comingsoon.aspx";
//            break;
//            
//        case "Classifieds":
//            url="WebPages/Other/Comingsoon.aspx";
//            break;
//            
//        case "Products":
//            url="WebPages/Other/Comingsoon.aspx";
//            break;
//        
//        case "More":
//            url="WebPages/RSSFeedViewer/RSSFeedViewer.aspx";
//            break;
//        case "Widgets":
//            url="WebPages/Widgets/GetWidget.aspx";
//            break;   
//        
//        case "My Goals":
//            url="WebPages/LogBook/MyGoals.aspx";
//            break;


    //menu 1
    
        case "Home":
            url="HomePage.aspx";
            break;      
       
    //menu 2   
            
        case "Workout":
            url="WebPages/LogBook/LogDetails.aspx";
            break; 
            
        case "Workout Calendar":
            url="WebPages/LogBook/LogDetails.aspx";
            break; 
            
        case "Import/Export":
            url="WebPages/LogBook/GPSDataUpload.aspx";
            break;    
            
        case "Workout Settings":
            setCookie("CookieLogSettings", "LogSettings", 3600);
            url="WebPages/LogBook/LogDetails.aspx?enc=1";
            break;
            
         case "Utilities":
            url="WebPages/LogBook/ShoeDetails.aspx";
            break;
            
             case "Threshold Limit":
            url="WebPages/Coaching/ThresholdLimitDetails.aspx";
            break;
            
         case "Report":
            url="WebPages/LogBook/LogReports.aspx";
            break;  
            
        case "Routes":
            url="WebPages/LogBook/SearchTrainingRoutes.aspx";
            break;   
                
      case "Athlete Tools":
       url="WebPages/AthleteTools/AthleteTools.aspx?calc=3";
       //  SubmitQueryString("WebPages/AthleteTools/AthleteTools.aspx?calc=3");
        break;
         
       case "Goals":
            url="WebPages/LogBook/MyGoals.aspx";
            break;
            
            
       case "Challenges":
            url="WebPages/LogBook/GlobalChallenges.aspx";
            break;
            
    //menu 3
        case "Training":
            //url="WebPages/TrainingAndCoaching/ViewCoaches.aspx"; 
            url="WebPages/Coaching/TrainingPlans.aspx"; 
            break;
        
        case "Training plans":
            //url="WebPages/TrainingAndCoaching/ViewCoaches.aspx"; 
            url="WebPages/Coaching/TrainingPlans.aspx"; 
            break;
            
         case "My Training plans":
             url="WebPages/Coaching/PlanDetails.aspx"; 
            break;    
            
         case "Training Coach":
            url="WebPages/Coaching/FindCoach.aspx"; 
            break;
        
         case "My Coach":
            url="WebPages/Coaching/MyTrainingCoaches.aspx"; 
            break;
            
    //menu 4        
           case "Events":
            url="WebPages/EventCalendar/EventList.aspx";
            break;  
            
            case "Global Events":
            url="WebPages/EventCalendar/EventCalendar.aspx";
            break;
            
            case "My Events":
            url="WebPages/SportsLifeEventsList/EventsList.aspx";
            break;
            
            case "Bucket List":
            //url="WebPages/SportsLifeEventsList/EventsList.aspx";
            url="WebPages/LifeEventList/LifeEventListTrial.aspx";
            break;
    //menu 5    
           case "My Stuff":
            url="MyHomePage.aspx";
            break;  
            
           case "My Home Page":
            url="MyHomePage.aspx";
            break;
            
            
             case "My Profile":
            var hidDisplayName = document.getElementById('TopFrame1_hidDisplayName');
            //alert("hidDisplayName= " + hidDisplayName);
            if(hidDisplayName!=null)
            {
            //alert("hidDisplayName.value = " + hidDisplayName.value);
                url= hidDisplayName.value;
            }
            else
            {
                url="WebPages/User/PageNotFound.aspx";
            } 
            break;
            
              case "My Photos":
            url="WebPages/User/MyPhotos.aspx";
            break;
            
              case "My Achievements":
            url="WebPages/LogBook/MyAchievement.aspx";
            break;
            
            
            case "Browse Users":
            url="WebPages/User/UserList.aspx";
            break;
            
             case "My Friends":
            url="WebPages/User/FriendRequest.aspx";
            break;
              
            case "User Management":
            url="WebPages/User/UserManagement.aspx";
            break;
            
            
             case "Settings":
            url="WebPages/User/EditProfile.aspx";
            break;
           
     //menu 6  
            case "Social Network":
            url="WebPages/Blogs/BlogHomePage.aspx";
            break; 
            
             case "Community":
            url="WebPages/Blogs/ViewBlogs.aspx";
            break; 
       
         case "Blogs":
            url="WebPages/Blogs/BlogHomePage.aspx";
            break; 
       
        case "Forums":
            url="WebPages/Community/ViewForums.aspx"; 
            break;
            
         case "Communities":
            url="WebPages/Community/ViewCommunities.aspx"; 
            break;    
            
            
      //meun 7    
      case "Extra":
            url="WebPages/Widgets/GetWidget.aspx";
            break;
      
       case "Widgets and Badges":
            url="WebPages/Widgets/GetWidget.aspx";
            break;  
       
        case "Newsletter":
            url="WebPages/NewsLetters/ViewNewsLetters.aspx";
            break;
            
        case "Glossary":
            url="WebPages/Coaching/GlossaryDetails.aspx";
            break;    
            
       case "Online Registration":
            url="WebPages/User/OnlineRegistration.aspx";
            break;        
                 
           case "Event Setup & Registration":
            url="WebPages/EventCalendar/EventList.aspx";
            break;
                         
        default:
            return;
            
            
    }
    
    self.location=url;
    
    return "";
    
    //if(arr[arr.length-1]=="Default.aspx" || arr[arr.length-1]==""||arr[arr.length-1]=="Default.aspx#" || arr[arr.length-1]=="#")
    //{
    //    self.location=url;
    //}
    //else
    //{
    //    self.location="../../"+url;
    //}
}
function CollapseMenus()
{
    if(document.getElementById("menu")!=null)
    {
        //document.getElementById("menu").SetVariable("outsideclick", "pageclick");
        window.document.menu.SetVariable("outsideclick", "pageclick");
    }
}

////This function will be called from the flash file to get the variables
//function GetRecentUsersList()
//{
//    window.recentusers = document.getElementById('recentusers');
//    
//    document.recentusers.SetVariable("UserIds",document.getElementById("hidrecentUserIds").value);
//    document.recentusers.SetVariable("UserNames",document.getElementById("hidrecentUsersNames").value);
//    document.recentusers.SetVariable("UserImages",document.getElementById("hidrecentUsersImages").value);
//    document.recentusers.SetVariable("imagepath","UserImages/");    
//}

////This function will be called from the flash file to get the variables for video
//function GetHomePageVideo()
//{
//    window.videoPlayer = document.getElementById('videoPlayer');
//    //Displaying the video on the home page
//    var filename=document.getElementById("CurrentVideo").value;
//    document.videoPlayer.SetVariable("VideoFileName","../../Videos/" + filename);
//}


function ShowMenus()
{
    
    //This is a workaround for the Flash external interface call for SWF included in Form element
    //window.menu = document.getElementById('menu');
    
    //alert(document.getElementById("menu"));
    //document.getElementById("menu").src="images/home page/menu.swf";
        
    //Set the video file
    //document.videoPlayer.SetVariable("VideoFileName", "../../Videos/hu_070704scm_1v.flv");
    
    //checkFlashPlayer();
    if(document.getElementById("PageFooter_hUserId").value!="")
    {
        //Make the panels visible/invisible
        checkSessionTimeout();
        if(document.getElementById("PageFooter_hidUserRole").value == 2 ||document.getElementById("PageFooter_hidUserRole").value == 1 ) 
        {
             if(document.getElementById("TopFrame1_divCoachLink") != null)
             {
                document.getElementById("TopFrame1_divCoachLink").style.visibility = 'visible';
                if( document.getElementById("TopFrame1_divCoachBar")!=null)
                {
                    document.getElementById("TopFrame1_divCoachBar").style.visibility = 'visible';
                }
             }
        }
        else
        {
              if(document.getElementById("TopFrame1_divCoachLink") != null)
              {
                  document.getElementById("TopFrame1_divCoachLink").style.display = 'none';
                  if(document.getElementById("TopFrame1_divCoachBar")!=null)
                  {
                  document.getElementById("TopFrame1_divCoachBar").style.display = 'none';
                  }
              }
        }
      //  document.getElementById("TopFrame1_pnlLogin").style.display = 'none';
       // document.getElementById("TopFrame1_pnlAfterLogin").style.display = 'block';
       // document.getElementById("diveditFBProfile").style.display='none';
       if(document.getElementById("TopFrame1_lblLoginName")!=null)
       {
            document.getElementById("TopFrame1_lblLoginName").innerHTML = document.getElementById("PageFooter_hUserName").value;
        }
    }
    else
    {
       if(document.getElementById("PageFooter_hFBAfterLoginId").value!="")
       {
          document.getElementById("PageFooter_hFBUserName").value="";
       }
       
//       if(document.getElementById("PageFooter_hFBUserName").value!="")
//       {
//           document.getElementById("TopFrame1_pnlAfterLogin").style.display = 'block';
//           document.getElementById("TopFrame1_pnlLogin").style.display = 'none';
//           document.getElementById("diveditFBProfile").style.display='block';
//           if(document.getElementById("TopFrame1_divCoachLink") != null)
//           {
//              document.getElementById("TopFrame1_divCoachLink").style.display = 'none';
//              document.getElementById("TopFrame1_divCoachBar").style.display = 'none';
//           }
//           document.getElementById("TopFrame1_lblLoginName").innerHTML = document.getElementById("PageFooter_hFBUserName").value +"!";   
//       }
//       else
  //     {
           // document.getElementById("TopFrame1_pnlAfterLogin").style.display = 'none';
           // document.getElementById("TopFrame1_pnlLogin").style.display = 'block';
           // document.getElementById("diveditFBProfile").style.display='none';
       //}
        
    }
    
    var Path; 
    var PageName;
    Path = self.location.href ;
    PageName = Path.substring(Path.lastIndexOf("/")+1 ,Path.length);
    
    //Check the browser type and accordingle set the properties on the menu container
    if(document.all)
    {
        //for IE
       // document.getElementById("menucontainer").style.overflow="hidden";
        document.getElementById("topframe").style.overflow="hidden";
    }
    else
    { 
        //For Firefox
       // document.getElementById("menucontainer").style.overflow="visible";
        document.getElementById("topframe").style.overflow="visible";
    } 
    
    document.body.onclick=CollapseMenus;
    
//    if(document.getElementById("PageFooter_hUserId").value!="")
//    {
//        FetchData();
//        document.menu.SetVariable("MenuOption", "User");
//    }
//    else
//    {
//        document.menu.SetVariable("MenuOption", "Normal");
//    }
 if(document.getElementById("PageFooter_hidUserRole").value=="2")
    {
         FetchData();
        //document.menu.SetVariable("MenuOption", "admin");
    }
    else if(document.getElementById("PageFooter_hidUserRole").value=="1")
    {
        FetchData();
        //document.menu.SetVariable("MenuOption", "coach");
    }
    else if(document.getElementById("PageFooter_hUserId").value!="")
    {
        FetchData();
        //document.menu.SetVariable("MenuOption", "User");
    }
    else
    {
        //document.menu.SetVariable("MenuOption", "Normal");
    }
    
    AdjustMenuZIndex("Rollout");
    
    if(document.getElementById("PageFooter_hUserId").value!="")
    {
        var obj;
	    obj =  document.getElementById("TopFrame1_hidShowMessanger");
	    if (obj != null)
	    {
	        if (obj.value == "true")
	        {
	            setVisible("TopFrame1_pnlIMPopUp");
	            obj.value = "false";
	        }
	    }
	} 
	else
    {
        //Check if any IM chat pop ups are open
        if (arrWindow != null)
        { 
            var objWindow;
            for (var key in  arrWindow)
            {
                objWindow = arrWindow[key]; 
                if (objWindow != null)
                {
                objWindow.close();
                }
            }
        }        
    }
    
    //Load the top banner
    if(document.getElementById("topbanner")!=null)
    {
        document.getElementById("topbanner").src="http://www.activeathletevector.com/OAS/AA_728x90.cfm?pub=tas.go-ultra&refresh_rate=60&refresh=yes";
    }
    
    //Load the footer advertisements
    if(document.getElementById("footerbanner")!=null)
    {
        document.getElementById("footerbanner").src="http://www.activeathletevector.com/OAS/AA_728x90.cfm?pub=tas.go-ultra&refresh_rate=60&refresh=yes";
    }
    
    //Load the left hand side banner
    if(document.getElementById("leftbanner")!=null)
    {
        document.getElementById("leftbanner").src="http://www.activeathletevector.com/OAS/AA_728x90.cfm?pub=tas.go-ultra&refresh_rate=60&refresh=yes";
    }
    
    //Load the right hand side banner
    if(document.getElementById("rightbanner")!=null)
    {
        document.getElementById("rightbanner").src="http://www.activeathletevector.com/OAS/AA_728x90.cfm?pub=tas.go-ultra&refresh_rate=60&refresh=yes";
    }
    
}

//Add the eventhandler for document click for making the menus collapse by passing variable to flash
//document.body.onclick=CollapseMenus;

//Function to load the flash movie for showing the menus
function LoadMenus()
{
    var script;
    var strMenuOption;
    if(document.getElementById("PageFooter_hUserId").value!="")
    {
        strMenuOption="MenuOption=User";
    }
    else
    {
        strMenuOption="MenuOption=Normal";
    }
    script='<object id="menu" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \
                     style="visibility: visible; z-index: 1000; position: relative; \
                    width: 966px; height: 160px;"> \
                    <param name="allowScriptAccess" value="sameDomain" /> \
                    <param name="wmode" value="transparent" /> \
                    <param name="movie" value="images/home page/menu.swf" /> \
                    <param name="quality" value="high" /> \
                    <param name="bgcolor" value="#ffffff" /> \
                    <param name="FlashVars" value="' + strMenuOption + '" /> \
                    <embed src="images/home page/menu.swf" quality="high" bgcolor="#ffffff" FlashVars="' + strMenuOption + '" width="966" \
                        height="160" id="menu" name="menu" align="middle" allowscriptaccess="sameDomain" \
                        type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" \
                        wmode="transparent" /> \
                </object>';
                
    //document.getElementById("menucontainer").innerHTML=script;
                
}

/*
//Function added for handling the fscommands for recently added users album
function recentusers_DoFSCommand(command, args) {
    //
    // Place your code here.
    //
    //alert(command);
    if(command=="ShowUserProfile")
    {
        var url="WebPages/User/MyProfile.aspx?userId=" + args;
        self.location=url;
    }
    else if(command == "GetRecentUsersList")
    {
        GetRecentUsersList();
    }
    
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
    document.write('<script language=\"VBScript\"\>\n');
    document.write('On Error Resume Next\n');
    document.write('Sub recentusers_FSCommand(ByVal command, ByVal args)\n');
    document.write('	Call recentusers_DoFSCommand(command, args)\n');
    document.write('End Sub\n');
    document.write('</script\>\n');
}
*/


/*
//Function added for handling the fscommands for Home page videos
function videoPlayer_DoFSCommand(command, args) {
    //
    // Place your code here.
    //
    //alert(command);
    if(command=="GetHomePageVideo")
    {
        GetHomePageVideo();
    }
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
    document.write('<script language=\"VBScript\"\>\n');
    document.write('On Error Resume Next\n');
    document.write('Sub videoPlayer_FSCommand(ByVal command, ByVal args)\n');
    document.write('	Call videoPlayer_DoFSCommand(command, args)\n');
    document.write('End Sub\n');
    document.write('</script\>\n');
}
*/

// To avoid passing query string to web page.
// Sending query string by post action of form in hidden fields.
function SubmitQueryString(URLQueryStr)
{
    //alert("In function SubmitQueryString value of URLQueryString=" + URLQueryStr);
    
    var form=document.createElement("form");
    form.method = 'post';
	form.id="submitQueryForm";
	form.name="submitQueryForm";
	form.style.visibility = 'hidden';
	
	var lengthOfURL = URLQueryStr.length;
    var posOfQueryStr = URLQueryStr.indexOf("?");
    var actionURL;
    var queryStr;
    if(posOfQueryStr == -1)
    {
        actionURL = URLQueryStr;
        queryStr = "" ;
    }
    else
    {
        actionURL = URLQueryStr.substring(0,posOfQueryStr);
        queryStr = URLQueryStr.substring(posOfQueryStr+1,lengthOfURL);
    }
    
    var queryStrPair = queryStr.split("&");
    var keyValuePair;
    var i=0;
    
    for(i=0;i<queryStrPair.length;i++)
    {
        keyValuePair =  queryStrPair[i].split("=");
        
        //alert("keyName:" + keyValuePair[0]);
        //alert("keyValue:" + keyValuePair[1]);
        
        addInput(document, form, 'hidden', keyValuePair[0], keyValuePair[1]);
    }
    
	document.body.appendChild(form);
	form.action = actionURL;
	form.submit();
	document.body.removeChild(form);
    return false;
}

function addInput(doc, form, type, name, value) 
{
	  var e = doc.createElement('input');
	  e.type = type;
	  e.name = name;
	  e.id = name;
	  e.value = value;
	 
	  form.appendChild(e);
}



function load()
{
    //alert('load');
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    
    prm.add_endRequest(EndRequestHandler);
    //prm.add_beginRequest(BeginRequestHandler);
    
    var Path = self.location.href;
        
    var PageName = Path.substring(Path.lastIndexOf("/")+1 ,Path.length);
//    if (PageName  == "MyHomePage.aspx") 
//    { 
//        window.onbeforeunload = function () {SaveDataOnUnload(); UpdateWindowArray();}    
//    }
//    else
//    {
      window.onbeforeunload = function () {UpdateWindowArray();} ;   
//    }
    // SaveDataOnUnload
    
    //window.onscroll = function() { setTimeout("placeIt('TopFrame1_pnlIMPopUp')",500);}
    //myTimer = setTimeout("ProcessTimerRequest()", 1000);
}

function EndRequestHandler(sender, args) 
{
    var UserMessage = null;
    
    UserMessage = document.getElementById("hidUserMessage"); 

    if(UserMessage != null && UserMessage != "")
    {
       var UserMessageVal = UserMessage.value;
    }
    //alert("in EndRequestHandler");
    //Check if to show the instance message window
    
    //CheckForMessageWin();
//alert("UserMessageVal="+UserMessageVal);
    switch(UserMessageVal)
    {
        case "CommunityJoinSuccessful":
            //alert("You have joined community successfully.");
            var msg="Congratulations! You have joined community successfully.";
            ShowMessageBox(msg);
            break;
            
        case "ExistingMemberOfCommunity":
            ShowInformationMessageBox("You are already a member of this community.");
            break;
        
        case "ErrorInJoinCommunity":
            alert("Error occured while joining this community. Please try again.");
            break;    
        
        case "AddTopicSuccessful":
            closepopup('divpnlAddTopic');
            //alert("Topic has been added successfully.");
            var msg="Congratulations! Topic has been added successfully.";
            ShowMessageBox(msg);
            break;
        
        case "AddTopicSuccessfulTwitted":
            closepopup('divpnlAddTopic');
            //alert("Topic has been added successfully.");
            var msg="Congratulations! Topic has been added successfully and shared with twitter.";
            ShowMessageBox(msg);
            break;
            
        case "ErrorInAddTopic":
            alert("Error occured while adding a topic to this community. Please try again.");
            break;  
        
        case "ErrorInDeleteCommunity":
            alert("Error occured while deleting the Community. Please try again.");
            break;  
        
//        case "SaveCommunitySuccessful":
//            var registrationErrorsDiv = document.getElementById("RegistrationErrors");
//            if(registrationErrorsDiv!=null && registrationErrorsDiv != "")
//            {
//                registrationErrorsDiv.style.display = "block";
//                var msg ="";
//                msg = "Congratulations! Community details are saved successfully !";
//                registrationErrorsDiv.innerHTML = msg;   
//            }
//            break;
//        
//        case "ErrorInSaveCommunity":
//            var registrationErrorsDiv = document.getElementById("RegistrationErrors");
//            if(registrationErrorsDiv!=null && registrationErrorsDiv != "")
//            {
//                registrationErrorsDiv.style.display = "block";
//                var msg ="";
//                msg = "Error occured while saving community, Please try again!";
//                registrationErrorsDiv.innerHTML = msg;   
//            }
//            break;    
        
        case "DeleteCommunitySuccessful":
            self.location="../../WebPages/Community/ViewCommunities.aspx";
          //  return confirm("Would you like to notify all the members?");
            break;            
        
        case "UserNotMemberOfCommunity":
           ShowInformationMessageBox("You are not a member of this community. Please join the community first.");
            break;
            
          
        case "AddEventCommentSuccessful":
            ShowMessageBox("Congratulations! Comment is added successfully.");
            document.getElementById("hidUserMessage").value="";
            //closepopup('pnlComment');
            break;
            
        case "AddEventCommentFailed":
            ShowInformationMessageBox("Sorry error occured while adding comment.");
            document.getElementById("hidUserMessage").value="";
            //closepopup('pnlComment');
            break;
            
        case "UpdateEventCommentFailed":
            ShowInformationMessageBox("Sorry error occured while updating comment.");
            document.getElementById("hidUserMessage").value="";
            //closepopup('pnlComment');
            break;
      
        case "DeleteTopicSuccessful":
            //alert("Topic has been deleted successfully.");
            var msg="Topic has been deleted successfully.";
            ShowMessageBox(msg);
            break;
        
        case "ErrorInDeleteTopic":
            alert("Error occured while deleting the Topic. Please try again.");
            break;        
            
        case "FriendRequestSuccessful":
            //alert("A friend request has been sent successfully.");
            var msg="A friend request has been sent successfully.";
            ShowMessageBox(msg);
            break;
        
        case "FriendAlreadyAdded":
           ShowInformationMessageBox("This user is already in your friend list.");
            break;  
            
        case "FriendRequestError":
            alert("Error occured while sending a friend request. Please try again.");
            break;
       
        case "SendInvitationSuccessful_InviteFriends":
            closepopup('divpnlSendInvitation');
            //alert("Invitation for joining community has been sent successfully.");
            var msg="Invitation for joining community has been sent successfully.";
            ShowMessageBox(msg);
            break;    
                            
        case "SendInvitationSuccessful_DeleteCommunity":
            self.location="../../WebPages/Community/ViewCommunities.aspx";
            //closepopup('divpnlSendInvitation');
            
            //alert("Notification of community deletion has been sent successfully !");
            
            break;
        case "AddTopicReplySuccessful":
            closepopup('divpnlAddTopic');
            //alert("Reply has been added successfully!");
           var msg = "Congratulations! Reply has been posted successfully.";
           ShowMessageBox(msg);
        
            break;
            
             case "AddTopicReplySuccessfulTwitted":
            closepopup('divpnlAddTopic');
            //alert("Reply has been added successfully!");
           var msg = "Congratulations! Reply has been posted successfully and shared with twitter.";
           ShowMessageBox(msg);
        
            break;
        case "ErrorInAddTopicReply":
            alert("Error occured while adding a reply to a topic. Please try again.");
            break;
                
        case "EditReplySuccessful":
            closepopup('divpnlAddTopic');
            //alert("Topic details are saved successfully!");
            var msg="Congratulations! Topic details are saved successfully!";
            ShowMessageBox(msg);
            break;
            
         case "EditReplySuccessfulTwitted":
            closepopup('divpnlAddTopic');
            //alert("Topic details are saved successfully!");
            var msg="Congratulations! Topic details are saved successfully and shared with twitter.";
            ShowMessageBox(msg);
            break;
        case "ErrorInEditReply":
            closepopup('divpnlAddTopic');
            alert("Error occured while changing Topic details. Please try again.");
            break;   
            
//        case "DeleteTopicSuccessful":
//            alert("Topic deleted successfully !");
//            break;
//        case "ErrorInDeleteTopic":
//            alert("Error occured while deleting topic,Please try again !");
//            break;       
        case "DeletePostSuccessful":
            //alert("Post deleted successfully!");
            var msg="Post deleted successfully!";
            ShowMessageBox(msg);
            break;
        case "ErrorInDeletePost":
            alert("Error occured while deleting the Post. Please try again.");
            break;            
        case "editDeleteLinksVisible":
            var temp = document.getElementById("divAdministrativeControls");
            if(temp != null && temp != "")
            {
                temp.style.display = "block";
            }
           
            break;
        case "editDeleteLinksInvisible":
             var temp = document.getElementById("divAdministrativeControls");
            if(temp != null && temp != "")
            {
                temp.style.display = "none";
            }
           
            break;   
        case "CommunityUnsubscribedSuccessful":
            //alert("You have unsubscribed from the community successfully.");
            var msg="You have unsubscribed from the community successfully.";
            ShowMessageBox(msg);
            break;
        case "ErrorInUnsubscribeCommunity":
            alert("Error occured while you tried to unsubscribe to the community. Please try again.");
            break;          
        case "RemoveFriendSuccessful":
            //alert("Friend is removed from your friend list successfully.");
            var msg="Friend is removed from your friend list successfully.";
            ShowMessageBox(msg);
            break;
        case "ErrorInRemoveFriend":
            alert("Error occured while removing a friend from the friend list. Please try again.");
            break;        
        case "":
            //alert("end");
            break;     
           
        case "BlockedUser":
            //alert("User is blocked successfully.");
            var msg="User is blocked successfully.";
            ShowMessageBox(msg);
            break;
        case "ActivatedUser":
            //alert("User is activated successfully.");
            var msg="User is activated successfully.";
            ShowMessageBox(msg);
            break;
           
        case "ErrorInBlockUser":
            alert("Error occured while blocking a user. Please try again.");
            break;    
        case "ErrorInActivateUser":
             alert("Error occured while activating a user. Please try again.");
            break;
        case "CoachAccessRemoved":
            //alert("Coach's access is blocked successfully.");
            var msg="Coach's access is blocked successfully.";
             ShowMessageBox(msg);
            break;    
        case "CoachAccessActivated":
            //alert("Coach's access is activated successfully.");
              var msg="Coach's access is activated successfully.";
             ShowMessageBox(msg);
            break;    
        case "ErrorInRemoveCoachAccess":
            alert("Error occured while blocking a coach's access. Please try again.");
            break;        
        case "ErrorInActivateCoachAccess":
            alert("Error occured while activating the coach's access. Please try again.");
            break;  
        case "AcceptFriendRequestSuccessful":
            //alert("Friend request is accepted successfully.");
            var msg="Friend request is accepted successfully.";
            ShowMessageBox(msg);
            break;
        case "ErrorInAcceptFriendRequest":
            alert("Error occured while accepting a friend  request. Please try again.");
            break;
            
        case "DenyFriendRequestSuccessful":
            //alert("Friend request is denied successfully.");
            var msg="Friend request is denied successfully.";
            ShowMessageBox(msg);
            break;
        case "ErrorInDenyFriendRequest":
            alert("Error occured while denying a friend request. Please try again.");
            break;    
        case "ErrorInSendMessage":
            alert("Error occured while sending a message. Please try again.");            
        case "EditTopicClick":
            UserMessage.value = "";
            return ShowModalPopup('divpnlAddTopic','Topic Reply'); 
            break;
            
        
        case "feedNameSortSuccessful":
            UserMessage.value = "";
            ShowModalPopup('divGoUltraFeeds','GoUltra RSS Feeds');
            return false;
        case "feedNamePagingSuccessful":
            UserMessage.value = "";
            ShowModalPopup('divGoUltraFeeds','GoUltra RSS Feeds');
            return false;    
            break;
        case "setGoUltraFeed":
            UserMessage.value = ""; 
            return setGoUltraFeed();
            break;
        case "RssFeedSavedSuccessful":
            UserMessage.value = "";
            //alert("RSS Feed saved successfully.");
            return closepopup('divAddRSSFeeds');
            
            var msg = "Congratulations! RSS Feed saved successfully.";
            ShowMessageBox(msg);
            break;
        case "ErrorInRssFeedSave":  
            UserMessage.value = "";
            alert("Error occured while saving the RSS Feed. Please try again.");
            return closepopup('divAddRSSFeeds');
            break;  
             
        case "AddBlogCommentSuccessful":
            UserMessage.value = "";
            var AcceptanceStaus = null;
            AcceptanceStaus = document.getElementById("hidCommentAcceptanceStatus"); 
            if(AcceptanceStaus != null && AcceptanceStaus != "")
            {
                var UserAcceptanceStaus = AcceptanceStaus.value;
            }       
            if(UserAcceptanceStaus == 0)
            {
                //alert("Comment on blog is added successfully.\nIt will be visible after approval of blog creator.");
                var msg="Congratulations! Comment on blog is added successfully.\nIt will be visible after approval of blog creator.";
                ShowMessageBox(msg);
             }
             AcceptanceStaus.value="";
             return closepopup('pnlComment');
             break;   
       case "AddReviewSuccessful":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="Congratulations! Review is added successfully.\nIt will be visible after approval of admin.";
             ShowMessageBox(msg);
             break;  
         case "AddReviewCommentSuccessful":
            UserMessage.value = "";
            // alert("Comment on Review is added successfully.\nIt will be visible after approval of review creator.");
             return closepopup('pnlComment');
             break;      
        case "SubscribedSuccessful":
            alert("Congratulations! You are successfully subscribed for this coach.");
            break;
        case "ErrorInSubscription":
            alert("Error occured while entering the subscription for a coach. Please try again.");
            break;
        case "CoachLimitExceed":
            ShowInformationMessageBox("You can not subscribe for this coach as,\n the coach is already subscribed for limited number of users.");
            break;         
        case "UserSubscribedForCoach":
            ShowInformationMessageBox("You are already subscribed for this coach.");
            break;
        case "UserNotSubscribedForCoach":
            return lnkSubscribeCoach_onClick();
            break;
        case "LogSettingsChangedSuccessful":
             UserMessage.value = "";
             alert("Congratulations! Log settings changed successfully.");
             return closepopup('dwindowsettings');
             break;
        case "CoachAcceptedUserRequest":
            UserMessage.value = "";
            var status = confirm("Do you want to send any message to this user?");
            if(status)
            {
                hidSendMsg = document.getElementById("hidSendMessage");
                if(hidSendMsg != null)
                {
                    hidSendMsg.value = "1";
                    ShowModalPopup('divSendMessage','Send Message To User');
                }
                return false;
            }
            else
            {
                hidSendMsg = document.getElementById("hidSendMessage");
                if(hidSendMsg != null)
                {
                    hidSendMsg.value = "0";
                    hidButton = document.getElementById("btnHiddenSubscribe");
                    if(hidButton != null)
                    {
                        hidButton.click();
                    }
                }
                else
                {
                    return false;
                }
            }
            
            break;
            
        case "ErrorInAcceptingUserRequest":
            alert("Error occured while accepting the user's request. Plaese try again.");
            break;         
        case "CoachIgnoredUserRequest":
            UserMessage.value = "";
            var status = confirm("Do you want to send any message to this user?");
            if(status)
            {
                hidSendMsg = document.getElementById("hidSendMessage");
                if(hidSendMsg != null)
                {
                    hidSendMsg.value = "1";
                    ShowModalPopup('divSendMessage','Send Message To User');
                }
            }
            else
            {
                hidSendMsg = document.getElementById("hidSendMessage");
                if(hidSendMsg != null)
                {
                    hidSendMsg.value = "0";
                    hidButton = document.getElementById("btnHiddenSubscribe");
                    if(hidButton != null)
                    {
                        hidButton.click();
                    }
                }
            }
            return false;
            break;
        case "ErrorInIgnoringUserRequest":
            alert("Error occured while ignoring the user's request. Plaese try again.");
            break;
        case "NotProperXML":
            if(document.getElementById("WarningMsgs_divWarningInfo")!=null)
            {
                 document.getElementById("WarningMsgs_RegistrationErrors").innerHTML="Please enter a valid XML filename !";
                 document.getElementById("WarningMsgs_RegistrationErrors").style.display = "block";;
                 document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
            }
            else
            {
                alert("Please enter a valid XML filename !");
            }
            
            break;    
        case "NotValidData_ForgotPassword":
            divObj = document.getElementById("divStatus");
            divObj.innerHTML = "Please enter valid Email-Id,security question and answer.";
            divObj.style.fontWeight="bold!important";
            divObj.style.display="block";
            break;    
        case "PasswordSent":
            divObj = document.getElementById("divStatus");
            divObj.innerHTML = "Password has been sent to ur Email-Id.";
            divObj.style.display="block";
            break; 
        case "ErrorInSendingMail":
            divObj = document.getElementById("divStatus");
            divObj.innerHTML = "Error occured while sending the Email. Please try again.";
            divObj.style.display="block";
            break;
        case "ErrorNewsLetterConfiguration":
            //alert("You need to save newsletter before configure advertisement.");
            //alert("hello");
            ShowInformationMessageBox("You need to save newsletter before configure advertisement.");
            window.refresh;
            break;
            
        case "SendFriendRequestSuccessful":
            ShowMessageBox("Friend Request sent sucessfully.");
            document.getElementById("hidUserMessage").value="";
        break;
        
        case "SendFriendRequestError":
            ShowInformationMessageBox("Error while sending Friend Request.");
            document.getElementById("hidUserMessage").value="";
        break;
        
        case "SendFriendAlreadyAdded":
            ShowInformationMessageBox("Your friend request is pending.");
            document.getElementById("hidUserMessage").value="";
        break;
        
        case "RemoveFriendSucessful":
            ShowMessageBox("Friend is removed from your friend list successfully.");
            document.getElementById("hidUserMessage").value="";
        break;
        
        case "UserNotLoggedIn":
            ShowInformationMessageBox("Please log in to add this person as your friend.");
            document.getElementById("hidUserMessage").value="";
        break;
        
        
        
        
        case "UserFollowsOwnBlog":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="You can not follow your own blog.";
             ShowInformationMessageBox(msg);
             break;
             
         case "BlogFollowSuccess":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="Congratulations! Your request to follow blog processed successfully.";
             ShowMessageBox(msg);
             break;
             
          case "BlogFollowFailure":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="Sorry! Your request to follow blog is not completed.";
             ShowInformationMessageBox(msg);
             break;
             
           case "BlogUnFollowSuccess":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="Congratulations! Your request to unfollow blog processed successfully.";
             ShowMessageBox(msg);
             break;
             
           case "BlogUnFollowFailure":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="Sorry! Your request to unfollow blog is not completed.";
             ShowInformationMessageBox(msg);
             break;
             
           case "UserLikesOwnBlog":
            UserMessage.value = "";
             //alert("Review is added successfully.\nIt will be visible after approval of admin.");
             var msg="UserLikesOwnBlog.";
             ShowInformationMessageBox(msg);
             break;
             
             
          case "OpenInvitePopup":   
             UserMessage.value = "";
             var displayName = document.getElementById("hidDisplayName").value;
             var isLogin = document.getElementById("hidIsLogin").value;
             var challengeTitle= document.getElementById("hidBlogTitle").value;
             CallInviteFriends(challengeTitle,displayName,isLogin,'True');
             break; 
             
          case "FailedToOpenPopup":
            UserMessage.value = "";
            var msg="Please select checkbox before sending invitation.";     
            ShowInformationMessageBox(msg); 
            break;
               
        default:
            return;
    }
    
    UserMessage.value = "";
    
}

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_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];
     }
  }
}

function swapButtonImageMouseover(btnId, btnSize)
{
    btn = document.getElementById(btnId);
    if(btnSize == 's' || btnSize== 'S')
    {
        btn.className = "clsSmallButtonRollover";
    }
    else if(btnSize == 'l' || btnSize == 'L')
    {
        btn.className = "clsLargeButtonRollover";
    }
    else
    {
        btn.className = "clsMediumButtonRollover";
    }
}

function restoreButtonImage(btnId, btnSize)
{
     btn = document.getElementById(btnId);
    if(btnSize == 's' || btnSize== 'S')
    {
        btn.className = "clsSmallButton";
    }
    else if(btnSize == 'l' || btnSize == 'L')
    {
        btn.className = "clsLargeButton";
    }
    else
    {
        btn.className = "clsMediumButton";
    }
}

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 toggleOnlineList(ctrlId)
   {
        var ctrl;
        ctrl = document.getElementById(ctrlId);
        if (ctrl != null)
        {
            if ((ctrl.style.display == 'block') || (ctrl.style.display == ''))
            {
                ctrl.style.display = 'none';
            }
            else 
            if (ctrl.style.display == 'none')
            {
                ctrl.style.display = 'block';     
            }           
        }
   }
   
//   function checkFlashPlayer()
//   {  if(pluginlist!=null)
//      {   
//          if (pluginlist.indexOf("Flash")!=-1)
//          {   // document.write("You have flash installed");
//              //alert("You have flash player plugin");
//          }
//          else
//          {
//              ShowMessageBox("You need to download and install player plugin.");
//          }
//       }      
//   }
   
   
   
//function reload()
//{
//    self.location.href="WebPages/User/Logout.aspx?mode=1";
//}
function refresh_page()
{
    //setTimeout("reload()",1000);
    self.location.href="WebPages/User/Logout.aspx?mode=1";
}


function FBLogout()
{
    var LoginWithFacebook  =  document.getElementById("TopFrame1_hidIsLoginwithFacebook")
    var FacebookFlag ="False";
    if(LoginWithFacebook != null )
    {
       
        FacebookFlag = LoginWithFacebook.value;
    }
    
    if(FacebookFlag == "True")
    {
    CallFBRequireFeatures();
        FB.ensureInit(function() {       
            FB.Connect.logout(function() { refresh_page(); });
        });
        refresh_page(); 
    }
    else
    { 
        refresh_page();
    
    }
}


    function fullScreen(strUrl)
    {
       window.open(strUrl);
    }
   
   
//Session Timeout
var flag = false;
var timerId=null;  

function checkSessionTimeout()
{

  registerHandlers();
  startSessionTimer();
}
function resetTimer()
{
       timeoutValue = 1200000; //20 minutes
        //timeoutValue = 60000; //1 Minute for testing
}
function startSessionTimer() 
{
  //if(timerId!=null)
  
      clearTimeout(timerId);
      resetTimer();
      timerId = setTimeout(showMsg,timeoutValue); 
}
 function CallToReset(e)
 {
    startSessionTimer();
}
function registerHandlers() 
{
    document.onclick =CallToReset;
    document.oncontextmenu = CallToReset;
    document.onkeypress =CallToReset;
    document.ondblclick =CallToReset;
    document.onfocusin  =CallToReset;  
    document.documentElement.onclick = CallToReset;
    window.onscroll = CallToReset;

    if (document.captureEvents) 
    { 
         document.captureEvents(Event.keyUp);
    }
    document.onkeyup = keyUp;  
}
function keyUp(e) {
var isIE = (document.all)? true:false;
var KeyID = 0;
	if (isIE)
	{
		KeyID=event.keyCode;
	} 
	else
	{
		KeyID=e.which;
	}  
   switch(KeyID)
   {
	  case 9 : /// For TAB Key
	   CallToReset();
	   break;
	  case 13: /// For ENTER Key
	   CallToReset();
	   break;
			
	}
}
function showMsg()
{    
	 //path = "WebPages/User/Logout.aspx?mode=1";
	 //top.location.href = path;	
	 FBLogout();		 
      //Your redirection
}

function CallFBRequireFeatures()
{
    var currUrl;
    
    var posURL1,posURL2,posURL3,posURL4,posURL5,posURL6;
    
    currUrl = String(self.location);
    
    currUrl = currUrl.toLowerCase();
    	 
    posURL1 = currUrl.indexOf("http://www.go-ultra.com");
    
    posURL2 = currUrl.indexOf("http://go-ultra.com");
    
    posURL3 = currUrl.indexOf("http://www.goultrasports.com");
    
    posURL4 = currUrl.indexOf("http://goultrasports.com");
	
	//posURL5 = currUrl.indexOf("http://goultratest2");
	
	posURL5 = currUrl.indexOf("http://192.168.200.8");
	
	posURL6 = currUrl.indexOf("http://121.241.77.229");
	
	if(posURL1 >= 0)
	{
	    FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"xd_receiver.htm"
						); 
					}
				); 
	}
   else if(posURL2 >= 0)
   {
       FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"xd_receiver.htm"
						); 
					}
				); 
   }
   else if(posURL3 >= 0)
   {
        FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"xd_receiver.htm"
						); 
					}
				); 
   }
   else if(posURL4 >= 0)
   {
        FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"89fb9a953dc4eb0adf700008bbf22940", 
							"xd_receiver.htm"
						); 
					}
				);    
   }
   else if(posURL5 >= 0)
   {
          FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"21fc39d41c399f7383e75ab4e8d05ae6", 
							"xd_receiver.htm"
						); 
					}
				);       
   }
   else if(posURL6 >= 0)
   {
        FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"9ff0f0c98159ed46f8ed389e890abab7", 
							"xd_receiver.htm"
						); 
					}
				);     
   }
   else
   {
       FB_RequireFeatures(
					["XFBML"], 
					function(){ 
						FB.Facebook.init(
							"21fc39d41c399f7383e75ab4e8d05ae6", 
							"xd_receiver.htm"
						); 
					}
				);     
   }
}

function setCookie(name, value, seconds) 
{
	if (typeof(seconds) != 'undefined') 
	{
		var date = new Date();
		date.setTime(date.getTime() + (seconds*1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else 
	{
		var expires = "";
	}

	document.cookie = name+"="+value+expires+"; path=/";
}
 
function getCookie(name) 
{
	name = name + "=";
	var carray = document.cookie.split(';');
	for(var i=0;i < carray.length;i++) {
		var c = carray[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
	}
    return null;
}
 
function deleteCookie(name) 
{
	setCookie(name, "", -1);
}
  function swapImage(btnId,cssClassName) 
        { 
            document.getElementById(btnId).className =cssClassName; 
        }




function showThirdLevelMenu(path)
{
  var DivScript="";
  var Div=document.getElementById("TopFrame1_divThirdMenu");
   if(WorkoutLeft1==0 && AtheleleLeft1==0)
  {
  
    getDefaultLeftTop();
  }
 
 // alert("in fun");
 // alert("Workout left="+document.getElementById("ancmy workouts").offsetLeft+" top="+document.getElementById("ancmy workouts").offsetTop);
  //  alert("athelete tools left="+document.getElementById("ancathlete tools").offsetLeft+" top="+document.getElementById("ancathlete tools").offsetTop);
   // alert("Workout left="+getElLeft(document.getElementById("ancmy workouts"))+" top="+getElTop(document.getElementById("ancmy workouts")));
   // alert("athelete tools left="+getElLeft(document.getElementById("ancathlete tools"))+" top="+getElTop(document.getElementById("ancathlete tools")));

  if(path.indexOf("LogDetails")==0)
  {
  
    DivScript="";
    DivScript=DivScript+"<div class='MiddleArrow' style='top:-0px;left:20px;'></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/LogDetails.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:8px;\">Workout Log</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/LogDetails.aspx?Show=WorkoutSetting' style='color:white;text-decoration: none; cursor:hand;'><div style=\"padding-top:10px;\">Workout Settings</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/LogReports.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:8px;\">Reports</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/ShoeDetails.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:8px;\">Shoe Tracking</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenuLast'><a href='WebPages/LogBook/TireDetails.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:8px;\">Tire Tracking</div></a></div>";
    
    
    
//    DivScript="";
//    DivScript=DivScript+"<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"> <tr> <td class='MiddleArrow' style='top:-0px;left:70px;'></td></tr>";
//    DivScript=DivScript+"<tr><td class='clsthirdMenu'><a onclick=\"javascript:return ShowLogSettings();\" style='color:white;text-decoration: none;'><span style=\"padding-top:10px;\">Workout Setting</span></a></td></tr>";
//    DivScript=DivScript+"<tr><td class='clsthirdMenu'><a href='../../WebPages/LogBook/LogReports.aspx' style='color:white;text-decoration: none;'><span style=\"padding-top:8px;\">Report</span></a></td></tr>";
//    DivScript=DivScript+"<tr><td class='clsthirdMenu'><a href='ShoeDetails.aspx' style='color:white;text-decoration: none;'><span style=\"padding-top:8px;\">Shoe Tracking</span></a></td></tr>";
//    DivScript=DivScript+"<tr><td class='clsthirdMenuLast'><a href='TireDetails.aspx' style='color:white;text-decoration: none;'><span style=\"padding-top:8px;\">Tire Tracking</span></a></td></tr>";
//    DivScript=DivScript+"</table>";
      if(Div!=null)
      {
         Div.innerHTML=DivScript;
        Div.style.display="block";
//        Div.style.left="150px";
//        if(document.getElementById("PageFooter_hidUserRole").value!="")
//        {
//            Div.style.top="192px";
//         }
//         else
//         {
//            Div.style.top="194px";
//         }
        if(WorkoutLeft1==0)
        {
            if(document.getElementById("ancmy workouts")!=null)
            {
                  Div.style.top=getElTop(document.getElementById("ancmy workouts"))+22+"px";
                  Div.style.left=getElLeft(document.getElementById("ancmy workouts"))+8+"px";
            }
        }
        else
          {
         //   Div.style.top=WorkoutTop1;
          Div.style.top=getElTop(document.getElementById("ancmy workouts"))+22+"px";
            Div.style.left=WorkoutLeft1;
          }
    
      }
  }
  else if(path.indexOf("GPSDataUpload")==0)
  {
    DivScript="";
//    DivScript=DivScript+"<div class='MiddleArrow' style='top:-0px;left:20px;'></div>";
//    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/LogBook/GPSDataUpload.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Garmin</div></a></div>";
//    DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/NikePlusDataUpload.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:8px;\">Nike+</div></a></div>";
//    DivScript=DivScript+"<div class='clsthirdMenuLast'><a onclick='WebPages/LogBook/LogDetails.aspx?Show=ImportData' style='color:white;text-decoration: none;'><div style=\"padding-top:8px;\">Excel Spreadsheet</div></a></div>";
     
        DivScript=DivScript+"<div class='MiddleArrow' style='top: -0px;left:20px;'></div>";
        DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/GPSDataUpload.aspx' style='color:white;text-decoration: none;cursor:hand;'><div style=\"padding-top:8px;\">Garmin</div></a></div>";
        DivScript=DivScript+"<div class='clsthirdMenu'><a href='WebPages/LogBook/NikePlusDataUpload.aspx?Show=WorkoutSetting' style='color:white;text-decoration: none; cursor:hand;'><div style=\"padding-top:8px;\">Nike+</div></a></div>";
        DivScript=DivScript+"<div class='clsthirdMenuLast'><a href='WebPages/LogBook/LogDetails.aspx?Show=ImportData' style='color:white;text-decoration: none;cursor:hand;'><div style=\"padding-top:8px;\">Excel Spreadsheet</div></a></div>";
       
    
      if(Div!=null)
      {
       
        Div.innerHTML=DivScript;
        Div.style.display="block";
//        Div.style.left="280px";
//          if(document.getElementById("PageFooter_hidUserRole").value!="")
//        {
//            Div.style.top="192px";
//         }
//         else
//         {
//            Div.style.top="194px";
//         }
        if(ImportLeft1==0)
        {
            if(document.getElementById("ancimport/export")!=null)
            {
                  Div.style.top=getElTop(document.getElementById("ancimport/export"))+22+"px";
                  Div.style.left=getElLeft(document.getElementById("ancimport/export"))+8+"px";
            }
        }
        else
          {
          //  Div.style.top=ImportTop1;
            Div.style.top=getElTop(document.getElementById("ancimport/export"))+22+"px";
            Div.style.left=ImportLeft1;
          }
      }
  }
 else if(path.indexOf("AthleteTools")==0)
  {
    DivScript="";
    DivScript=DivScript+"<div class='MiddleArrow' style='top:-0px;left:20px;'></div>";
     DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/AthleteTools/AthleteTools.aspx?calc=6' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">BMI Calculator</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/AthleteTools/AthleteTools.aspx?calc=1' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Pace Calculator</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/AthleteTools/AthleteTools.aspx?calc=3' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Calorie Calculator</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/AthleteTools/AthleteTools.aspx?calc=4' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Conversion Calculator</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/AthleteTools/AthleteTools.aspx?calc=2' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Heart Rate Calculator</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenuLast'><a  href='WebPages/AthleteTools/AthleteTools.aspx?calc=5' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Race Time Predictor</div></a></div>";
    
      if(Div!=null)
      {
        Div.innerHTML=DivScript;
        Div.style.display="block";
//        if(document.getElementById("PageFooter_hidUserRole").value!="")
//        {
//            Div.style.left="590px";
//             Div.style.top="192px";
//        }
//        else
//        {
//            Div.style.left="270px";
//             Div.style.top="194px";
//        }
        if(AtheleleLeft1==0)
        {   
            if(document.getElementById("ancathlete tools")!=null)
            {
                  Div.style.top=getElTop(document.getElementById("ancathlete tools"))+22+"px";
                  Div.style.left=getElLeft(document.getElementById("ancathlete tools"))+8+"px";
            }
        }
        else
          {
           // Div.style.top=AtheleleTop1;
              Div.style.top=getElTop(document.getElementById("ancathlete tools"))+22+"px";
            Div.style.left=AtheleleLeft1;
          }
      }
  }
  else if(path.indexOf("PublicProfile")==0)
  {
     var LoginUserName="";
    if(document.getElementById("PageFooter_hUserName")!=null && document.getElementById("PageFooter_hUserName").value!="")
    {
     LoginUserName=document.getElementById("PageFooter_hUserName").value;
    }
    DivScript="";
    DivScript=DivScript+"<div class='MiddleArrow' style='top:-0px;left:20px;'></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='Profile/"+LoginUserName+"' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">View Profile</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/User/EditProfile.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Edit Profile</div></a></div>";
    DivScript=DivScript+"<div class='clsthirdMenuLast'><a  href='WebPages/User/ChangePassword.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">Settings</div></a></div>";
    
      if(Div!=null)
      {
     
        Div.innerHTML=DivScript;
        Div.style.display="block";
//        Div.style.left="890px";
//        if(document.getElementById("PageFooter_hidUserRole").value!="")
//        {
//            Div.style.top="192px";
//         }
//         else
//         {
//            Div.style.top="194px";
//         }
        if(settingleft1==0)
        {
            if(document.getElementById("ancprofile")!=null)
            {
                  Div.style.top=getElTop(document.getElementById("ancprofile"))+22+"px";
                  Div.style.left=getElLeft(document.getElementById("ancprofile"))+8+"px";
            }
        }
         else
          {
          //  Div.style.top=settingtop1;
           Div.style.top=getElTop(document.getElementById("ancprofile"))+22+"px";
            Div.style.left=settingleft1;
          }
      }
  }
  
   else if(path.indexOf("GlobalChallenges")==0)
  {
 
     DivScript="";
        DivScript=DivScript+"<div class='MiddleArrow' style='top:-0px;left:20px;'></div>";
        DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/LogBook/GlobalChallenges.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">All Challenges</div></a></div>";
        var isUserLoggedIn = document.getElementById("TopFrame1_hidIsUserLoggedIn").value;
       
        if (isUserLoggedIn == "true")            
            DivScript=DivScript+"<div class='clsthirdMenu'><a  href='WebPages/LogBook/MyChallenges.aspx' style='color:white;text-decoration: none;'><div style=\"padding-top:10px;\">My Challenges</div></a></div>";
           
      if(Div!=null)
      {
     
        Div.innerHTML=DivScript;
        Div.style.display="block";

        if(challegesLeft1==0)
        {
            if(document.getElementById("ancchallenges")!=null)
            {
                  Div.style.top=getElTop(document.getElementById("ancchallenges"))+22+"px";
                  Div.style.left=getElLeft(document.getElementById("ancchallenges"))+8+"px";
            }
        }
         else
          {
          //  Div.style.top=settingtop1;
           Div.style.top=getElTop(document.getElementById("ancchallenges"))+22+"px";
            Div.style.left=challegesLeft1;
          }
      }
  }
  
  else
  {
    if(Div!=null)
      {
        Div.innerHTML="";
        Div.style.display="none";
      }
  }
    document.getElementById("TopFrame1_tblThirdMenu").style.display="block";
      document.getElementById("TopFrame1_tblThirdMenuTop").style.display="block";
  
}
var WorkoutLeft1=0,WorkoutTop1=0,ImportTop1=0,ImportLeft1=0,AtheleleLeft1=0,AtheleleTop1=0,settingleft1=0,settingtop1=0,challegesLeft1=0,challengesTop1=0;
function getDefaultLeftTop()
{
    //WorkoutLeft=0,WorkoutTop=0,ImportTop=0,ImportLeft=0,AtheleleLeft=0,AtheleleTop=0,settingleft=0,settingtop=0;
     if(document.getElementById("ancmy workouts")!=null)
         {
             WorkoutTop1=getElTop(document.getElementById("ancmy workouts"))+22+"px";
              WorkoutLeft1=getElLeft(document.getElementById("ancmy workouts"))+8+"px";
              
         }
          if(document.getElementById("ancimport/export")!=null)
        {
              ImportTop1=getElTop(document.getElementById("ancimport/export"))+22+"px";
              ImportLeft1=getElLeft(document.getElementById("ancimport/export"))+8+"px";
        }
         if(document.getElementById("ancathlete tools")!=null)
        {
             AtheleleTop1=getElTop(document.getElementById("ancathlete tools"))+22+"px";
              AtheleleLeft1=getElLeft(document.getElementById("ancathlete tools"))+8+"px";
        }
        if(document.getElementById("ancprofile")!=null)
        {
              settingtop1=getElTop(document.getElementById("ancprofile"))+22+"px";
              settingleft1=getElLeft(document.getElementById("ancprofile"))+8+"px";
        }
          if(document.getElementById("ancchallenges")!=null)
        {
              challengesTop1=getElTop(document.getElementById("ancchallenges"))+22+"px";
              challegesLeft1=getElLeft(document.getElementById("ancchallenges"))+8+"px";
        }
}
function HeighlightTopMenu()
{

    var Div=document.getElementById("TopFrame1_divThirdMenu");
    var ActiveMenu="";
    var OnSameMenu=false;
      var OnWorkoutMenu=false;
    if(document.getElementById("TopFrame1_hidCurrentMenu")!=null)
    {
         ActiveMenu=document.getElementById("TopFrame1_hidCurrentMenu").value;
    }
      if(Div!=null)
      {
       if(Div.innerHTML.indexOf("AthleteTools")>=0 || Div.innerHTML.indexOf("NikePlusDataUpload")>=0 ||  Div.innerHTML.indexOf("LogReports")>=0 ||  Div.innerHTML.indexOf("GlobalChallenges")>=0 )
       {
             document.getElementById("WORKOUTS").className="selectedcurrent";
              OnWorkoutMenu=true;
       }
       else if(Div.innerHTML.indexOf("EditProfile")>=0)
       {
            document.getElementById("MY STUFF").className="selectedcurrent";
            OnSameMenu=true;
       }
       
      }
  
    if(ActiveMenu!="")
    {
        document.getElementById(ActiveMenu).className="deselectedcurrent"; 
    }
    if(OnSameMenu==true && ActiveMenu=="MY STUFF")
    {
          document.getElementById(ActiveMenu).className="current"; 
    }
     if(OnWorkoutMenu==true && ActiveMenu=="WORKOUTS")
    {
         document.getElementById(ActiveMenu).className="current"; 
    }
    document.getElementById("TopFrame1_tblThirdMenu").style.display="block";
     document.getElementById("TopFrame1_tblThirdMenuTop").style.display="block";
    return false;
}
function RestoreOriginal()
{

     var Div=document.getElementById("TopFrame1_divThirdMenu");
     var ActiveMenu="";
   if(document.getElementById("TopFrame1_hidCurrentMenu")!=null)
   {
     ActiveMenu=document.getElementById("TopFrame1_hidCurrentMenu").value;
   }
     if(Div!=null)
      {
       if(Div.innerHTML.indexOf("AthleteTools")>=0 || Div.innerHTML.indexOf("NikePlusDataUpload")>=0 ||  Div.innerHTML.indexOf("LogReports")>=0 ||  Div.innerHTML.indexOf("GlobalChallenges")>=0 )
       {
             document.getElementById("WORKOUTS").className="select";
       }
       else if(Div.innerHTML.indexOf("EditProfile")>=0 )
       {
             document.getElementById("MY STUFF").className="select";
       }
      }
   
   if(ActiveMenu!="")
   {
      document.getElementById(ActiveMenu).className="current"; 
    
     }

    return false;
}
function HideMenu()//Hiding 3rd level menu
{
  var Div=document.getElementById("TopFrame1_divThirdMenu");
  document.getElementById("TopFrame1_tblThirdMenu").style.display="none";
   document.getElementById("TopFrame1_tblThirdMenuTop").style.display="none";
  
 Div.style.display="none";
 WorkoutLeft1=0,WorkoutTop1=0,ImportTop1=0,ImportLeft1=0,AtheleleLeft1=0,AtheleleTop1=0,settingleft1=0,settingtop1=0;
   return false;
}


var ns4 = (navigator.appName.indexOf("Netscape")>=0 
          && parseFloat(navigator.appVersion) >= 4 
          && parseFloat(navigator.appVersion) < 5)? true : false;
var ns6 = (parseFloat(navigator.appVersion) >= 5 
          && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;

function getElLeft(el) {
    if (ns4) {return el.pageX;} 
    else {
        xPos = el.offsetLeft;
        tempEl = el.offsetParent;
        while (tempEl != null) {
            xPos += tempEl.offsetLeft;
              tempEl = tempEl.offsetParent;
        }
        return xPos;
    }
}
function getElTop(el) {
    if (ns4) {return el.pageY;} 
    else {
        yPos = el.offsetTop;
        tempEl = el.offsetParent;
        while (tempEl != null) {
            yPos += tempEl.offsetTop;
              tempEl = tempEl.offsetParent;
        }
        return yPos;
    }
}

