/* FUNCTIONS */

/* Calculate Scrolling from top */   
    function getScrollTop()
	{
		var scTop = 0;
		if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			// DOM
			scTop = document.body.scrollTop;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			// IE6
			scTop = document.documentElement.scrollTop;
		}
		
		return scTop;
	}
/* end Calculate Scrolling from top */ 	
	
/* Show any Hide element */	
function show(id){
	$(id).show();
	}
/* end Show any Hide element */		

/* Hide any element by its id */	
function hide(id){
	
	$(id).hide();
	}		
/* end Hide any element by its id */		
	
	
function moveQickLogin(){
   $(".quickLogin").css({ top:moveTop, left:moveLeft });
   var docH = $(document).height();
   var winH = $(window).height();
   var docW = $("body").width();
    
   var moveTop = getScrollTop()+ (winH-180)/2;
   var moveLeft = (docW-300)/2;
   $(".blackBg").css({ width:docW, height:docH });
   $(".quickLogin").css({ top:moveTop, left:moveLeft });
}	

function moveActionLightBox(){
   $(".lightBoxAction").css({ top:moveTop, left:moveLeft });
   var docH = $(document).height();
   var winH = $(window).height();
   var docW = $("body").width();
    
  // var moveTop = + (winH-500)/2;
   //var moveLeft = (docW - 300) / 2;
   var moveTop = (parseInt(winH) - parseInt(contH)) / 2 ;
   var moveLeft = (parseInt(docW) - parseInt(contW)) / 2;
   $(".blackBg2").css({ width:docW, height:docH });
   $(".lightBoxAction").css({ top:moveTop, left:moveLeft });
}

/* Quick Login */ 
function showQickLogin(referringURL)
{
    $(document).ready(function(){
        var LoadingImageURL = "/im/j3/site/indicator.gif";
        moveQickLogin();        
        $(".blackBg").css({ display:'block' });
        $(".quickLogin").css({ display:'block' });        
        
        var doc = j$Obj("iframeLogin").contentDocument;
        if (doc == undefined || doc == null)
            doc = j$Obj("iframeLogin").contentWindow.document;
        doc.open();
        doc.write("<div style='text-align:center'><img src='" + LoadingImageURL + "'></div>");
        doc.close();                    
        j$Obj("iframeLogin").src = LightBoxLoginPageURL + "&ReferringURL=" + escape(referringURL);
    })

   
}
/* End Quick Login */ 

function CloseLighBox() {
   
   parent.j$Obj("quickLogin").style.display='none';
   parent.j$Obj("blackBg").style.display='none';
   parent.j$Obj("blackBg2").style.display='none';
   parent.j$Obj("lightBoxAction").style.display = 'none';
   
   

}

/* Action Light Box */
function ShowActionLightBox() {
    var j;
    var query = '';
    var arg = '';
    var docH = $(document).height();
    var winH = $(window).height();
    var docW = $("body").width();
    var scrollTop = 0;

    for (j = 0; j < arguments.length; j++) {
        var args = arguments[j].split("||=||");
        query += '&' + args[0] + "=" + escape(args[1]);
    }

    var data = "";
    $(document).ready(function() {
        var LoadingImageURL = "/im/j3/site/indicator.gif";


        $(".blackBg2").css({ display:'block' });
        //$(".blackBg2").css('opacity','0.7');
        parent.j$Obj("blackBg2").style.display = 'block'; // Display the Black Background

        if (typeof document.body.style.maxHeight == "undefined") {
            scrollTop = getScrollTop(); 										// IF IE6 ADD ScrollTop Value and Disable the Scroll 
            $("html").css({ overflow: 'hidden' });

        }


        $("#lightBoxAction").css({ width: containerWidth });
        $("#lightBoxAction").css({ height: containerHeight });
        $("#iframeLightBox").css({ width: iframeWidth });
        $("#iframeLightBox").css({ height: iframeHeight });
        $("#lightBoxContainer").css({ width: iframeWidth });

        data = LightBoxPageURL + query;
        j$Obj("iframeLightBox").src = data;




        var moveTop = (parseInt(winH) - parseInt(containerHeight)) / 2 + scrollTop;
        var moveLeft = (parseInt(docW) - parseInt(containerWidth)) / 2;

        $(".blackBg2").css({ width: docW, height: docH });
        $(".lightBoxAction").css({ top: moveTop, left: moveLeft });



        $("#lightBoxAction").css({ display: 'block' });




        
        document.getElementById('iframeLightBox').style.display = 'none';
        document.getElementById('lightBoxLoading').style.display = 'block';
    })
}

/* End Action Light Box*/



function SearchQueryKeyPress(e,ControlID,DefaultSearchQuery, Filter, IsFilterEnabled,ResultsUrl)
{
    var oEvent = window.event ? window.event : e;
    var isDOM = (document.getElementById ? true : false);
    var isNS4 = (document.layers ? true : false);

    if (document.all != 'undefined') key = oEvent.keyCode;
    else if (isDOM) key = oEvent.charCode;
    else if (isNS4) key = oEvent.which;

    if (key == 13)
    {        
        ShowSearchResults(ControlID,DefaultSearchQuery, Filter,IsFilterEnabled,ResultsUrl);
        oEvent.cancelBubble = true;
        return false;
    }
    else
    { 
        return true; 
    }
}

function ShowSearchResults(ControlID,DefaultSearchQuery, Filter, IsFilterEnabled,ResultsUrl)
{
    var filterValue = '';

    if((Filter == null) || (Filter == ''))
    {
        filterValue = "all";
    }
    else
    {
       filterValue = Filter;
    }
    
    var elValue = document.getElementById(ControlID).value;
    
    // STRIP HTML AND JS TAGS - OMAR B
    var re= /<\S[^><]*>/g;
    for (i=0; i<elValue.length; i++)
    {
        elValue=elValue.replace(re,"");
    }    
    
    if(elValue != "" && elValue != null && elValue != DefaultSearchQuery)
    {
        if(IsFilterEnabled == true)
        {
            elValue = elValue + "&filter=" + filterValue;
        }
        
        window.location = ResultsUrl.replace("||TAG||", elValue);
    }
    else
    {
        switch(filterValue)
        {
            case 'blogs':
                document.getElementById('lnkBlogs').className = "sort_selected";
                
                document.getElementById('lnkPhotos').className = "";
                document.getElementById('lnkVideos').className = "";
                document.getElementById('lnkAll').className = "";
            break;
            
            case 'photos':
                document.getElementById('lnkPhotos').className = "sort_selected";
                
                document.getElementById('lnkBlogs').className = "";
                document.getElementById('lnkVideos').className = "";
                document.getElementById('lnkAll').className = "";
            break;
            
            case 'videos':
                document.getElementById('lnkVideos').className = "sort_selected";
                
                document.getElementById('lnkPhotos').className = "";
                document.getElementById('lnkBlogs').className = "";
                document.getElementById('lnkAll').className = "";
            break;
            
            default:
                document.getElementById('lnkAll').className = "sort_selected";
                
                document.getElementById('lnkPhotos').className = "";
                document.getElementById('lnkVideos').className = "";
                document.getElementById('lnkBlogs').className = "";
            break;
        }
    }
}

