﻿/*function to create a cookie on divtop close image click*/
function setCookie(szName, szValue, szExpires, szPath, szDomain, bSecure) {
    var szCookieText = escape(szName) + '=' + escape(szValue);
    szCookieText += (szExpires ? '; EXPIRES=' + szExpires.toGMTString() : '');
    szCookieText += (szPath ? '; PATH=' + szPath : '');
    szCookieText += (szDomain ? '; DOMAIN=' + szDomain : '');
    szCookieText += (bSecure ? '; SECURE' : '');

    document.cookie = szCookieText;
}

function CreateCookieandClose() {

    var today = new Date();
    var nextMonth = new Date(today.getYear(), today.getMonth() + 1, today.getDate());
    setCookie("CloseDivTopCookie", "YES", nextMonth);
}


function check_log() {
    var api = FB.Facebook.apiClient;
    var uiid = api.get_session().uid;
    alert(uiid);
    loadFriends(uiid);
}

function doPost_Profile() {
    FB.XFBML.Host.parseDomTree();
    var FullName = document.getElementById('<%=hdFullNameProfile.ClientID%>').value;
    var GizaSiteAddres = document.getElementById('<%=hdGizaSiteAddressProfile.ClientID%>').value;
    var valueUserMsg = "Just discovered " + FullName + "'s social profiles organized at " + GizaSiteAddres;
    var user_message_prompt = "";
    var user_message = { value: valueUserMsg };
    var template_data = { content: "<fb:tag name='div'>  <fb:tag-attribute name='class'>user_info</fb:tag-attribute>  <fb:tag-attribute name='title'>  <fb:intl>  <fb:name uid='12345'/> has {number} friends. <fb:intl-token name='number'>15</fb:intl-token>  </fb:intl>  </fb:tag-attribute>  <fb:tag-body>  <fb:intl>  <fb:name uid='12345'/> is in first place. </fb:intl>  </fb:tag-body> </fb:tag>" }
    FB.Connect.showFeedDialog(124431468571, '', '', '', null, FB.RequireConnect.doNotRequire, callback, user_message_prompt, user_message);
    return false;
}
function callback() {
    return false;
}




function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 50 + 'px';
    top.style.left = location.x - 50 + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}

function BulletinCount(text, long) {
    var maxlength = new Number(long); 
    if (document.getElementById('<%=txtRepErrMessage.ClientID%>').value.length > maxlength) {
        text.value = text.value.substring(0, maxlength);
    }
}



function ValidateSocialServices(source, arguments) {

    var socialProfileList = document.getElementById("ddlSocialServices");
    if (socialProfileList != null) {

        var socialService = arguments.valueOf(socialProfileList); 

        if (socialService.Value == "0" || socialService.Value == "----------------") {
            arguments.IsValid = false;
        }
        else {
            arguments.IsValid = true;
        }
    }
}


// This function is used to hide the modular popup on page

function HideModalPopupExtender(controlId) {
    var myExtender = $find(controlId);
    if (myExtender != null) {
        myExtender.hide();
        return true;
    }
}

// This function is used to show the modular popup on page

function StartProgressBar(controlID) {
 var myExtender = $find(controlID);
    myExtender.show();
    return true;
}