/******************************************************************
    CHECK DROPDOWNLIST MONTH 
*******************************************************************/
    
function CheckDay()
{
    var DayForm=document.getElementById(DayFormID);
    var theMonth=document.getElementById(MonthFormID).value;
    var theYear=document.getElementById(YearFormID).value;
    var DayValue=Number(DayForm.value);
    
    switch(theMonth)
    {
        case "2":
        if(DayValue>28)
        {
            if(theYear==0)
            {
                DayForm.value="29";
            }
            else
            {
                if(IsLeapYear(theYear))
                {
                    DayForm.value="29";
                }
                else
                {
                    DayForm.value="28";
                }
            }
         }
        break;
        case "4":
        case "6":
        case "9":
        case "11":
            if(DayValue>30)
            {
                DayForm.value="30";
            }
            break;
        }
    }

function IsLeapYear(Year)
{
    if( (Year%4) == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}


/***************************************************************
************************* END FUNCTIONS ************************
***************************************************************/
 
 $(document).ready(function(){
   
	$(window).scroll(function(){
							  if($(".quickLogin").css("display")!="none")
							  	{
                                    moveQickLogin();							  		
								}
//								
//							  if($(".lightBoxAction").css("display")!="none")
//							  	{
//                                    moveActionLightBox();							  		
//								}
//								
							  });
//	
	// close Qucik login
	$(".xbase img").click(function(){
                                    parent.j$Obj("quickLogin").style.display='none';
                                    parent.j$Obj("blackBg").style.display='none';
                                    parent.j$Obj("blackBg2").style.display='none';
                                    parent.j$Obj("lightBoxAction").style.display = 'none';
                                                                     
                                    $("html").css({ overflowY:'auto'});
                                    
								   //$(".quickLogin").hide();
								   //$(".blackBg").hide();
                                });
       $(".blackBg2").click(function(){
                                    parent.j$Obj("quickLogin").style.display='none';
                                    parent.j$Obj("blackBg").style.display='none';
                                    parent.j$Obj("blackBg2").style.display='none';
                                    parent.j$Obj("lightBoxAction").style.display = 'none';
                                                                     
                                    $("html").css({ overflowY:'auto'});
                                    
								   //$(".quickLogin").hide();
								   //$(".blackBg").hide();
                                });
       $(".blackBg").click(function() {
                                    parent.j$Obj("quickLogin").style.display = 'none';
                                    parent.j$Obj("blackBg").style.display = 'none';
                                    parent.j$Obj("blackBg2").style.display = 'none';
                                    parent.j$Obj("lightBoxAction").style.display = 'none';

                                    $("html").css({ overflowY: 'auto' });

                                    //$(".quickLogin").hide();
                                    //$(".blackBg").hide();
    });							   

	// Setting Menu
	$("#Settings .settingItem").hover(
	    function(){
	        $(this).css("background","none");
	    },
	    function(){
	        $(this).css("background","#90B557");
	    }
	    
	    );
	
								   
/* input text initial text */
   $("input[type=text]:not(.notwater),input[type=password],textarea:not(.notwater)").focus(function(){
										 
				
			 if (this.value == this.defaultValue){  
             this.value = '';  
         }  
			$(this).css({color:"#000"})
			
							 });
   
   $("input[type=text]:not(.notwater),input[type=password],textarea:not(.notwater)").blur(function(){
										 
			
				 if (this.value == ""){  
                this.value = this.defaultValue; 
			 }
			$(this).css({color:"#777"}) 
			
			
							 });
   
 /* end input text initial text */ 
 
 

 
 });
 
 
//jal.js
// JScript File

/// THE FUNCTION THAT GETS DATA USING AJAX - requires ShowDiv() & HideDiv()  - OMAR AA - V[1.0.8] - 4/8/2007 11:13:32 AM -
function funcGetAjaxData(AjaxURL, DataDivName, LoadingDivName, UseLoadingDiv, ErrorMsg)
{
    var ObjAJAX = new JeeranRemoteScripting();
	ObjAJAX.SetRequestMethod("GET");
	ObjAJAX.SetRequestURL(AjaxURL);
	ObjAJAX.SetData("");
	ObjAJAX.SetRequestAsynch(true);
    ObjAJAX.InitializeRequester();
    if (UseLoadingDiv == 'true')
       { ShowDiv(LoadingDivName); }
	ObjAJAX.SendRequest();
	//waiting?

	ObjAJAX.OnLoaded = function() {
        if (UseLoadingDiv == 'true')
           { HideDiv(LoadingDivName); }
	    document.getElementById(DataDivName).innerHTML = ObjAJAX.GetText();
	    ObjAJAX = null;
	}
	ObjAJAX.OnFailure = function() {
	    if (UseLoadingDiv == 'true')
	       { HideDiv(LoadingDivName); }
	    document.getElementById(DataDivName).innerHTML = ErrorMsg;
	    ObjAJAX = null;   
	}
}

///  FILL DATA FROM AJAX TO BOXES   - OMAR AA - V[1.0.8] - 4/25/2007 5:35:55 PM -
function FillDataForBoxes(AjaxURL, DivToFill, DivLoading, qsType)
{
    if (document.getElementById(DivToFill).innerHTML == "")
    {
        funcGetAjaxData(AjaxURL + '&type=' + qsType, DivToFill, DivLoading, 'true', 'request failed');
    }
}

function LoadAjaxInBox(BoxID, RequestURL, RequestMethod, RequestData, LoadingText, AllowRefresh)
{
    var AjaxRequest;
    var AllowLoad;
    var ErrorMsg;

    
    // Check if we want to allow this request t ogo through 
    if (AllowRefresh == false) {

       
        if (trim(document.getElementById(BoxID).innerHTML) == "")
        {
            AllowLoad = true;
        }
        else {
            AllowLoad = false;
        }
    }
    else {
        AllowLoad = true;
    }

    
    if(AllowLoad == true)
    {
        // Set the text in the loading message
        if (LoadingText == "")
        {
            LoadingText = "Loading...";
        }
        
        //  
        if (RequestMethod.toLowerCase() == "get")
        {
            RequestURL += "&" + RequestData;
        }

        AjaxRequest = CreateAjaxRequest(RequestURL, RequestMethod, RequestData);
        
        SetTextOfLayer(BoxID, "<div style='position: relative; top:40px; margin: auto; height:31px; width:150px; line-height:31px; font-size: 10px;'><img src='/im/j2/ajax/loading.gif' style='height: auto; width: auto; border:0; padding:0;' />&nbsp;" + LoadingText + "</div>");

        AjaxRequest.OnLoaded = function() {
            var ResponseText = AjaxRequest.GetText();
            /// THIS IS A FIX FOR IE6 - IE6 DOESN'T ALLOW <form> TO BE ADDED USING innerHTML
            /// SO WE REPLACE IT WITH DIV
            ResponseText = ResponseText.replace("form ", "div ")
            
            SetTextOfLayer(BoxID, ResponseText);
            AjaxRequest = null;
        }

        AjaxRequest.OnFailure = function() {
            ErrorMsg = "Load failed. Please try again!";
            
            SetTextOfLayer(BoxID, ErrorMsg);
            AjaxRequest = null;
        }    
    }    
}

//jJsFw.js
/*
 Name: Jeeran's JS Framework;
 Built by: Fouad Masoud;
 Date: 22-09-2007
*/ 


/* =Add Load Event Function
	How to use:
		ex. addLoadEvent(functionName);
----------------------------------------------------- */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

/* =Get Elemets By Class Name Function 
	How to use:
		ex. getElementsByClassName(document,"TagName","className");
----------------------------------------------------- */
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

/* =Prepare Tabs
	How to use:
		1- In the markup assign the class sectionTabs to any ul or ol.
	Tips:
		1- The Li elements must have A element inside them and only A elements.
		2- For this Script to work in the right way; two classes have to be added to the css that controls the page
		   .sectionTabs and .selected and handled there.
	Notes: This function works well, but needs some enhancement;
	Built: FM 22-09-2007
----------------------------------------------------- */
function changeTab(elem){
  
	var tabsContainer = elem.parentNode.parentNode;
	var classNm = tabsContainer.className;
	
	if (!classNm.match("sectionTabs")){
	    tabsContainer = elem.parentNode.parentNode.parentNode;
	}
	
	var links = tabsContainer.getElementsByTagName("li");
	for(i=0; i<links.length; i++){
		links[i].className = "";
	}
	elem.parentNode.className = "selected";

	var panels = tabsContainer.getElementsByTagName("a");
	for(i=0; i<panels.length; i++){
	    panelID=panels[i].getAttribute("href").split("#")[1];
	    document.getElementById(panelID).style.display = "none";
	}
	
	panelID = elem.getAttribute("href").split("#")[1];
	document.getElementById(panelID).style.display = "block"; 
}

/* =Simple Show Hide Function
	How to use:
		1- Use it with onclick, just place the function name "showHide" and the name of the element that you wish 
		   for the affect to be applied on. ex. onclick = "toggle("Banner");"
	TODO: Fix the onclick issue; it shouldnt be used in the markup
	Built: FM 24-09-2007
----------------------------------------------------- */
function toggle(obj) {
	var el = j$Obj(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = 'block';
	}
	return false;
}

/*
This toggles between the two given image urls.
*/
function toggleImage(ImageID, Image1, Image2)
{
    var Image = j$Obj(ImageID);
    if (Image.src == Image1)
    {
        Image.src = Image2;
    }
    else
    {
        Image.src = Image1;
    }
}

/* =Creat A popup
    How to use:
		1- just add the class popup to any link that u want to open as a popup, juat keep in-mind that the 
		url of the link should be the same url that will be loaded in the popup.
	TODO: Fixs the function to accept height and width parameters.
	Built: FM 24-09-2007
----------------------------------------------------- */
function popup() {
	if (!getElementsByClassName(document,"a","popup")) return false;
  	var links = getElementsByClassName(document,"a","popup");
  	for (var i=0; i<links.length; i++) {
    	links[i].onclick = function() {
			window.open(this.getAttribute("href"),"popup","width=320,height=480");
        	return false;
    	}
  	}
}
addLoadEvent(popup);

/* =Prepare Navigation
	Built: FM 30-09-2007
----------------------------------------------------- */
function showDropdown(elem){
    tm(elem);
}
function hasC(e,c) {
	return (e.className && e.className.indexOf(c)>-1);
};

function addC(e,c) {
	if (!hasC(e,c)){
		if (e.className) e.className += " " + c;
		else e.className = c;
	}
};

function remC(e,c) {
	if (hasC(e,c)) {
		var r = new RegExp("(^|\\s)" + c + "(\\s|$)");
		e.className = e.className.replace(r, "$2");
	}
};
function tm(el) 
{
    var p=el.parentNode;
    var d=document;
    function cl() {remC(p,'selected');d.onclick=null;}
    function sh() {d.onclick=cl;}
    if(hasC(p,'selected')) cl();
    else{
        addC(p,'selected');
        setTimeout(sh, 0);
        try {
            var u=(p.getElementsByTagName("UL")[1]), c=u.childNodes, w=u.clientWidth, e=u, x=0;  
        }
        catch (ig){}
    }
    return false;
}

/* =This will copy/move page elements between the source and target divs
    to move, set KeepOriginal = false, otherwise KeepOriginal = true
    Built by: Laith
    Moved by: FM
----------------------------------------------------- */    
function ThrowObjectInDiv(Object, SourceID, TargetID, KeepOriginal)
{
    var TargetDiv = j$Obj(TargetID);
    var SourceDiv = j$Obj(SourceID);   
  
    // If we want to keep the original, we need to make a copy of the object
    // Otherwise we just append the object itself to the new node and it will move.
    if(KeepOriginal)
    {
        var NewObject = Object.cloneNode(true);
        NewObject.id = Object.id + '-copy';
        TargetDiv.appendChild(NewObject);
    }
    else
    {
        var targetDivContent = TargetDiv.innerHTML;
        TargetDiv.innerHTML = "";
        TargetDiv.appendChild(Object);
        TargetDiv.innerHTML += targetDivContent;
    }
}


var TimeToFade = 1000.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
    
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null || element.style.opacity == '' 
       || element.style.opacity == '1')
      element.FadeState = 2;
    else
      element.FadeState = -2;
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}

function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
	element.style.display = 'none';
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
  
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}

function changeTabs(elemId1,elemId2)
{
  var panel1 = $("#"+ elemId1).attr('href');
  var panel2 =  $("#"+ elemId2).attr('href');
  
    $("#"+ elemId2).removeClass("selected");
    $("#"+ elemId1).addClass("selected");
    

    show(panel1);
    hide(panel2);


}

//jLists.js
// This method will take an xml tree and append the designated values from
// the tree to an existing ordered or un-ordered html list
// -Laith
function PopulateItemList(ListID, ItemsXml, XmlNodeName, ItemOnClick, ItemOnMouseDown, ResetList, ItemCss)
{
    var ItemText;
    var ListItems = ItemsXml.getElementsByTagName(XmlNodeName);
    
    // if we want to reset the list, we delete all its items
    if (ResetList)
    {
        PurgeItemList(ListID);        
    }
    
    for(var i=0; i<ListItems.length; i++) 
     {     
        ItemText = ListItems[i].childNodes[0].nodeValue;
        AppendListItem(ListID, ItemText, "", ItemOnClick, ItemOnMouseDown, ItemCss);
        
     }
     
     //j$Obj("tempinp").innerText = j$Obj(ListID).innerHTML;
     
}

// This method will append a singe list item to an existing html
// ordered or un-ordered html list
// -Laith
function AppendListItem(ListID, ListItemText, ListItemID, ListItemOnClick, ItemOnMouseDown, ListItemCssClass)
{
    //ul element that contains the bullet items
    var ul = j$Obj(ListID);        
    var el = null; 

    el = document.createElement("li");
    
    // if theres an onclick or on mousedown event, we need to use a link
    if(ListItemOnClick != "" || ItemOnMouseDown != "")
    {

        
        el.innerHTML = "<div style='width: 100%;' onclick='"+ListItemOnClick+"' onmousedown='"+ItemOnMouseDown+"'>"+ListItemText+"</div>";
        //el.innerHTML = ListItemText;
        //el.onclick = "javascript:alert('sdssdsd');";
    }
    else 
    {
        el.innerHTML = ListItemText;
    }
    
    if(ListItemCssClass != "")
    {
        el.className = ListItemCssClass;
    }    
    
    
    //el.appendChild(al);
    //el.attributes.add = "function{alert('sdssdsd');}";
    ul.appendChild(el);
    

}