// This function is used to hide the modular popup on parent page i.e. on MyAccount.aspx
function parentButtonClick() {
    parent.InvokeHideProgressBar();
}

 function ApplyCustomHeaderSettings(customHeaderDetails) {             
             var colors = customHeaderDetails.split('$');             
             $('.topHeaderTbl').css('background-color', colors[0]);
             
             $('#LblName').css('color', colors[1]);
             $('#LblCount').css('color', colors[1]);
             $('#LblViews').css('color', colors[1]);
             $('#LblFavourite').css('color', colors[1]);
             $('#LblShare').css('color', colors[1]);
             $('#LblGizaPage').css('color', colors[1]);
             $('#LblSignIn').css('color', colors[1]);
            
 }
 
 function LoadTabs(strValues, strUrlName, strID, strImageURL, PrivacySetting, GizaEntityID, strIframeCompat,gizaProfileLogoUrl) {
             // load Profile tab with public data
             if (PrivacySetting == 'Public') {
                 var he = document.documentElement.clientHeight - 3;
                 var tabs = new Ext.TabPanel
                     (
                        {
                            renderTo: 'tabs',
                            id: 'tabpanelProfileview',
                            resizeTabs: false,
                            minTabWidth: document.documentElement.clientHeight ,
                            tabWidth:document.documentElement.clientWidth ,
							height: he,
							activeTab: 0,
							autoWidth: true,
							autoScroll: false,
							enableTabScroll: true,
							border: false,

                            items: [ // tab items
                        {
                        html: '<iframe height="100%"  scrolling="Yes" width="100%" frameborder="0" src="profile.aspx?GizaEntityID=' + GizaEntityID + '&SecuritySetting=Public&PublicProfile=YES"/>',
                        //title: 'Profile',
                        title: '<img style="height:16px;width:16px; padding-left:2px; margin-left:0px; padding-bottom:3px; horizontal-align:left;vertical-align:top;" src=\"'+gizaProfileLogoUrl+'\"/>&nbsp;Profile',
                        id: 'MyProfile',
                        activeTab: 0,
                        iconCls: 'tabs',
                        closable: false,
                        autoScroll: false
                    }
                        ]
                        });

               
                 var extender = Ext.getCmp("tabpanelProfileview"); //get a reference to the extender           
                 var newarray = strValues.split("$");
                 var newarrayName = strUrlName.split("$");
                 var newarrayID = strID.split("$");
                 var newarrayImage = strImageURL.split("$");
                 var newarrayIFrameCompat = strIframeCompat.split("$");
                 var GizaID = GizaEntityID;

                 var browserName = navigator.appName;
                 if (browserName == 'Netscape')
                     he = he - 47;
                 else
                     he = he - 57;
                 for (var i = 0; i < newarray.length - 1; i++) {
				   
                     extender.add({
                         title: '<img style="width:16px;height:16px;padding-bottom:3px;horizontal-align:left;vertical-align:top;margin-left:2px"  src="http://www.gizapage.com/icons' + '\\' + newarrayImage[i] + '"/>' + ' ' + newarrayName[i],
                         //title: '<img style="width:16px;height:16px;padding-bottom:3px;horizontal-align:left;vertical-align:top;"  src="icons'+'\\'+newarrayImage[i]+'"/>'+ ' '+ newarrayName[i],
                         id: newarrayID[i] + '$' + newarray[i],
                         iconCls: 'tabs', // tab icon from css class tabs (mainstyle.css)
                         html: '<iframe height="100%" scrolling="no" width="100%" frameborder="0" src="SocialPageSettings.aspx?ShowButton=false&PageHeight=' + he + '&SocialPageName=' + newarray[i] + '&SocialServiceId=' + newarrayID[i] + '&SocialServiceURL=' + newarrayName[i] + '&GizaEntityID=' + GizaEntityID + '&IframeCompat=' + newarrayIFrameCompat[i] + '"/>',
                         closable: true,
                         autoScroll: false
                     })
					
                 }
             }
             else if (PrivacySetting == 'Private') {
                 // load Profile tab with private data


                 var he = document.documentElement.clientHeight - 3;
                 var tabs = new Ext.TabPanel({
                     renderTo: 'tabs',
                     id: 'tabpanelPublicView',
                     resizeTabs: false,
                     // turn on tab resizing
                     enableTabScroll: true,
                     height: he,
                     activeTab: 0,
                     autoScroll: false,
                     border: false,

                     items: [ // tab items

                        {
                        html: '<iframe height="100%" scrolling="yes" width="100%" frameborder="0" src="profile.aspx?GizaEntityID=' + GizaEntityID + '&SecuritySetting=PRIVATE"/>',
                        title: '<img style="height:16px;width:16px; padding-left:0px;margin-left:0px;padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="http://images.gizapage.com/icons/PublicViewLogo.png" />&nbsp;Profile',
                        //title: '<img style="height:16px;width:19px; padding-left:0px;margin-left:0px;padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="Images/PublicViewLogo.gif" />&nbsp;Profile',

                        id: 'MyProfile',
                        activeTab: 0,
                        iconCls: 'tabs',
                        closable: false,

                        autoScroll: false



                    }
                        ]

                 });
               
                 var extender = Ext.getCmp("tabpanelPublicView"); //get a reference to the extender           
                 var newarray = strValues.split("$");
                 var newarrayName = strUrlName.split("$");
                 var newarrayID = strID.split("$");
                 var newarrayImage = strImageURL.split("$");
                 var newarrayIFrameCompat = strIframeCompat.split("$");
                 var browserName = navigator.appName;
                 if (browserName == 'Netscape')
                     he = he - 47;
                 else
                     he = he - 57;
                 for (var i = 0; i < newarray.length - 1; i++) {
                     extender.add({
                         title: '<img style="width:16px;height:16px;padding-left:0px; padding-right:3px;padding-bottom:3px;horizontal-align:left;vertical-align:top;"  src="http://www.gizapage.com/icons' + '\\' + newarrayImage[i] + '"/>' + ' ' + newarrayName[i],
                         //title: '<img style="width:16px;height:16px;padding-left:0px; padding-right:3px;padding-bottom:3px;horizontal-align:left;vertical-align:top;"  src="icons'+'\\'+newarrayImage[i]+'"/>'+ ' '+ newarrayName[i],
                         id: newarrayID[i],
                         iconCls: 'tabs', // tab icon from css class tabs (mainstyle.css)
                         html: '<iframe height="100%" scrolling="no" width="100%" frameborder="0" src="SocialPageSettings.aspx?ShowButton=false&PageHeight=' + he + '&SocialPageName=' + newarray[i] + '&SocialServiceId=' + newarrayID[i] + '&SocialServiceURL=' + newarrayName[i] + '&GizaEntityID=' + GizaEntityID + '&IframeCompat=' + newarrayIFrameCompat[i] + '"/>',
                         border: false,

                         closable: true


                     })
		     
                 }
                
                 extender.activate('MyProfile');

             }

            
             else {

                 //load profile fully
                 //load connections fully
                 //load social pages
                 //load Plus tab

                 var he = document.documentElement.clientHeight - 3;
                 var tabs = new Ext.TabPanel({
                     renderTo: 'tabs',
                     id: 'tabpanelPublicView',
                     resizeTabs: false,
                     // turn on tab resizing
                     enableTabScroll: true,
                     height: he,
                     activeTab: 0,
                     autoScroll: false,

                     border: false,
                     defaults: {
                         // applied to each contained panel

                         bodyStyle: 'background:#e9e5e5;'

                     },
                     items: [ // tab items

                        {
                        html: '<iframe width="100%" height="100%"  scrolling="auto" frameborder="0" src="profile.aspx?SecuritySetting=MYSELF"/>',
                        title: '<img style="height:16px;width:16px;padding-left:0px; margin-left:0px; padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="http://images.gizapage.com/icons/PublicViewLogo.png" />&nbsp;Profile',
                        //title: '<img style="height:16px;width:19px;padding-left:0px; margin-left:0px; padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="Images/PublicViewLogo.gif" />&nbsp;Profile',

                        id: 'MyProfile',
                        activeTab: 0,

                        iconCls: 'tabs',
                        closable: false,
                        autoScroll: false


                    }
                        ]

                 });

                 var extender = Ext.getCmp("tabpanelPublicView"); //get a reference to the extender           
                 var newarray = strValues.split("$");
                 var newarrayName = strUrlName.split("$");
                 var newarrayID = strID.split("$");
                 var newarrayImage = strImageURL.split("$");
                 var newarrayIFrameCompat = strIframeCompat.split("$");
                 var browserName = navigator.appName;
                 if (browserName == 'Netscape')
                     he = he - 47;
                 else
                     he = he - 57;
                 for (var i = 0; i < newarray.length - 1; i++) {
                     extender.add({
                         html: '<iframe height="100%" scrolling="auto" width="100%" frameborder="0" src="SocialPageSettings.aspx?ShowButton=true&PageHeight=' + he + '&SocialPageName=' + newarray[i] + '&SocialServiceId=' + newarrayID[i] + '&SocialServiceURL=' + newarrayName[i] + '&GizaEntityID=' + GizaEntityID + '&IframeCompat=' + newarrayIFrameCompat[i] + '"/>',
                         title: '<img style="width:16px;h eight:16px; padding-left:0px;padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="http://www.gizapage.com/icons' + '\\' + newarrayImage[i] + '"/>' + ' ' + newarrayName[i],
                         //title: '<img style="width:16px;h eight:16px; padding-left:0px;padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="icons'+'\\'+newarrayImage[i]+'"/>'+ ' '+ newarrayName[i],
                         id: newarrayID[i],
                         closable: true,
                         iconCls: 'tabs',
                         autoScroll: false,
                         border: false
                     })
                 }
                 extender.add({
                     contentEl: 'divPlus',
                     title: '<img style="width:16px;height:16px; padding-left:0px; padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="http://images.gizapage.com/Images/Add.gif" />&nbsp; Pin profile',
                     //title: '<img style="width:16px;height:16px; padding-left:0px; padding-bottom:3px; horizontal-align:left;vertical-align:top;"  src="Images/Add.gif" />&nbsp; Pin profile',

                     id: 'divPlusShow',
                     iconCls: 'tabs',
                     closable: false,
                     autoScroll: false,
                     border: false
                 })
               
                 extender.activate('divPlusShow');
                 extender.activate('MyProfile');
             }
            
         }
         //Loading a particular tab
         function setActiveTabByTitle(tabID) {
             var extender = Ext.getCmp("tabpanelProfileview"); //get a reference to the extender
             var tabs = extender.find('id', tabID);
             extender.setActiveTab(tabs[0]);
         }
         function HideTab(tabID) {
             var extender = Ext.getCmp("tabpanelProfileview");
             var tabs = extender.find('id', tabID);
             extender.remove(tabs[0], true);
         }

         function ShowTab(tabID) {

             var extender = Ext.getCmp("tabpanelProfileview");
             extender.activate(tabID);

         }
		 
		 
		function ViewGizaSite(GizaEntityID, tab_title, GizaPageAdress) {

        if (frames.parent.Ext != null) {
              var thisPage = this;
              var tab_id = 'tab' + GizaEntityID;
              var showInviteButton = "true";
              if (tab_title == "") {
                  tab_title = 'Profile';
              }
              if (thisPage.frames.parent.Ext.getCmp("Tabs") != null) {
                  var extender = thisPage.frames.parent.Ext.getCmp("Tabs");
              }              
              else if(thisPage.frames.parent.parent.Ext.getCmp("Tabs")!=null) {
                  var extender = thisPage.frames.parent.parent.Ext.getCmp("Tabs");
              }
              if (extender != null) {
                  var tab = extender.getItem(tab_id);
                  if (tab) {
                      extender.setActiveTab(tab);
                      tab.body.dom.innerHTML = '<iframe height="100%"  frameborder="0"  scrolling="auto" width="100%" src="newprofile.aspx?GizaEntityID=' + GizaEntityID + '&SecuritySetting = "PUBLIC"/>';
                  }
                  else {
                      //get a reference to the extender
                      extender.add({
                          title: tab_title,
                          iconCls: 'tabs', // tab icon from css class tabs (mainstyle.css)
                          html: '<iframe height="100%" scrolling="auto"  frameborder="0"  width="100%" src="newprofile.aspx?GizaEntityID=' + GizaEntityID + '"/>',
                          closable: true
                      }).show();
                  }
              }
              else {
                  window.open('http://' + GizaPageAdress);
              }
          }
          else {

              window.open('http://' + GizaPageAdress);
          }
      }