function PurgeItemList(ListID)
{
    var oul = j$Obj(ListID);
    var ouli = oul.getElementsByTagName("li");
    
    for(var i=0; i<ouli.length; i++) 
    {
       oul.removeChild(ouli[0]);
    }
}

//jll.js
///   GENERIC HIDE DIV  - OMAR AA - V[1.0.8] - 4/8/2007 11:12:49 AM -
function HideDiv(DivName) 
{
    j$Obj(DivName).style.visibility = "hidden";
    j$Obj(DivName).style.display = "none";
}

///   GENERIC SHOW DIV  - OMAR AA - V[1.0.8] - 4/8/2007 11:12:54 AM -
function ShowDiv(DivName) 
{
    j$Obj(DivName).style.visibility = "visible";
    j$Obj(DivName).style.display = "block";
}

//method that shows the div if it is hidden and hide it if it visible --SARA AA 21/5/2007
function DisplayDiv(divName)
{
    if (j$Obj(divName).style.display == 'none')
    {
      ShowDiv(divName);
    }
    else 
    { 
      HideDiv(divName);
    }
}

///  MOVE CONTENT OF A DIV TO ANOTHER   - OMAR AA - V[1.0.8] - 4/24/2007 11:32:56 AM -
function MoveDivContent(From, To)
{
    j$Obj(To).innerHTML = j$Obj(From).innerHTML;
    j$Obj(From).innerHTML = "";
}

/// Sets the contents of any div or span tag
function SetTextOfLayer(LayerID, Contents)
{  
    j$Obj(LayerID).innerHTML = Contents;  
}

/// Sets the value of any input tag
function SetInputValue(InputID, InputValue)
{
   j$Obj(InputID).value = InputValue;
}

function ShowLightBox(referringURL)
{
    var lightBoxHeight = document.body.offsetHeight;    
    j$Obj("lightBox").style.height = lightBoxHeight +'px';
    
    ShowDiv('lightBox');
    ShowDiv('loginBox');
    
    var doc = j$Obj("iframeLogin").contentDocument;
    if (doc == undefined || doc == null)
        doc = j$Obj("iframeLogin").contentWindow.document;
    doc.open();
    doc.write("<div style='text-align:center'><img src='" + LoadingImageURL + "'></div>");
    doc.close();            
    
    j$Obj("iframeLogin").src = LightBoxLoginPageURL + "&ReferringURL=" + referringURL;
    changeOpac(75,'lightBox');
}

function HideLightBox()
{
    HideDiv('lightBox');
    HideDiv('loginBox');
}    

function changeOpac(opacity, id) { 
    var object = j$Obj(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}


//js.js

function j$Obj(ObjectID){
    return document.getElementById(ObjectID);
}

function j$SetCssClass(Object, ClassName, AutoOff)
{
    var CurrentClassName;
    var Obj;
    
    try {
        CurrentClassName = Object.className;
        Obj = Object;
    }
    catch (error)
    {
        Obj = j$Obj(Object)
        CurrentClassName = j$Obj(Object).className;        
    }    
 
    if (AutoOff)
    {
        if (CurrentClassName.indexOf(ClassName) > -1)
        {
            Obj.className = Obj.className.replace(ClassName, "");
        }
        else
        {
            Obj.className = Obj.className + " " + ClassName;
        }        
    }
    else
    {
        Obj.className = Obj.className + " " + ClassName;
    } 
}

function openBrWindow(theURL,winName,features) { //v2.0
  var win;
  win = window.open(theURL,winName,features);
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    return newstr;
}

function IsEmail(email) {
    return/^[\w!.%+]+@[\w]+(?:\.[\w]+)+$/.test(email);
}

// Auto generated from DW
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 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;
}

//jTabbing.js
// JScript File

//  Shows / Hide Tabs of quantity 2
    function ShowDoubleTabs(PanelName,DivID,Tab1,Tab2,Div1,Div2)
    {
        //  Unselect the Tabs
	    document.getElementById(Tab1).className = "jUnSelectedTab";
        document.getElementById(Tab2).className = "jUnSelectedTab";
        
        //  Unselect the Divs
        document.getElementById(Div1).style.display = "none"; 
        document.getElementById(Div2).style.display = "none"; 
        
        //  Selected the click panel and its corresponding Div
	    document.getElementById(PanelName).className = "jSelectedTab";
	    document.getElementById(DivID).style.display = "block";
	    document.getElementById(DivID).style.visibility = "visible";
    }
    
    //  Shows / Hide Tabs of quantity 3
    function ShowTrippleTabs(PanelName,DivID,Tab1,Tab2,Tab3,Div1,Div2,Div3)
    {
         //  Unselect the Tabs
	    document.getElementById(Tab1).className = "jUnSelectedTab";
        document.getElementById(Tab2).className = "jUnSelectedTab";
	    document.getElementById(Tab3).className = "jUnSelectedTab";
	    
        //  Unselect the Divs
        document.getElementById(Div1).style.display = "none"; 
        document.getElementById(Div2).style.display = "none"; 
        document.getElementById(Div3).style.display = "none"; 
        
        //  Selected the click panel and its corresponding Div    
	    document.getElementById(PanelName).className = "jSelectedTab";
	    document.getElementById(DivID).style.display = "block"; 
	    document.getElementById(DivID).style.visibility = "visible";
    }

//NewsFeeds.js
var NfAjaxRequest;

/* =Select NewsFeed
	Built: FM 07-02-2008
----------------------------------------------------- */
function selectNewsFeed(elem, exception){
    
    var holder = elem.parentNode;
    var img = holder.getElementsByTagName("img");
    var checkBox = holder.getElementsByTagName("input");
    
    if (!exception){
        if (checkBox[0].checked == true){
            img[1].style.display = "block";
            img[0].style.display = "none";
        }
        else{
            img[1].style.display = "none";
            img[0].style.display = "block";
        }
    }
    else{
        if (checkBox[0].checked == true){
            img[1].style.display = "block";
            img[0].style.display = "none";
            
            var related = getElementsByClassName(document,"*","commentsKid");
            
            for (j=0; j<related.length; j++){             
                related[j].parentNode.style.fontWeight = "bold";
                img = related[j].parentNode.getElementsByTagName("img");
                img[1].style.display = "block";
                img[0].style.display = "none";
                j$Obj("nfSubComments").style.display = "block";
            }
        }
        else{
            img[1].style.display = "none";
            img[0].style.display = "block";
            var related = getElementsByClassName(document,"*","commentsKid");
            for (j=0; j<related.length; j++){
                related[j].parentNode.style.fontWeight = "normal";
                img = related[j].parentNode.getElementsByTagName("img");
                img[1].style.display = "none";
                img[0].style.display = "block";
                j$Obj("nfSubComments").style.display = "none";
            }
        }
    }
}

//This function is used to expand/hide the "NewsList" in the "News Feeds Summary Box" -MAISQ-     
function ShowHidePanel(ButtonID,PanelID)
{
    var ThePanel = document.getElementById(PanelID);
    var ButtonID = document.getElementById(ButtonID); 
    
//    
//    if(ButtonID.innerHTML=="Show me +")
//    {
//        ButtonID.innerHTML="Show me -";
//        ShowDiv(PanelID);
//    }
//    else
//    {
//       ButtonID.innerHTML="Show me +";
//       HideDiv(PanelID);
//    }      
//    
    if(ThePanel.style.display == 'block')
    {
       //ButtonID.innerHTML= ShowMeText + " +";
       ThePanel.style.display="none";
       //HideDiv(PanelID);     
    }
    else
    {
        //ButtonID.innerHTML= ShowMeText+ " -";
        ThePanel.style.display="block";
//        ShowDiv(PanelID);   
    }
    
}

//This function is used to check/uncheck the "Comments" checkboxes in the "News Feeds Summary Box" - MAISQ - 
function SelectComments()
{ 
    var CommentsID =document.getElementById(Comments);
    var ProfileCommentsID = document.getElementById(ProfileComments); 
    var PhotosCommentsID = document.getElementById(PhotosComments);
    var PostCommentID = document.getElementById(PostsComments);
    var VideoCommentID = document.getElementById(VideoComments);
    
    if ( CommentsID.checked == '')
    {
        //If the main check box "Comments" is unchecked then the sub checkboxes should be unchecked - MAISQ -
        ProfileCommentsID.checked = '';
        PhotosCommentsID.checked = '';
        PostCommentID.checked = '';
        VideoCommentID.checked = '';
    }
    else 
    {
        //If the main check box "Comments" is checked then the sub checkboxes should be checked - MAISQ -
        ProfileCommentsID.checked = true;
        PhotosCommentsID.checked = true;
        PostCommentID.checked = true;
        VideoCommentID.checked = true;
    }
     
    if((CommentsID.checked == true) &&( (ProfileCommentsID.checked == true) ||( PhotosCommentsID.checked == true) ||(PostCommentID.checked ==true) && (VideoCommentID.checked ==true)))
    {   
        CommentsID.checked = true;
        ProfileCommentsID.checked = true;
        PhotosCommentsID.checked = true;
        PostCommentID.checked = true;
        VideoCommentID.checked = true;
    }    
 }
 
 //This functions is concerned with the "Comments" sub-checkboxes behaviour in the "News Feeds Summary Box" -MAISQ- 
 function CommentsSubCheckBoxes()
 {
    var CommentsID =document.getElementById(Comments);
    var ProfileCommentsID = document.getElementById(ProfileComments); 
    var PhotosCommentsID = document.getElementById(PhotosComments);
    var PostCommentID = document.getElementById(PostsComments);
    var VideoCommentID = document.getElementById(VideoComments);
    
    var img = j$Obj('nfComments').getElementsByTagName("img");
          
    if((((ProfileCommentsID != null))&&(ProfileCommentsID.checked == 'checked')) || ((PhotosCommentsID != null)&&(PhotosCommentsID.checked == 'checked')) || ((PostCommentID != null)&&(PostCommentID.checked == 'checked'))|| ((VideoCommentID != null)&&(VideoCommentID.checked == 'checked')))
    {
        //If all sub checkboxes are checked, then the main "Comments" checkbox should be selected - MAISQ- 
        CommentsID.checked = 'checked';
        
        j$Obj('nfComments').className = "nfSelected";
        img[1].style.display = "block";
        img[0].style.display = "none";
    }

    if (((ProfileCommentsID != null)&&(ProfileCommentsID.checked == '')) && ((PhotosCommentsID != null)&&(PhotosCommentsID.checked == '')) && ((PostCommentID != null)&&(PostCommentID.checked == '')) && ((VideoCommentID != null)&&(VideoCommentID.checked == '')))
    { 
        //If all sub checkboxes are unchecked, then the main "comments" should be unchecked -  MAISQ - 
        CommentsID.checked = '';
        
        j$Obj('nfComments').className = "";
        img[1].style.display = "none";
        img[0].style.display = "block";
        
        j$Obj("nfSubComments").style.display = "none";
    }
    else
    {
        //If some Checkboxes are checked then check the main "Comments" checkbox  - MAISQ - 
        CommentsID.checked = 'checked';
        
        j$Obj('nfComments').className = "nfSelected";
        img[1].style.display = "block";
        img[0].style.display = "none";
    }
}

//Calls an Ajax page that gets the events according to the display settings provided. - MAISQ -
function CallAjaxPage(QueryString, divName) 
{
    //var DivName = "nfSummaryCustomControl";
    // var DivName = document.getElementById(divName);
    
    //Call the AJAX page - MAISQ -
    //LoadAjaxInBox(DivName, PageURL,'POST', QueryString, nfLoadingText, true);
    try
        { 
        NfAjaxRequest.Close();
        }
    catch(error)
    {
    
    }
    NfAjaxRequest = CreateAjaxRequest(PageURL , 'POST', QueryString);
        
    SetTextOfLayer(divName, "<div style='margin:60px auto; height:31px; width:150px; line-height:31px; font-size: 10px;'><img src='/im/j2/ajax/loading.gif' style='height: auto; width: auto; border:0; padding:0;' />&nbsp;" + nfLoadingText + "</div>");
    
//     try
//        { 
        NfAjaxRequest.OnLoaded = function(){
       
            SetTextOfLayer(divName, NfAjaxRequest.GetText());
            NfAjaxRequest = null;
        }
//        }
//     catch(error)
//       {
//       }

//    try
//        {  
    NfAjaxRequest.OnFailure = function() {
    
        ErrorMsg = "Load failed. Please try again!";
        SetTextOfLayer(divName, ErrorMsg);
        NfAjaxRequest = null;   
        }
//    }
//    catch(error)
//    {
//    }
}


//// NEWS FEEDS PRIVACY SETTINGS PAGE.


//function ShowHidePanel(ButtonID,PannelID)
//{
//    var ThePannel = document.getElementById(PannelID);
//    var ButtonID = document.getElementById(ButtonID); 
//    
//    if(ButtonID.innerHTML=="Show me +")
//    {
//        ButtonID.innerHTML="Show me -";
//        ShowDiv(PannelID);
//    }
//    else
//    {
//       ButtonID.innerHTML="Show me +";
//       HideDiv(PannelID);
//    }      
//}

function DisableButton(ButtonID)
{
    var Btn = document.getElementById(ButtonID);
    Btn.disabled  = true;
}

function EnableButton(ButtonID)
{
    var Btn = document.getElementById(ButtonID);
    Btn.disabled  = false;
}  

//function that enable or disabel allt eh check boxes in the news feeds section of the page --SARA AA AND - MAISQ -- 
function DisableOrEnabelAllCheckboxes() 
{
        
   // var FriendsCheckBx = document.getElementById(formFriendsAdditionsName);
    //var BirthdaysCheckBx = document.getElementById(formBirthdayReminderName);
    
    var PhotosCheckBx = document.getElementById(formPhotosAdditionsName);
    var BlogsCheckBx = document.getElementById(formBlogsUpdatesName);
    var ProfilesCheckBx = document.getElementById(formProfilesUpdatesName);
    var CommentsCheckBx = document.getElementById(formCommentsAdditionsName);
    var ProfileCommentsCheckBx = document.getElementById(formProfileCommentsName); 
    var PhotosCommentsCheckBx = document.getElementById(formPhotosCommentsName);
    var BlogCommentsCheckBx = document.getElementById(formPostsCommentsName);
    var WebsitesCheckBx = document.getElementById(formWebsiteCreationName);
    var StatusCheckBx = document.getElementById(formFriendsStatusName);
    var HideCheckBox= document.getElementById(formHideNewsFeedsName);
    var VideosCheckBx = document.getElementById(VideosName);
    var VideosCommentsCheckBx = document.getElementById(VideoCommentsName);
    
    //If the "Hide" checkbox is selected, all other checkboxes should be disabled. else, all checkboxes are enabled. - MAISQ - 
    if (HideCheckBox.checked == true) 
    {
   
        // FriendsCheckBx.disabled = true;
        //BirthdaysCheckBx.disabled =true;
        PhotosCheckBx.disabled = true;
        PhotosCheckBx.parentNode.disabled = true;
        
        BlogsCheckBx.disabled = true;
        BlogsCheckBx.parentNode.disabled = true;
        
        ProfilesCheckBx.disabled =true;
        ProfilesCheckBx.parentNode.disabled =true;
        
        CommentsCheckBx.disabled = true;
        CommentsCheckBx.parentNode.disabled = true;
        
        ProfileCommentsCheckBx.disabled =true;
        ProfileCommentsCheckBx.parentNode.disabled =true;
        
        PhotosCommentsCheckBx.disabled = true;
        PhotosCommentsCheckBx.parentNode.disabled = true;
        
        BlogCommentsCheckBx.disabled =true;
        BlogCommentsCheckBx.parentNode.disabled =true;
        
        WebsitesCheckBx.disabled =true;
        WebsitesCheckBx.parentNode.disabled =true;
        
        StatusCheckBx.disabled = true;
        StatusCheckBx.parentNode.disabled = true;
        
        VideosCheckBx.disabled = true;
        VideosCheckBx.parentNode.disabled = true;
        
        VideosCommentsCheckBx.disabled = true;
        VideosCommentsCheckBx.parentNode.disabled = true;
        
      
        var i;
        for (i=0; i < document.forms[0].elements.length; i++) 
        {
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dlstBlogs') > -1) )
            {
                document.forms[0].elements[i].disabled = true;
                document.forms[0].elements[i].parentNode.disabled = true;
                
            }
        }
      }
     else
     { 
        //FriendsCheckBx.disabled =false;
        //BirthdaysCheckBx.disabled = false;
        PhotosCheckBx.disabled =false;
        PhotosCheckBx.parentNode.disabled = false;
        
        BlogsCheckBx.disabled =false;
        BlogsCheckBx.parentNode.disabled =false;
        
        ProfilesCheckBx.disabled = false;
        ProfilesCheckBx.parentNode.disabled = false;
        
        CommentsCheckBx.disabled = false;
        CommentsCheckBx.parentNode.disabled = false;
        
        ProfileCommentsCheckBx.disabled = false;
        ProfileCommentsCheckBx.parentNode.disabled = false;
        
        PhotosCommentsCheckBx.disabled = false;
        PhotosCommentsCheckBx.parentNode.disabled = false;
        
        BlogCommentsCheckBx.disabled = false;
        BlogCommentsCheckBx.parentNode.disabled = false;
        
        WebsitesCheckBx.disabled = false;
        WebsitesCheckBx.parentNode.disabled = false;
        
        StatusCheckBx.disabled = false;
        StatusCheckBx.parentNode.disabled = false;
        
        VideosCheckBx.disabled = false;
        VideosCheckBx.parentNode.disabled = false;
        
        VideosCommentsCheckBx.disabled = false;
        VideosCommentsCheckBx.parentNode.disabled = false;
        
        var i;
        for (i=0; i < document.forms[0].elements.length; i++) 
        {
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dlstBlogs') > -1))
            {
                document.forms[0].elements[i].disabled = false;
                document.forms[0].elements[i].parentNode.disabled = false;
            }
        }
    }
}

function SelectDeselectComments()
{ 
    var Comments =document.getElementById(formCommentsAdditionsName);
    var ProfileComments = document.getElementById(formProfileCommentsName); 
    var PhotosComments = document.getElementById(formPhotosCommentsName);
    var PostComment = document.getElementById(formPostsCommentsName);
    var VideosComments = document.getElementById(VideoCommentsName);

    if ( Comments.checked == '')
    {
        //If the main check box "Comments" is unchecked then the sub checkboxes should be unchecked - MAISQ -
        ProfileComments.checked = '';
        PhotosComments.checked = '';
        PostComment.checked = '';
        VideosComments.checked = '';
     }
    else 
    {
        //If the main check box "Comments" is checked then the sub checkboxes should be checked - MAISQ -
        ProfileComments.checked = 'checked';
        PhotosComments.checked = 'checked';
        PostComment.checked = 'checked';
        VideosComments.checked = 'checked';
        Comments.style.backgroundColor='';
    } 
    if((Comments.checked == true) &&( (ProfileComments.checked == 'checked') ||( PhotosComments.checked == 'checked') ||(PostComment.checked == 'checked') || (VideosComments.checked == 'checked')))
    {    Comments.checked='checked';
        ProfileComments.checked = 'checked';
        PhotosComments.checked = 'checked';
        PostComment.checked = 'checked';
        VideosComments.checked = 'checked';
    }    
}

function CommentsCheckBoxes()
{ 
    var Comments =document.getElementById(formCommentsAdditionsName);
    var ProfileComments = document.getElementById(formProfileCommentsName); 
    var PhotosComments = document.getElementById(formPhotosCommentsName);
    var PostComment = document.getElementById(formPostsCommentsName);
    var VideoComments = document.getElementById(VideoCommentsName);

    if((ProfileComments.checked == 'checked') || (PhotosComments.checked == 'checked') || (PostComment.checked == 'checked') || (VideoComments.checked == 'checked'))
    {
      //If all sub checkboxes are checked, then the main "Comments" checkbox should be selected - MAISQ- 
      Comments.checked = 'checked';
       
    }
     if ((ProfileComments.checked == '') && (PhotosComments.checked == '') && (PostComment.checked == '') && (VideoComments.checked == ''))
    { 
        //If all sub checkboxes are unchecked, then the main "comments" should be unchecked -  MAISQ - 
        Comments.checked = '';
    }
      else
    {
        //If some Checkboxes are checked then check the main "Comments" checkbox  - MAISQ - 
        Comments.checked = 'checked';
    }
}

//function to disabel the sub checkboxes in the datalist when the main check box is unchecked 
//and visa versa --SARA AA 6/6/2007 
function DisableSubBlogs()
{
    var Blogs =document.getElementById(formBlogsUpdatesName);
    //var subBlogs=document.getElementById(dtaListBlogs);

    if((Blogs.checked == false) || (Blogs.disabled == true))
    {
      var i;
        for (i=0; i < document.forms[0].elements.length; i++) 
        {
            
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dlstBlogs') > -1))
            {
                document.forms[0].elements[i].disabled = true;
            }
        }
    }
    else 
    {
        var i;
        for (i=0; i < document.forms[0].elements.length; i++) 
        {
            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dlstBlogs') > -1))
            {
                document.forms[0].elements[i].disabled = false;
            }
        }
    }
}

//Deals with the behavior of the blogs checkboxes such that:
//  1) If One sub-checkbox is selected, the main blogs checkbox should be selected.
//  2) If all sub-checkboxes are unchecked , the main blogs checkbox shoud be de-selected.   - MAISQ -
function SelectMainBlogsCheckBox()
{

    var Blogs =document.getElementById(formBlogsUpdatesName);
    
    var i;
    var isSelected = false;
    
    for (i=0; i < document.forms[0].elements.length; i++) 
    {
        if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('dlstBlogs') > -1) && (document.forms[0].elements[i].checked == true))
        {
            //Exist the loop if at least one sub-checkbox is selected.
            isSelected = true;
            break;
        }
    }
    
    if(isSelected)
    {
        Blogs.checked = true;
    }
    else
    {
        Blogs.checked = false;
    }
}

//This function constructs the query string that is to be sent to the AJAX page. - MAISQ -
function ConstructQueryString(Period, divName)
{
    var QueryString = "" ;
   // var FriendsConnectionsID = document.getElementById(FriendsConnections);
    var PhotosID = document.getElementById(Photos);
    var BlogsID = document.getElementById(Blogs);
    var ProfilesID = document.getElementById(Profiles);
    var CommentsID = document.getElementById(Comments);
    var ProfileCommentsID = document.getElementById(ProfileComments);
    var PhotosCommentsID = document.getElementById(PhotosComments);
    var PostsCommentsID = document.getElementById(PostsComments);
    var WebsitesID = document.getElementById(Websites);
    var StatusID = document.getElementById(Status);
    var VideosID = document.getElementById(Videos);
    var VideoCommentID = document.getElementById(VideoComments);

    //Get the state of the checkboxes and put them in a string. - MAISQ -       
//    if( FriendsConnectionsID.checked == true)
//    {
//        QueryString =  "friends=1";
//    }
//    else
//    {
//        QueryString =  "friends=0";
//    }
    
    if( PhotosID.checked == true)
    {
       QueryString +=  "&photos=1";
    }
    else
    {
        QueryString +=  "&photos=0";
    }
    
//    if( BirthdayID.checked == true)
//    {
//       QueryString +=  "&birthday=1";
//    }
//    else
//    {
//        QueryString +=  "&birthday=0";
//    }
    
    if( BlogsID.checked == true)
    {
       QueryString +=  "&blogs=1";
    }
    else
    {
        QueryString +=  "&blogs=0";
    }
    
    if( ProfilesID.checked == true)
    {
       QueryString +=  "&profiles=1";
    }
    else
    {
        QueryString +=  "&profiles=0";
    }
    
    if( ProfileCommentsID.checked == true)
    {
       QueryString +=  "&profilecomments=1";
    }
    else
    {
        QueryString +=  "&profilecomments=0";
    }
    
    if( PhotosCommentsID.checked == true)
    {
       QueryString +=  "&photoscomments=1";
    }   
    else
    {
        QueryString +=  "&photoscomments=0";
    }
    
    if( PostsCommentsID.checked == true)
    {
       QueryString +=  "&postscomments=1";
    }
    else
    {
        QueryString +=  "&postscomments=0";
    }
    
    if( WebsitesID.checked == true)
    {
       QueryString +=  "&websites=1";
    }
    else
    {
        QueryString +=  "&websites=0";
    }
     
    if( StatusID.checked == true)
    {
       QueryString +=  "&status=1";     
    }
    else
    {
        QueryString +=  "&status=0";
    }   
    
    if( VideosID.checked == true)
    {
       QueryString +=  "&videos=1";     
    }
    else
    {
        QueryString +=  "&videos=0";
    }   
    
    if( VideoCommentID.checked == true)
    {
       QueryString +=  "&videocomment=1";     
    }
    else
    {
        QueryString +=  "&videocomment=0";
    }   
    
    
    GetPulsePeriod();
    
    QueryString +=  "&feedsperiod=" + Period;  
    QueryString +=  "&newsfrom="+ NewsFrom;  
    QueryString +=  "&user="+ user;  
 
    CallAjaxPage(QueryString, divName);
}

//Sets the selected css class for the selected day and removes the selection from the other days. - MAISQ -
function SelectDays(ObjectID,ClassName)
{
    j$Obj('divOneDay').className = "";
    j$Obj('divThreeDays').className = "";
    j$Obj('divSevenDays').className = "";

    ObjectID.className = ClassName;   
}

//Change the "Pulse Period" according to the selected day.
function GetPulsePeriod()
{
    if(j$Obj('divOneDay').className != "")
    {
        FeedsPeriod = 1;
    }
    else if(j$Obj('divThreeDays').className != "")
    {
        FeedsPeriod = 3;
    }
    else
    {
        FeedsPeriod = 7;
    }
}

//rs.js
//This function is basically a class which encapsulates all the methods needed to perform asynchronous callbacks
function JeeranRemoteScripting() {
	//--------------PRIVATE MEMBERS
	
	var _JeeranRemoteScripting = this;
	var _HTTPRequester = null;
	var _RequestMethod = null;
	var _RequestURL = null;
	var _RequestAsynch = null;
	var _Data = null;
	var _GetXML = "";
	var _GetText = "";
	
	//--------------PROPERTIES
	
	//Write only
	this.SetRequestMethod = function(Method) {		
		_RequestMethod = Method;
	}
	this.SetRequestURL = function(URL) {
		_RequestURL = URL;		
	}		
	this.SetData = function(Data) {
		_Data = Data;
	}	
	this.SetRequestAsynch = function(Asynch) {
		_RequestAsynch = Asynch;
	}
	//Read only
	this.GetXML = function() {
		return _GetXML;
	}
	this.GetText = function() {
		return _GetText;
	}
	
	//--------------PUBLIC METHODS
	
	//Initialize the requester
	this.InitializeRequester = function() {		
		var randomnumber = Math.floor(Math.random()*100000000); //this is to prevent caching
		if (_RequestURL.indexOf("?") > -1)
		{
			_RequestURL += "&r=" + randomnumber
		}
		else
		{
			_RequestURL += "?r=" + randomnumber
		}		
		
		try
		{			
			_HTTPRequester = new XMLHttpRequest();
			_HTTPRequester.open(_RequestMethod, _RequestURL, _RequestAsynch);
		}
		catch (error)
		{
			try
			{
				_HTTPRequester = new ActiveXObject("Microsoft.XMLHTTP");
				_HTTPRequester.open(_RequestMethod, _RequestURL, _RequestAsynch);
			}
				catch (error)
			{	
				try
				{
					_HTTPRequester = new ActiveXObject("Msxml2.XMLHTTP");
					_HTTPRequester.open(_RequestMethod, _RequestURL, _RequestAsynch);
				}
				catch (error)
				{
				}
			}
		}				
	}
	
	//Send the request
	this.SendRequest = function() {
			if (_RequestMethod == "POST")
			{
				_HTTPRequester.setRequestHeader("Method", "POST "+_RequestURL+" HTTP/1.1");
       			_HTTPRequester.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			_HTTPRequester.send(_Data);
			_HTTPRequester.onreadystatechange = stateHandler;
	}
	
	//Close aborts the XMLHttpRequest object
	this.Close = function() {
		_HTTPRequester.abort();
	}	

	//--------------PRIVATE METHODS
	
	//This monitors the request status and performs the nessesary actions
	function stateHandler()
	{
	    try
	    {
		    if (_HTTPRequester.readyState == 4)
		    {
			    if (_HTTPRequester.status == 200)
			    {				
					    _GetXML = _HTTPRequester.responseXML;
					    _GetText = _HTTPRequester.responseText;
					    //_GetText = _HTTPRequester.responseText;
					    _Loaded(); //Fire the loaded event
			    }
			    else
			    {
				    _Failure(); //Fire the failure event
			    }
		    }
    	    return true;
        }
        catch(error)
        {
            return false;
            _Failure(); //Fire the failure event
        }
	}
	
	//--------------EVENTS
	
	//Public Events
	this.OnLoaded = function() {};
	this.OnFailure = function() {};
	
	//Private Events
	function _Loaded() { 
		_JeeranRemoteScripting.OnLoaded(); 
		_JeeranRemoteScripting.Close();
	}
	
	function _Failure() 
	{ 
		_JeeranRemoteScripting.OnFailure();
		_JeeranRemoteScripting.Close();
	}
}

// Does creates and sends the ajax request and returns the requester object
function CreateAjaxRequest(RequestURL, RequestMethod, RequestData)
{
    var AjaxRequester = new JeeranRemoteScripting();
	AjaxRequester.SetRequestMethod(RequestMethod);
	AjaxRequester.SetRequestURL(RequestURL);
	AjaxRequester.SetRequestAsynch(true);
	AjaxRequester.SetData(RequestData);

	AjaxRequester.InitializeRequester();
	AjaxRequester.SendRequest();
    
    return AjaxRequester;

}

//Status.js

//Loads user status message
function LoadUserStatus()
{   
    //Create an ajax call to get status message 
    var AjaxRequest;
    AjaxRequest =  CreateAjaxRequest(AjaxStatusUrl + "&action=getcurrent","GET","");
    AjaxRequest.OnLoaded = function() 
    { 
        var userStatus = AjaxRequest.GetText();
     
        if (userStatus != "")
        {
          
            //Show read div and hide write div
            HideDiv('StatusWrite');
            ShowDiv('StatusRead');
            
             
            //set status message label
            document.getElementById('lblStatusMessage').innerHTML = userStatus;
            AjaxRequest = null;
        }
        else
        {
            GetEmptyStatusMessage();
        }
    }
    AjaxRequest.OnFailure = function()
    {
        AjaxRequest = null;
    }
 } 
 
 // if user doesnt have a status message get an empty message
 function GetEmptyStatusMessage()
 {
    //Show read div and hide write div
    HideDiv('StatusRead');
    ShowDiv('StatusWrite');
    
    //Create an ajax call to get the empty status text
    var AjaxRequest;
    AjaxRequest =  CreateAjaxRequest(AjaxStatusUrl + "&action=emptystatus","GET","");
    AjaxRequest.OnLoaded = function() 
    { 
        
        document.getElementById('txtStatusMessage').value = AjaxRequest.GetText();
        document.getElementById('txtStatusMessage').select();
        AjaxRequest = null;
 
    }
        
          AjaxRequest.OnFailure = function()
    {
        AjaxRequest = null;
    }
 }
 
 //Clear Status Message
  function ClearStatusMessage()
 {

    //Create an ajax call to get the empty status text
    var AjaxRequest;
    AjaxRequest =  CreateAjaxRequest(AjaxStatusUrl + "&action=clearstatus","GET","");
    AjaxRequest.OnLoaded = function() 
    { 
        //show the empty status message
        GetEmptyStatusMessage();
        AjaxRequest = null;
 
    }
        
          AjaxRequest.OnFailure = function()
    {
        AjaxRequest = null;
    }
 }



 function UpdateUserStatus() {

     //Get updated text
     var NewStatusText = document.getElementById("txtStatusMessage").value;
     NewStatusText = encodeURIComponent(NewStatusText);
     
     var AjaxTwitterRequest;
     AjaxTwitterRequest = CreateAjaxRequest(AjaxTwitterURL, "GET", "");

     AjaxTwitterRequest.OnLoaded = function() {
         var twitterAlert = AjaxTwitterRequest.GetText();

         if (twitterAlert == "True") {

             ShowActionLightBox("status||=||" + NewStatusText);
         }

         var AjaxRequest;

         //Create an ajax call to get status message
         AjaxRequest = CreateAjaxRequest(AjaxStatusUrl + "&action=setstatus", "POST", "newstatus=" + NewStatusText);

         AjaxRequest.OnLoaded = function() {
             var userStatus = AjaxRequest.GetText();

             if (userStatus != "") {
                 //Show read div and hide write div
                 HideDiv('StatusWrite');
                 ShowDiv('StatusRead');


                 //set status message label
                 document.getElementById('lblStatusMessage').innerHTML = userStatus;
                 AjaxRequest = null;
             }
             else {
                 GetEmptyStatusMessage();
             }
         }
         AjaxRequest.OnFailure = function() {
             AjaxRequest = null;
         }
         
     }

   
 } 
 
   function EditUserStatus() 
    {
    //Create an ajax call to get status message 
    var AjaxRequest;
    AjaxRequest =  CreateAjaxRequest(AjaxStatusUrl + "&action=GetStatusForEdit","GET","");
    AjaxRequest.OnLoaded = function() 
    { 
        var userStatus = AjaxRequest.GetText();

        if (userStatus != "")
        {
          
            //Show write div and hide read div
            HideDiv('StatusRead');
            ShowDiv('StatusWrite');
            
             
            //set status message label
            document.getElementById('txtStatusMessage').value = userStatus;
            AjaxRequest = null;
        }
        else
        {
            GetEmptyStatusMessage();
        }
    }
    AjaxRequest.OnFailure = function()
    {
        AjaxRequest = null;
    }
    }
 
 
//method that calls the Validate layer form when the ENTER key is pressed and stops the action onblure for the same control
function StatusKeyPress(e)
{  
    var NewStatusText = document.getElementById("txtStatusMessage").value;
  
 
    
    var oEvent = window.event ? window.event : e;
    var isDOM = (document.getElementById ? true : false);
    var isNS4 = (document.layers ? true : false);



    if (document.all != 'undefined') key = oEvent.keyCode;
    else if (isDOM) key = oEvent.charCode;
    else if (isNS4) key = oEvent.which;

    if(key == 13)
    {            
        UpdateUserStatus();
        
        // for stoping the .Net auto post back in the IE and Firefox --  SARA AA 16/10/2007
        e.returnValue = false;  
        e.cancel = true;  // for IE
        e.cancelBubble = true; // for IE
        e.preventDefault(); // for FF
        
        return false;
    }
}



