﻿function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}


function TextChanged(o) {
    if (codeguidmaps.hasItem(o.id) && formexps.hasItem(codeguidmaps.getItem(o.id))) {
       var expsArray = formexps.getItem(codeguidmaps.getItem(o.id)); 
       for (var i=0;i<expsArray.length;i++)
       {
		   var expressionhtml = $($.base64Decode(expsArray[i]));
		   var expressionType = expressionhtml.find("ExpressionType").text();
		   var Formula = expressionhtml.find("Formula").text();
  		   var CurrFormItem = expressionhtml.find("CurrFormItem").text();
            
		   if (expressionType == "DependencyFormula") {
		   
    	        expressionhtml.find("Var").each(function(i){
					if (guidcodemaps.hasItem($(this).attr("FormItemGUID"))) {
						var controlVal = $("#" +guidcodemaps.getItem($(this).attr("FormItemGUID"))).val();
						var reg=new RegExp($(this).attr("VarName"),"g"); 
						
						Formula = Formula.replace(reg, controlVal)
						
				    }                    
        	    });
        	    
		        //$("#wide").append("mlookup.aspx?formitemguid=" + CurrFormItem +"&searchquery=" + $.base64Encode(Formula));
		        
				$.post("mlookup.aspx?formitemguid=" + CurrFormItem +"&searchquery=" + $.base64Encode(Formula),function(data){  
				      
				ClearAndSetStateListItems(data, returnObjById(guidcodemaps.getItem(CurrFormItem)));

		    });

		   }

       }
    } 
     returnObjById("@" +o.id).value = "1";   
}

function CheckStateChanged(o) {
    if (o.checked){
        o.value = "1";
    } else {
        o.value = "0";
    }
    returnObjById("@" +o.id).value = "1";
    
}

function FCKeditor_OnComplete( editorInstance )
{
    editorInstance.Events.AttachEvent( 'OnSelectionChange',DoSomething ) ;
    
    
}

function DoSomething( editorInstance )
{

//    alert('test' + editorInstance.Name);
    // This is a sample function that shows in the title bar the number of times
    // the "OnSelectionChange" event is called.
    //window.document.title = editorInstance.Name + ' : '  ;

    if (editorInstance.id != null) {
      returnObjById("@" + editorInstance.id).value = "1";   
    } else {
      returnObjById("@" + editorInstance.Name).value = "1";   
    }
    //document.forms("form1")("@" +editorInstance.Name).value = "1";   
}



var req;
var response;
var city;
var state;
var myHash = new Hash();

function loadXMLDoc(url, ddplist) {
    var lreq;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        
        lreq = new XMLHttpRequest();
        myHash.setItem(url, lreq);
        lreq.onreadystatechange = function () {processReqChange(url, ddplist)};
        lreq.open("GET", url, true);
        lreq.send(null);
    // branch for IE/Windows ActiveX versionform
    } else if (window.ActiveXObject) {
        isIE = true;
        lreq = new ActiveXObject("Microsoft.XMLHTTP");
        myHash.setItem(url, lreq);
        if (lreq) {     
            lreq.onreadystatechange = function () {processReqChange(url, ddplist)};
            lreq.open("GET", url, true);
            lreq.send();
        }
    }
}

function processReqChange(url, ddplist) {
    if (myHash.hasItem(url)) {
        var lreq = myHash.getItem(url);
        if (lreq.readyState == 4) {
            if (lreq.status == 200) {                 
			    response  = lreq.responseXML.documentElement;  	
  		        ClearAndSetStateListItems(lreq.responseXML.documentElement, ddplist)
            } else {
                alert("Req:status:" + lreq.statusText);
            }
        }
    }
}


function ClearAndSetStateListItems(xmlNode, ddpList)
 {
    var selectedValue;
    if (ddpList.selectedIndex > -1) {
        selectedValue = ddpList.options[ddpList.selectedIndex].value.toLowerCase();
    }
 
    for (var count = ddpList.options.length-1; count >-1; count--)
    {
        ddpList.options[count] = null;
    }
    var objNodeList = xmlNode.getElementsByTagName("Item");
	
	 ddpList.options[0] = new Option( "Please select", "",  false, false);
		
	if (selectedValue == "") {

	    ddpList.value = null;
        ddpList.text = ddpList.options[0].text;
		ddpList.options[0].selected = true;
	} 
     
    for (var i=0;i<objNodeList.length;i++)
    {
	    if (objNodeList[i].childNodes[0].text != null) {
	    
        optionItem = new Option( objNodeList[i].childNodes[1].text, objNodeList[i].childNodes[0].text,  false, false);
        } else {
        optionItem = new Option( objNodeList[i].getElementsByTagName("Display")[0].textContent, objNodeList[i].getElementsByTagName("Code")[0].textContent,  false, false);
	    }
		
        ddpList.options[ddpList.length] = optionItem;
//        optionItem.selected=false;
        //alert('[' + optionItem.value + ']');
        if (optionItem.value.toLowerCase() == selectedValue) {        			
            optionItem.selected=true;
            ddpList.value = optionItem.value;
            ddpList.text = optionItem.text;
			

        }
    }

}

function loadxml(ddpList, attriguid) {
    if (ddpList.options.length <= 1) {
  
	loadXMLDoc('mlookup.aspx?attributeguid=' + attriguid, ddpList );
     
	}
}

function ImportExcel(path,file)  {
    //alert(arrayList.length);
    //alert(arrayList[0]);
    var selecteditem = "";
    
    for(i=0; i < arrayList.length ; i++) {   
        var list = document.getElementById(arrayList[i]);

        if(list.checked == true){
            selecteditem = selecteditem + list.value + ',';
        }
    }

    if (selecteditem.length > 0) {
        selecteditem = selecteditem.substring(0,selecteditem.length-1);
    }
    
    //alert(filename + "in mcs.js");
    var url = 'action.aspx?action=Import&path=' + path + '&file=' + file + '&sl=' + selecteditem;
    //alert(url);
    
    if (window.XMLHttpRequest) {
        //alert(url);
        req = new XMLHttpRequest();
        req.onreadystatechange = function () {ImportComplete()};
        req.open('GET', url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function () {ImportComplete()};
            req.open("GET", url, true);
            req.send();
        }
    }
}

function ImportComplete() {
   if (req.readyState == 4) {
        if (req.status == 200) {
			alert("Import Complete");
			window.location = document.location;
        } else {
            alert("Req:status:" + req.statusText);
            //alert("Error");
        }
    }
}

// for document upload code //
function loadDocFolderxml(ddpList, objectguid ,recordguid) {

    if (ddpList.options.length <= 1) {
  
	loadXMLDoc('mlookup.aspx?action=load&objectguid=' + objectguid + '&recordguid='+ recordguid, ddpList );
     
	}
}

// for document upload code //
function loadDocFolderxml(ddpList, objectguid ,recordguid, queryguid) {

    if (ddpList.options.length <= 1) {
  
	loadXMLDoc('mlookup.aspx?action=load&objectguid=' + objectguid + '&recordguid='+ recordguid + '&queryguid='+ queryguid, ddpList );
     
	}
}

function createDocFolderxml(ddpList, objectguid, recordguid, foldername) {
  
  
	var url = 'mlookup.aspx?action=new&objectguid=' + objectguid + '&key=' + recordguid + '&foldername='+ foldername;
    
        //var filecount = document.getElementById("lastfilename").value;
         
        
       
       
     // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function () {
     
             
         for(i=0; i < arrayList.length ; i++) 
          {  
            
              processReqChangeforDocUpload(document.getElementById(arrayList[i] + "_selectedlist"))
            
           }
            checkfoldername();
        
        };
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function () {
            
         for(i=0; i < arrayList.length ; i++) 
            {  
            
              processReqChangeforDocUpload(document.getElementById(arrayList[i] + "_selectedlist"))
            
              }
              
             checkfoldername();
             
            };
            req.open("GET", url, true);
            req.send();
        }
    }

}

// For copy to folder //
function createCopyToFolder(objectguid, recordguid, foldername,object) {
    var url = 'mlookup.aspx?action=new&objectguid=' + objectguid + '&key=' + recordguid + '&foldername='+ foldername;
    //var filecount = document.getElementById("lastfilename").value;

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function () {
        checkcopytofoldername(object); //not complete
        getfolderguid();
    };
    
    req.open("GET", url, true);
    req.send(null);
    // branch for IE/Windows ActiveX version
    } 
    else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function () {                     
             checkcopytofoldername(object); //not complete
             getfolderguid();
            };
            req.open("GET", url, true);
            req.send();
        }
    }
}

//for Getting FolderGUID
function getfolderguid()
{
    if (req.readyState == 4) {
        if (req.status == 200) {
            var em = req.responseXML.documentElement;
            var check = em.getElementsByTagName("Code");
             //alert(check[0].textContent);
             alert($(check).eq(0).text());
             $("#divFolderProgress").html("<input type='hidden' id='FolderGUID' value='" + $(check).eq(0).text() + "'>");
        }
    }
}

function checkcopytofoldername(object)
{
    if (req.readyState == 4) {
        if (req.status == 200) {
  
            var em = req.responseXML.documentElement;
            var check = em.getElementsByTagName("Item");
         
            for (var i=0;i<check.length;i++) {
 	            if (check[i].childNodes[0].text != null) {
	                if(check[i].childNodes[0].text == "error") {
                        document.getElementById("foldernameError").innerHTML = check[i].childNodes[1].text;
                    }
                    else {
                        document.getElementById("divFolderProgress").removeChild(document.getElementById("createFolder"));
                        document.getElementById(object).href = document.getElementById(object + "X").value;
                    }
                } 
                else {
                    if(check[i].getElementsByTagName("Code")[0].textContent == "error") {
                        document.getElementById("foldernameError").innerHTML = check[i].getElementsByTagName("Display")[0].textContent;
                    }
                    else {
                        
                        document.getElementById("divFolderProgress").removeChild(document.getElementById("createFolder"));                         
                        document.getElementById(object).href = document.getElementById(object + "X").value;
                        
                    }
                }
            } // End for
        }
    }
}

function checkfoldername()
{
    if (req.readyState == 4) {
      if (req.status == 200) {
  
       var em = req.responseXML.documentElement;
       var cherk = em.getElementsByTagName("Item");
         
   for (var i=0;i<cherk.length;i++)
    {
 
	if (cherk[i].childNodes[0].text != null) {
	
        if(cherk[i].childNodes[0].text == "error")
        {
          document.getElementById("foldernameError").innerHTML = cherk[i].childNodes[1].text;
            
        }
        else
        {
          document.getElementById("divFolderProgress").removeChild(document.getElementById("createFolder"));
          document.getElementById("assignFolder").href = "javascript:this.createFolder()";
        }
     } 
     else
     {
        if(cherk[i].getElementsByTagName("Code")[0].textContent == "error")
        {
          document.getElementById("foldernameError").innerHTML = cherk[i].getElementsByTagName("Display")[0].textContent;
            
        }
        else
        {
          document.getElementById("divFolderProgress").removeChild(document.getElementById("createFolder"));
          document.getElementById("assignFolder").href = "javascript:this.createFolder()";
        }
     }
    }
    }
    }
}
function processReqChangeforDocUpload(ddplist) {
 

    if (req.readyState == 4) {
    
        if (req.status == 200) {        
         
			response  = req.responseXML.documentElement;
			var cherk = response.getElementsByTagName("Item");
			//alert(cherk[0].childNodes[0].text);
	if (cherk[0].childNodes[0].text != null) {		
  	        if(cherk[0].childNodes[0].text != "error")
            {
  		      ClearAndSetStateListItemsDocUpload(req.responseXML.documentElement, ddplist)
  		    }
  		  }
  		  else
  		  {
  		  //alert(cherk[0].getElementsByTagName("Display")[0].textContent);
  		     if(cherk[0].getElementsByTagName("Code")[0].textContent != "error")
            {
  		       ClearAndSetStateListItemsDocUpload(req.responseXML.documentElement, ddplist)
  		    }
  		  }
  		  
        } 

        else {
            alert("Req:status:" + req.statusText);
        }
    }
}

function ClearAndSetStateListItemsDocUpload(xmlNode, ddpList)
 {
    var selectedValue;
    if (ddpList.selectedIndex > -1) {
        selectedValue = ddpList.options[ddpList.selectedIndex].value.toLowerCase();
    }
 
    for (var count = ddpList.options.length-1; count >-1; count--)
    {
        ddpList.options[count] = null;
    }
    var objNodeList = xmlNode.getElementsByTagName("Item");
  
    
     
    for (var i=0;i<objNodeList.length;i++)
    {
	if (objNodeList[i].childNodes[0].text != null) {
	    
        optionItem = new Option( objNodeList[i].childNodes[1].text, objNodeList[i].childNodes[0].text,  false, false);
        } else {
        optionItem = new Option( objNodeList[i].getElementsByTagName("Display")[0].textContent, objNodeList[i].getElementsByTagName("Code")[0].textContent,  false, false);
	}
        ddpList.options[ddpList.length] = optionItem;
        //alert('[' + optionItem.value + ']');
        if (optionItem.value.toLowerCase() == selectedValue) {
            optionItem.selected=true;
        }
    }
    
}


// for document upload code finish //

// Change Password start //

function PostToPage(url,htmlObject) {
   //var htmlObject = document.getElementById("error");
    //alert(htmlObject.innerHTML);
    url += "&oldpassword=" + document.getElementById("oldpassword").value + "&newpassword=" + document.getElementById("newpassword").value;
    //alert(url);
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function () {processReqReturn(htmlObject)};
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
     
            req.onreadystatechange = function () {processReqReturn(htmlObject)};
            req.open("GET", url, true);
            req.send();
        }
    }
}
function processReqReturn(htmlObject) {
 
    if (req.readyState == 4) {
        if (req.status == 200) {
        
         
			response  = req.responseXML.documentElement;
  	
  		  displayXmlItems(req.responseXML.documentElement, htmlObject)
        } else {
            alert("Req:status:" + req.statusText);
        }
    }
}
function displayXmlItems(xmlNode, htmlObject)
 {
    var objNodeList = xmlNode.getElementsByTagName("Item");
     
     for (var i=0;i<objNodeList.length;i++)
     {     
	    if (objNodeList[i].childNodes[0].text != null) {

	        htmlObject.innerHTML = objNodeList[i].childNodes[1].text;
	        if(objNodeList[i].childNodes[0].text === "true")
	        {
	        $("#changePasswordInput").empty();
	        }
	    }
	    else {
	     
	      htmlObject.innerHTML = objNodeList[i].getElementsByTagName("Display")[0].textContent;
	     if(objNodeList[i].getElementsByTagName("Code")[0].textContent === "true")
	      {
	      $("#changePasswordInput").empty();
	      }

	    }
	    

    }
    
}


// change Password Finish//


<!-- helper script that uses the calendar -->
var oldLink = null;
// code to change the active stylesheet
function setActiveStyleSheet(link, title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (oldLink) oldLink.style.fontWeight = 'normal';
  oldLink = link;
  link.style.fontWeight = 'bold';
  return false;
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {

  TextChanged(cal.sel)
//   alert("test=" + document.forms(o.name));
//  document.forms("form1")("@" +o.name).value = "1";   
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format, showsTime, showsOtherMonths) {
//  alert("id=" + id);
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

// If this handler returns true then the "date" given as
// parameter will be disabled.  In this example we enable
// only days within a range of 10 days from the current
// date.
// You can use the functions date.getFullYear() -- returns the year
// as 4 digit number, date.getMonth() -- returns the month as 0..11,
// and date.getDate() -- returns the date of the month as 1..31, to
// make heavy calculations here.  However, beware that this function
// should be very fast, as it is called for each day in a month when
// the calendar is (re)constructed.
function isDisabled(date) {
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}

function flatSelected(cal, date) {
  var el = document.getElementById("preview");
  el.innerHTML = date;
}

function showFlatCalendar() {
  var parent = document.getElementById("display");

  // construct a calendar giving only the "selected" handler.
  var cal = new Calendar(0, null, flatSelected);

  // hide week numbers
  cal.weekNumbers = false;

  // We want some dates to be disabled; see function isDisabled above
  cal.setDisabledHandler(isDisabled);
  cal.setDateFormat("%A, %B %e");

  // this call must be the last as it might use data initialized above; if
  // we specify a parent, as opposite to the "showCalendar" function above,
  // then we create a flat calendar -- not popup.  Hidden, though, but...
  cal.create(parent);

  // ... we can show it here.
  cal.show();
}


// For The Help //
function help(HelpWebpageID) {
    document.getElementById("help_" + HelpWebpageID).href = "#";
    //this.href = "#";

    var createFolder = document.createElement("div");
	createFolder.className = "HelpPanel";
	createFolder.id = "HelpPanel_"+HelpWebpageID;
	
	var createFolderCancel = document.createElement("a");
	createFolderCancel.className = "HelpCancel";
	createFolderCancel.href = "javascript:this.closeHelpTap('" + HelpWebpageID + "')";
	//createFolderCancel.style.visibility = "hidden";
	createFolderCancel.appendChild(document.createTextNode(" "));
	createFolder.appendChild(createFolderCancel);
	
	var helpDescrip = document.createElement("div");
	helpDescrip.className = "HelpDescrip";
	helpDescrip.id = "HelpDescrip_" + HelpWebpageID;
	createFolder.appendChild(helpDescrip);
	
	//var ReadMore = document.createElement("a");
	//ReadMore.className = "ReadMore";
	//ReadMore.id = "ReadMore_" + HelpWebpageID;
	//ReadMore.appendChild(document.createTextNode("Read More..."));
	//ReadMore.href = "javascript:this.ReadMore('#ReadMore_"+ HelpWebpageID +"','"+ HelpWebpageID +"')";
	//createFolder.appendChild(ReadMore);  
	
	var createFolderCancel2 = document.createElement("a");
	createFolderCancel2.className = "HelpCancel";
	createFolderCancel2.href = "javascript:this.closeHelpTap('" + HelpWebpageID + "')";
	//createFolderCancel.style.visibility = "hidden";
	createFolderCancel2.appendChild(document.createTextNode(" "));
	createFolder.appendChild(createFolderCancel2);
	
	$("#divHelp_" + HelpWebpageID).html("");
	document.getElementById("divHelp_" + HelpWebpageID).appendChild(createFolder);
	document.getElementById("divHelp_" + HelpWebpageID).style.display= "";
	var HelpWebpage = document.getElementById(HelpWebpageID).value; 
		
	$.get("action.aspx?action=help&a=long&helpWebpage=" + HelpWebpageID,function(data){  
	    //alert($(data).find("Display").text());                     
        $("#HelpDescrip_"+ HelpWebpageID).html($(data).find("Display").text());		   
        //ReadMore(data,"#HelpDescrip");
    });
}

function loadSectionHtml(sectionguid, recordguid, QueryGUID,f1, f2, f3, f4, f5, f6, ronly,SearchWord) {
    $.get("action.aspx?action=formsection&sectionguid=" + sectionguid + "&recordguid=" + recordguid+ "&q=" + QueryGUID + "&f1=" + f1 + "&f2=" + f2+ "&f3=" + f3 + "&f4=" + f4 + "&f5=" + f5+ "&f6=" + f6+ "&ronly=" + ronly + "&SearchWord=" + SearchWord,function(data){                       
        $("#divsection_" + sectionguid ).html($(data).find("Display").text());		   
        //ReadMore(data,"#HelpDescrip");
    });
}


function checkSectionupdate(recordguid) {

    $.get("action.aspx?action=chatroom&recordguid=" + recordguid +"&lastupdated=" + $("#LastUpdated").val(),function(data){                       
        $("#messagelist" ).prepend($(data).find("Display").text());		   
        //ReadMore(data,"#HelpDescrip");
    });
}

//function ReadMore(datatext,textobject){
function ReadMore(readmoreobject,HelpWebpageID){
    $(readmoreobject).hide();
    var HelpWebpage = document.getElementById(HelpWebpageID).value; 
    $.get("action.aspx?action=help&a=long&helpWebpage="+ HelpWebpage,function(data){                       
        $("#HelpDescrip_" + HelpWebpageID).html($(data).find("Display").text());		   
    });
}

function closeHelpTap(HelpWebpageID) {
    document.getElementById("divHelp_"+ HelpWebpageID).removeChild(document.getElementById("HelpPanel_"+HelpWebpageID));
    document.getElementById("help_" + HelpWebpageID).href = "javascript:this.help('"+HelpWebpageID+"')";
}

/*hash table object*/
function Hash() {
	this.length = 0;
	this.items = new Array();
	for (var i = 0; i < arguments.length; i += 2) {
		if (typeof(arguments[i + 1]) != 'undefined') {
			this.items[arguments[i]] = arguments[i + 1];
			this.length++;
		}
	}
   
	this.removeItem = function(in_key)
	{
		var tmp_value;
		if (typeof(this.items[in_key]) != 'undefined') {
			this.length--;
			var tmp_value = this.items[in_key];
			delete this.items[in_key];
		}
	   
		return tmp_value;
	}

	this.getItem = function(in_key) {
		return this.items[in_key];
	}

	this.setItem = function(in_key, in_value)
	{
		if (typeof(in_value) != 'undefined') {
			if (typeof(this.items[in_key]) == 'undefined') {
				this.length++;
			}

			this.items[in_key] = in_value;
		}
	   
		return in_value;
	}

	this.hasItem = function(in_key)
	{
		return typeof(this.items[in_key]) != 'undefined';
	}
}

function AddLibrary(file,option,param2){
    var path = document.location.href.replace( "content/page.aspx" + document.location.search,"") + file;
    
    $.getScript(path, function(){
        
        createTheFolder("actionpanelform",option,param2);

        //alert(path);
    });
}

function AssignToFolderLibrary(file,option,param2){
    
    var path = document.location.href.replace( "content/page.aspx" + document.location.search,"") + file;
    
    $.getScript(path, function(){
        
        AssignToFolder("actionpanelform",option,param2,$("#RecordGUID").val());

        //alert(path);
    });
}


function floatbox(boxsize,floatboxcontent){
    $.floatbox( {
        content: "<a class='createFolderCancel' href='javascript:closeFloatBox()'> </a><h3 id='heading'></h3><div id='floatboxcontent'>"+ floatboxcontent + "</div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : boxsize
    });
}

function closeFloatBox() {			
				$("#floatbox-box").fadeOut(200, function () {
					 $("#floatbox-background").fadeOut(200, function () {
						$("#floatbox-box").remove();
						$("#floatbox-background").remove();
					});
					$("#floatbox-backgroundV2").fadeOut(200, function () {
						$("#floatbox-box").remove();
						$("#floatbox-backgroundV2").remove();
					});
                    $("#floatbox-backgroundWhite").fadeOut(200, function () {
						$("#floatbox-box").remove();
						$("#floatbox-backgroundWhite").remove();
						$("#floatbox-backgroundWhiteV2").remove();
						$("#floatbox-backgroundV2").remove();
					});
                    
					
				});
		}
				
function reload(){
    window.location.reload();
}
		
function deleteSelectedItem(isconfirm, heading) {
    var keys = "";
    //var currentTime = new Date();

    if($("#SelectObjectGUID").val() != undefined){
    $.get("action.aspx?action=getSelected&objectguid=" + $("#SelectObjectGUID").val()+ "&listguid=" + $("input[name='r']").val() + "&isconfirm=" + isconfirm,function(data){ 
        $(data).find("Display").each(function () {
            keys += $(this).text() + ",";
        });
         //alert($(data).find("Code").text());
        if($(data).find("Code").text()!= 'error'){
            if (keys.length > 0) {
                keys = keys.substr(0, keys.length - 1);
                // alert(keys);
                $.get("action.aspx?action=deletefromfolder&folderguid=" + $("input[name='r']").val() + "&keys=" + keys + "&isconfirm=" + isconfirm ,function(data){ 
                    //alert($(data).find("Display").text());
                    if(isconfirm == "1") {
                        $("#floatboxcontent").html($(data).find("Display").text());
                        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                    }
                    else {
                        floatbox("small","");
                        $("#heading").html(heading);
                        $("#floatboxcontent").html($(data).find("Display").text());
                        $("#floatboxaction").html("<li><a href='javascript:deleteSelectedItem(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                    }
                });
            }
        }
        else {
//            floatbox($(data).find("Display").text(),40,20);
            floatbox("");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
        }
    });
    }
    else
    {
//      floatbox("<p>There is no item(s)</p></br><a href='javascript:reload();'>OK</a>",40,20);
        floatbox("");
        $("#heading").html(heading);
        $("#floatboxcontent").html("<p>There are no files in this folder which can be selected for this action.</p>");
        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
    }    
}

function SetProfileImage(isconfirm,heading) {

            $.get("action.aspx?action=setProfileImage&" + document.location.search.replace("?","") + "&isconfirm=" + isconfirm ,function(data){ 
                if(isconfirm == "1") {  
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                }
                else {
             floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='javascript:SetProfileImage(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }
            });
        
}

function ClearProfileImage(isconfirm,heading) {

            $.get("action.aspx?action=clearProfileImage&" + document.location.search.replace("?","") + "&isconfirm=" + isconfirm ,function(data){ 
                if(isconfirm == "1") {
                    $("#floatboxcontent").html($(data).find("Display").text());
                    $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                }
                else {
                     floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='javascript:ClearProfileImage(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }
            });
        
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function OpenEditor(t, o, r){
	var currentTime = new Date();

	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' onclick='reload();' href='javascript:void(0); reload();'  >Close</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=" + t + "&o="+ o + "&r="+ r + "&timer=" + currentTime.getTime() +"' ></iframe>", boxsize : "large",	fade: true});
	}
	
	
	function OpenEditor(t, o, r, urlparam){
	var currentTime = new Date();

	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' onclick='reload();' href='javascript:void(0); reload();'  >Close</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=" + t + "&o="+ o + "&r="+ r + urlparam+"&timer=" + currentTime.getTime() +"' ></iframe>", boxsize : "large",	fade: true});
	}

function NewEditor(t, o, urlparam){
	var currentTime = new Date();

	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:void(0); reload();'  >Close</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=" + t + "&o="+ o + "&a=new" + urlparam+ "&timer=" + currentTime.getTime() +"' ></iframe>", boxsize : "large",	fade: true});
	}

function OpenSearchForm(o, actionguid, trackformparam, urlparam){
	var currentTime = new Date();
	if (actionguid == null) {
	
	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:void(0); reload();'   >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebSearch&o="+ o + "&timer=" + currentTime.getTime() + urlparam +"' ></iframe>", boxsize : "large",	fade: true});
    } else {
        $.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:void(0);' onclick='MoveTempDataToObject(\"" +actionguid +"\", \"" + o + "\", \"" +trackformparam +"\")' >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebSearch&o="+ o + urlparam + "&timer=" + currentTime.getTime() +"' ></iframe>", boxsize : "large",	fade: true});
    }	
	}
	
function OpenPagePopup(o, actionguid, trackformparam, urlparam){
    var currentTime = new Date();
    if (actionguid == null) {

    $.floatbox(
    {content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:void(0);'   >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebSearch&o="+ o + "&timer=" + currentTime.getTime() + urlparam +"' ></iframe>", boxsize : "large",	fade: true});
    } else {
        $.floatbox(
    {content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:void(0);'  >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebSearch&o="+ o + urlparam + "&timer=" + currentTime.getTime() +"' ></iframe>", boxsize : "large",	fade: true});
    }	
}

function PopupAction(action, formurl){
	var currentTime = new Date();
	
    $.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:void(0);' onclick='" + action + "' >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='" + formurl + "&timer=" + currentTime.getTime() + "' ></iframe>", boxsize : "large",	fade: true});
	}



function OpenPagePopupRefresh(o, actionguid, trackformparam, urlparam){
    var currentTime = new Date();
    if (actionguid == null) {

    $.floatbox(
    {content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:location.reload();'   >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebSearch&o="+ o + "&timer=" + currentTime.getTime() + urlparam +"' ></iframe>", boxsize : "large",	fade: true});
    } else {
        $.floatbox(
    {content: "<p class='floatboxaction'><a id='close-floatbox' href='javascript:location.reload();'  >Confirm</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebSearch&o="+ o + urlparam + "&timer=" + currentTime.getTime() +"' ></iframe>", boxsize : "large",	fade: true});
    }	
}
function MoveTempDataToObject(actionguid, selobjectguid, param){
    
    $.get("action.aspx?action=MoveTempDataToObject&actoinguid=" + actionguid + "&selobjectguid=" + selobjectguid + "&param=" + param,
		function(data){ 
		    if (data != null) {
                        var content = $(data).find("Message").text();
                        
                        if($(data).find("IsErrorReturn").text()== '1')
                        {     
				            floatbox("small","");
                        
                        $("#heading").html("Validation Failed");
                        $("#floatboxcontent").html("<p>" + content + "</p>");
                        $("#floatboxaction").html("<li><a href='javascript:closeFloatBox()'>OK</a></li>");                 
                        }
                        else{

			            window.location = document.location;
                }	
			}
		});
}
	
	
function OpenLibraryForm(p,o,r,fo,fr){
        //alert(p+ " | " + " | " + o + " | " + r);
		var currentTime = new Date();
	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' href=\"javascript:closeFloatBox(); AddObjectDocument('" + fo + "','" + fr + "','" + o + "'); reload(); \">Close</a><a class='createFolderCancel' href='javascript:closeFloatBox()'> </a></p><iframe id='iframe_search' src ='pagenoheader.aspx?t=WebViewer&p="+ p + "&o=" + o + "&r=" + r + "&timer=" + currentTime + "' ></iframe>", boxsize : "large",	fade: true});
	}	
	
function AddObjectDocument(fo,fr,o){
       
                        
$.get("action.aspx?action=addobjectdocument&objectguid=" + fo + "&recordguid=" + fr+ "&selectionObject=" + o );
                        
                                                
	
}	
	
/* for Email */
function getmail(){

 
 
  $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small"
    });
    
    $("#heading").html("Loading email, please wait..");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    
$.get("Email.aspx?action=getmail",function(data){ 

var count = $(data).find("emailcount").text();

$("#floatbox-box").remove();
$("#floatbox-background").remove();

if(count > 0)
{

   $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'><h3>" + count +" Email will be download ?</h3></div><ul id='floatboxaction' class='action'><li><a href='javascript:loadEmail(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li></ul>",
        fade: true,
        boxsize : "small"
    });

    
}
else
{
    loadEmail();
}
});

}
 
 function loadEmail(confirm){

$("#floatbox-box").remove();
$("#floatbox-background").remove();
 
 if(confirm != null)
 {
     $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small"
    });
    
    $("#heading").html("Loading email, please wait..");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
        
        
    $.get("Email.aspx?action=getmail&confirm=true",function(data){
        //alert("test");
        $("#floatbox-box").remove();
        $("#floatbox-background").remove();
        $.floatbox( {
            content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
            fade: true,
            boxsize : "small"
        });

        $("#heading").html("Loading email, please wait..");    
        $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");

        window.location.reload();

        $(window).load(function(){
            closeFloatBox();
        });
    });
    
 }
 else
 {
    $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small"
    });
    
    $("#heading").html("Loading email, please wait..");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    
    window.location.reload();
    
    $(window).load(function(){
        closeFloatBox();
    });
 }
 
 }
 
 function EmailFlag (object){
    $(function(){
    // BUTTON
    //alert($("#" + object).html());
    $("#" + object).hover(
    function(){ $(this).removeClass('ui-state-default').addClass('ui-state-focus'); },
    function(){ $(this).removeClass('ui-state-focus').addClass('ui-state-default'); }
    );

    // MENU
    $("#" + object).menu({
    content: $("#" + object).next().html(), // grab content from this page
    showSpeed: 400,
    width : 35,
    maxHeight : 80
    });
    });
}


function SetEmailFlag (object1,object2){
    $("#"+ object1).html($("#"+ object2).html());
    $.get("action.aspx?action=setEmailFlag&EmailGUID=" + object1 + "&FlagGUID=" + object2 );   
    
}


function MoveToTrash(RecordGUID){

    $.get("action.aspx?action=DeleteEmail&RecordGUID=" + RecordGUID,function(){
    $("input[name='actionselect']").attr('checked', false);
    window.location.reload();   
    });   
    

}

function DeleteAllMail(RecordGUID){

    $.get("action.aspx?action=DeleteAllMail&RecordGUID=" + RecordGUID,function(){
    $("input[name='actionselect']").attr('checked', false);
    window.location.reload();   
    });   
    

}
function DeleteSelectedMail(RecordGUID,isConfirm){

    $.get("action.aspx?action=DeleteSelectedMail&isConfirm=" + isConfirm + "&RecordGUID=" + RecordGUID,function(data){
        if(isConfirm == 1){
             floatbox("small","");
            $("#heading").html("Delete Selected Email");
            $("#floatboxcontent").html(data);
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
        }
        else{
        if(data == "0")
        {
            floatbox("small","");
            $("#heading").html("Delete Selected Email");
            $("#floatboxcontent").html("<p>You have not selected any item(s)</p>");
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
        }
        else
        {
             floatbox("small","");
            $("#heading").html("Delete Selected Email");
            $("#floatboxcontent").html(data);
            $("#floatboxaction").html("<li><a href=\"javascript:DeleteSelectedMail('" + RecordGUID + "','1')\">Confirm</a></li><li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
         }
        }
    //window.location.reload();   
    });   
    
}

function RestoreMail(RecordGUID){

    $.get("action.aspx?action=RestoreMail&RecordGUID=" + RecordGUID,function(){
    $("input[name='actionselect']").attr('checked', false);
    window.location.reload();   
    });   
    
}

function EmailAddLibrary(file,option,param2){
    var path = document.location.href.replace( "content/page.aspx" + document.location.search,"") + file;
    
    $.getScript(path, function(){
        
      createTheFolder("actionpanelform",option,param2);

        //alert(path);
    });
}

function deleteSelectedEmailItem(isconfirm, heading) {
    var keys = "";
    //var currentTime = new Date();

    if($("#SelectObjectGUID").val() != undefined){
    $.get("action.aspx?action=getSelected&objectguid=" + $("#SelectObjectGUID").val()+ "&listguid=" + $("input[name='r']").val() + "&isconfirm=" + isconfirm,function(data){ 
        $(data).find("Display").each(function () {
            keys += $(this).text() + ",";
        });
         //alert($(data).find("Code").text());
        if($(data).find("Code").text()!= 'error'){
            if (keys.length > 0) {
                keys = keys.substr(0, keys.length - 1);
                // alert($("#QueryGUID").val());
                
                $.get("action.aspx?action=deletefromfolder&folderguid=" + $("#QueryGUID").val() + "&keys=" + keys + "&isconfirm=" + isconfirm ,function(data){ 
                    //alert($(data).find("Display").text());
                    if(isconfirm == "1") {
                        $("#floatboxcontent").html($(data).find("Display").text());
                        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                    }
                    else {
                        floatbox("small","");
                        $("#heading").html(heading);
                        $("#floatboxcontent").html($(data).find("Display").text());
                        $("#floatboxaction").html("<li><a href='javascript:deleteSelectedEmailItem(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                    }
                });
            }
        }
        else {
//            floatbox($(data).find("Display").text(),40,20);
            floatbox("");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
        }
    });
    }
    else
    {
//      floatbox("<p>There is no item(s)</p></br><a href='javascript:reload();'>OK</a>",40,20);
        floatbox("");
        $("#heading").html(heading);
        $("#floatboxcontent").html("<p>There are no files in this folder which can be selected for this action.</p>");
        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
    }    
}


function EmailMarkAsRead(){
$.get("action.aspx?action=EmailMarkAsRead&objectguid=" + $("#SelectObjectGUID").val()+ "&listguid=" + $("input[name='r']").val(),function(data){ 
        floatbox("");
        $("#heading").html(data);
        $("#floatboxcontent").html("<p>Mark as Read is done</p>");
        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
}
);

}

function EmailFlag2 (object){
//    $(function(){
//    // BUTTON
//    //alert($("#" + object).html());
//    $("#" + object).hover(
//    function(){ $(this).removeClass('ui-state-default').addClass('ui-state-focus'); },
//    function(){ $(this).removeClass('ui-state-focus').addClass('ui-state-default'); }
//    );

//alert($("#showStar").html());
    $(object).attr('tabindex','0');
    //$(object).addClass('ui-widget ui-state-default ui-corner-all');
 //$(object).removeClass('ui-state-default').addClass('ui-state-focus');
    // MENU
    $(object).menu({
    content: $("#showStar").html(), // grab content from this page
    showSpeed: 400,
    width : 40,
    maxHeight : 80
    });
   
}

function SetEmailFlagAll (object1){
    //$("#"+ object1).html($("#"+ object2).html());
    $.get("action.aspx?action=setEmailFlagAll&FlagGUID=" + object1 + "&objectguid=" + $("#SelectObjectGUID").val()+ "&listguid=" + $("input[name='r']").val(),function(data){ 
        // floatbox("");
//        $("#heading").html(data);
//        $("#floatboxcontent").html("<p>All done</p>");
//        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");

            //reload();
            $("input[name='actionselect']").attr('checked', false);
    });
    
}


 
			
function CloneAll(actionguid, objectguid, recordguid){
 
    $.get("action.aspx?action=CloneAll&actionguid=" + actionguid + "&objectguid=" + objectguid + "&recordguid=" + recordguid,
		function(data){ 
		    if (data != null) {					 				
			
				var newlocation = window.location + "";
				newlocation = newlocation.replace("&r=" + recordguid.toUpperCase(),"&r=" + $(data).find("Root").text().toUpperCase());
				
				/*$("<div>Clone Successfully</div>").dialog({ modal: true });*/
	 floatbox("small","");
    
        $("#floatboxcontent").html("<div>Clone action completed successfully.</div>");
        $("#floatboxaction").html("<li><a href='" + newlocation + "'>OK</a></li>");
//	alert( recordguid.toLowerCase());
//	alert($(data).find("Root").text().toLowerCase());

					
			}
		});
 
}	

function DeleteProfileImage(isconfirm,heading) {

            $.get("action.aspx?action=DeleteProfileImage&" + document.location.search.replace("?","") + "&isconfirm=" + isconfirm ,function(data){ 
                if(isconfirm == "1") {
                    $("#floatboxcontent").html($(data).find("Display").text());
                    $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                }
                else {
                     floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='javascript:DeleteProfileImage(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }
            });
        
}

function MessageMarkAsRead(Object){

$.get("action.aspx?action=MessageMarkAsRead&MessageGUID=" + Object,function(data){ 
//        floatbox("");
//        $("#heading").html(data);
//        $("#floatboxcontent").html("<p>Mark as Read is done</p>");
//        $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
     //alert(data);
    $("#" + Object).hide("slow");
    //$("#" + Object).next().html("<a href='javascript:$('#"+ Object +"').show("slow");'>Undo</a>");
}
);

}

function MessageMarkAsReadWidget(Object){

$.get("action.aspx?action=MessageMarkAsRead&MessageGUID=" + Object,function(data){ 
       // floatbox("");
        //$("#heading").html(data);
        //$("#floatboxcontent").html("<p>Mark as Read is done</p>");
       //$("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
       //reload();

       $("#" + Object).slideUp(function () {
                                $(this).remove();
        });
     //alert(data);
//    $("#" + Object).hide("slow");
    //$("#" + Object).next().html("<a href='javascript:$('#"+ Object +"').show("slow");'>Undo</a>");
}
);

}

function DeleteMessageAttach(Object){
 
$.get("action.aspx?action=DeleteMessageAttach&DocumentGUID=" + Object,function(data){ 
    $("#doc_" + Object).hide();
;

}
);

}

function MessageAttachSetProfileImage(DocumentGUID,ObjectGUID,ObjectRecordGUID){
 $.get("action.aspx?action=setProfileImage&r=" + DocumentGUID + "&f1="+ ObjectGUID + "&f2="+ ObjectRecordGUID +"&isconfirm=1" ,function(data){ 
        //$("#" + Object).hide("slow");
 }
 );
}

var current = 0;
var saved = 0;

function SelectAll(){

current = 0;
saved = 0;

var arr = [];

arr = $("input[name='actionselect']");


	$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Processing your request, please wait");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");

current = arr.length;
 for( var i = 0; i < arr.length; i++ ) {
    if($(arr[i]).val().length > 0 )
    {
        $(arr[i]).attr("checked","true");
        Oncheck(arr[i]);       
    }
   }

   
}

function CheckProcessing()
{
        saved++;
       
       
       if(current == saved)
       {
          
         $("#floatbox-box").remove();
                        $("#floatbox-background").remove();
                        $("#floatbox-backgroundWhite").remove();
        }
}

function DeselectAll(){

current = 0;
saved = 0;



	$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Processing your request, please wait");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");



var arr = [];
arr = $("input[name='actionselect']");


current = arr.length;
 for( var i = 0; i < arr.length; i++ ) {
 
    if($(arr[i]).val().length > 0 )
    {        
         $(arr[i])[0].checked = false;
         
         Oncheck(arr[i]);
    }
 
 }
}


function InverseSelection(){

current = 0;
saved = 0;

	$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Processing your request, please wait");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");

var arr = [];
arr = $("input[name='actionselect']");

current = arr.length;

 for( var i = 0; i < arr.length; i++ ) {
 
    if($(arr[i]).val().length > 0)
    {        
         if($(arr[i]).attr("checked") == true)
         {
            $(arr[i])[0].checked = false;
           
         }
         else
         {
           $(arr[i]).attr("checked","true"); 
         }
         
         
         Oncheck(arr[i]);
    }
 
 }
}

/* Form Expression*/

var formexps = new Hash();

var codeguidmaps = new Hash();
var guidcodemaps = new Hash();

function AddCodeGUIDs(id, guid){
    if (!guidcodemaps.hasItem(guid)) {
        guidcodemaps.setItem(guid, id);
    }  
     if (!codeguidmaps.hasItem(id)) {
        codeguidmaps.setItem(id, guid);
    }
  
}

function AddFormExps(guid, expression){
    var formexpsArray = [];
    if (!formexps.hasItem(guid)) {
        formexpsArray[formexpsArray.length] = expression;
        formexps.setItem(guid, formexpsArray);
    } else {
         formexpsArray = formexps.getItem(guid);
         formexpsArray[formexpsArray.length] = expression;
    }
  
}


function CalendarOpenEditor(date,t, o, r,p,ag,urlparam){
	var currentTime = new Date();
if(urlparam == "")
{

	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' onclick='closeFloatBox(); $(\"#calendar\").fullCalendar( \"refetchEvents\" );' href='javascript:void(0);'  >Close</a><a class='createFolderCancel' onclick='closeFloatBox(); $(\"#calendar\").fullCalendar( \"refetchEvents\" );' href='javascript:void(0);'> </a></p><iframe id='iframe_search' src ='popup.aspx?t=" + t + "&o="+ o + "&p=320C8BB0-3225-458F-8270-2AFE3B8633F4&ag="+ ag + "&r="+ r + urlparam +"&timer=" + currentTime.getTime() +"' ></iframe>", 
	boxsize : "large",	
	fade: true,
	 bg: "floatbox-backgroundV2"
	});
}
else
{
	$.floatbox(
	{content: "<p class='floatboxaction'><a id='close-floatbox' onclick='closeFloatBox(); $(\"#calendar\").fullCalendar( \"refetchEvents\" );' href='javascript:void(0);'  >Close</a><a class='createFolderCancel' onclick='closeFloatBox(); $(\"#calendar\").fullCalendar( \"refetchEvents\" );' href='javascript:void(0);' > </a></p><iframe id='iframe_search' src ='popup.aspx?t=" + t + "&o="+ o + "&r="+ r +"&p=" + p + "&ag="+ ag + urlparam +"&timer=" + currentTime.getTime() +"' ></iframe>",
	 boxsize : "large",
	 fade: true,
	 bg: "floatbox-backgroundV2"
	 });
}
}

function UpdateListView(date)
{ 
     
    if($(".fc-state-active a span").text() == "List")
    {
        
    
        var d = $('#calendar').fullCalendar('getDate');
       $.get("Calendar.aspx?module=GetCalendarItemListView&date=" + date + "&start=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss") +
      "&end=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss")+ "&o="+ $("#ObjectGUID").val() +"&r=" + $("#RecordGUID").val() +"&IsPanner=" + $("#IsPanner").val() + "&List=" + $("#CalendarSelectionList").val()
      ,function(data){ 
    $(".fc-list-view").html(data);   
    $('#calendar').fullCalendar( 'gotoDate', $.fullCalendar.parseDate($("#ListViewStartDate").val()));
    
        var start =  $.fullCalendar.parseDate($("#ListViewStartDate").val());
        var end = $.fullCalendar.parseDate($("#ListViewEndDate").val());
    
    $(".fc-header-title-monogold").html($.fullCalendar.formatDates(start,end,"MMM d[]{ '&#8212;'[ MMM] d}"));
    
    $(".fc-button-today").removeClass("fc-state-disabled");
    
    
    
    });
    }
}

function PreListView()
{
    $(".calendar-List").hide();
    $(".fc-header-title").parent().append("<h2 class='fc-header-title-monogold'></h2>");
    $(".fc-header-title-monogold").hide();
    
    $(".fc-button-prev").parent().append($(".fc-button-prev").clone().addClass("fc-button-prev-list"));
    $(".fc-button-prev-list").unbind("click");
    $(".fc-button-prev-list").hide();
    
    
    $(".fc-button-next").parent().append($(".fc-button-next").clone().addClass("fc-button-next-list"));
    $(".fc-button-next-list").unbind("click");
    $(".fc-button-next-list").hide();
    
    
    
    $(".fc-button-today").bind('click',function() {
       
        UpdateListView(0);
    
    });
    $(".fc-button-prev-list").bind('click',function() {
        UpdateListView(-7);
    
    });
    
    $(".fc-button-next-list").bind('click',function() {
        UpdateListView(7);
    
    });
}

function ListView()
{ 
      
        var d = $('#calendar').fullCalendar('getDate');
$.get("Calendar.aspx?module=GetCalendarItemListView&date=0&start=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss") +
      "&end=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss")+ "&o="+ $("#ObjectGUID").val() +"&r=" + $("#RecordGUID").val() +"&IsPanner=" + $("#IsPanner").val() + "&List=" + $("#CalendarSelectionList").val()
,function(data){ 
    $(".fc-list-view").html(data);    
    $(".fc-list-view").show();
    $(".fc-year-view").hide();
     $('#calendar').fullCalendar( 'gotoDate', $.fullCalendar.parseDate($("#ListViewStartDate").val()));
    
    $(".fc-button-today").removeClass("fc-state-disabled");
    $(".fc-state-default").removeClass("fc-state-active");
    
    $(".fc-button-List").addClass("fc-state-active");
    
    $(".fc-content").addClass("m-list");  //Added 13/3/10 by CMR
    
    var start =  $.fullCalendar.parseDate($("#ListViewStartDate").val());
    var end = $.fullCalendar.parseDate($("#ListViewEndDate").val());
   
    
    $("#calendar .calendar").hide();
    $(".calendar-List").show();
    
    $(".fc-header-title").hide();
    $(".fc-header-title-monogold").html($.fullCalendar.formatDates(start,end,"MMM d[]{ '&#8212;'[ MMM] d}"));
    $(".fc-header-title-monogold").show();
    
    $(".fc-button-prev").hide();
    $(".fc-button-prev-list").show();
    
    $(".fc-button-next").hide();
    $(".fc-button-next-list").show();
    
    
    
    $(".fc-view-month").hide();
    $(".fc-view-agendaWeek").hide();
    $(".fc-view-agendaDay").hide();
    
   $(".fc-button-month").click(function() {
        $(".fc-list-view").hide(); 
        $(".fc-button-List").removeClass("fc-state-active"); 
        $(".fc-view-month").show();
        ListOut();
        $(this).addClass("fc-state-active");});
   $(".fc-button-agendaWeek").click(function() {
        $(".fc-list-view").hide(); 
        $(".fc-button-List").removeClass("fc-state-active");
        $(".fc-view-agendaWeek").show();
        ListOut();
        $(this).addClass("fc-state-active");});
   $(".fc-button-agendaDay").click(function() {
        $(".fc-list-view").hide(); 
        $(".fc-button-List").removeClass("fc-state-active");
        $(".fc-view-agendaDay").show();
        ListOut();
        $(this).addClass("fc-state-active");});
        
   $(".fc-button-month a").click(function() {
        refetchEvents(this);
        });
   $(".fc-button-agendaWeek a").click(function() {
          refetchEvents(this);
        });
   $(".fc-button-agendaDay a").click(function() {
        refetchEvents(this);
      });
                
        
   $(".fc-button-Year").click(function() {
        ListOut();
   });
 }
);
}
function refetchEvents(objet)
{
$("#calendar").fullCalendar("refetchEvents");
$(objet).unbind("click");
}

function ListOut()
{
    $(".fc-content").removeClass("m-list");  //Added 13/3/10 by CMR
    $(".calendar").show();
    $(".calendar-List").hide();
    $(".fc-header-title").show();
    $(".fc-header-title-monogold").hide();
    $(".fc-button-prev").show();
    $(".fc-button-prev-list").hide();
    $(".fc-button-prev-year").hide();
    
    $(".fc-button-next").show();
    $(".fc-button-next-list").hide();
    $(".fc-button-next-year").hide();
    
    $(".fc-button-today a").unbind('click');
   
    
}

/*Year View*/

function UpdateYearView(date)
{ 
       if($(".fc-state-active a span").text() == "Year")
    {
        
				
     
        var d = $('#calendar').fullCalendar('getDate');
        //alert(d);
       $.get("Calendar.aspx?module=GetCalendarItemYearView&date=" + date + "&start=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss") +
      "&end=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss") + "&o="+ $("#ObjectGUID").val() +"&r=" + $("#RecordGUID").val() +"&IsPanner=" + $("#IsPanner").val() + "&List=" + $("#CalendarSelectionList").val()
      ,function(data){ 
    $(".fc-year-view").html(data);   
    $('#calendar').fullCalendar( 'gotoDate', $.fullCalendar.parseDate($("#YearViewStartDate").val()));

        var start =  $.fullCalendar.parseDate($("#YearViewStartDate").val());
        var end = $.fullCalendar.parseDate($("#YearViewEndDate").val());
    
    $(".fc-header-title-monogold-year").html($.fullCalendar.formatDate(start,"yyyy"));
    
    $(".fc-button-today").removeClass("fc-state-disabled");
    
    });
    }
}

function PreYearView()
{
    $(".calendar-Year").hide();
    
    $(".fc-header-title").parent().append("<h2 class='fc-header-title-monogold-year'></h2>");
    $(".fc-header-title-monogold-year").hide();
    
    $(".fc-button-prev-list").parent().append($(".fc-button-prev-list").clone().removeClass("fc-button-prev-list").addClass("fc-button-prev-year"));
    $(".fc-button-prev-year").hide();
    
    
    $(".fc-button-next-list").parent().append($(".fc-button-next-list").clone().removeClass("fc-button-next-list").addClass("fc-button-next-year"));
    $(".fc-button-next-year").hide();
    
    
    
    $(".fc-button-today").bind('click',function() {
       
        UpdateYearView(0);
    
    });
    $(".fc-button-prev-year").bind('click',function() {
        UpdateYearView(-1);
    
    });
    
    $(".fc-button-next-year").bind('click',function() {
        UpdateYearView(1);
    
    });
}

function YearView()
{ 
    $.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='loading..' />");
				
				
        var d = $('#calendar').fullCalendar('getDate');
$.get("Calendar.aspx?module=GetCalendarItemYearView&date=0&start=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss") +
      "&end=" + $.fullCalendar.formatDate(d,"ddd d MMM yyyy HH:mm:ss") + "&o="+ $("#ObjectGUID").val() +"&r=" + $("#RecordGUID").val() +"&IsPanner=" + $("#IsPanner").val() + "&List=" + $("#CalendarSelectionList").val()
,function(data){ 
    $(".fc-year-view").html(data);    
    $(".fc-year-view").show();
    $(".fc-list-view").hide();    
    // $('#calendar').fullCalendar( 'gotoDate', $.fullCalendar.parseDate($("#YearViewStartDate").val()));
    
      $(".fc-content").addClass("m-list");  //Added 13/3/10 by CMR
    
    $(".fc-button-today").removeClass("fc-state-disabled");
    $(".fc-state-default").removeClass("fc-state-active");
    
    $(".fc-button-Year").addClass("fc-state-active");
    
    var start =  $.fullCalendar.parseDate($("#YearViewStartDate").val());
    var end = $.fullCalendar.parseDate($("#YearViewEndDate").val());
   
    
    $("#calendar .calendar").hide();
    $(".calendar-Year").show();
    
    $(".fc-header-title").hide();
    $(".fc-header-title-monogold-year").html($.fullCalendar.formatDate(start,"yyyy"));
    $(".fc-header-title-monogold-year").show();
    
    $(".fc-button-prev").hide();
   // $(".fc-button-prev-list").hide();
    $(".fc-button-prev-year").show();
    
    $(".fc-button-next").hide();
   // $(".fc-button-next-list").hide();
    $(".fc-button-next-year").show();
    
    
    
    $(".fc-view-month").hide();
    $(".fc-view-agendaWeek").hide();
    $(".fc-view-agendaDay").hide();
    
   $(".fc-button-month").click(function() {
        $(".fc-year-view").hide(); 
        $(".fc-button-Year").removeClass("fc-state-active"); 
        $(".fc-view-month").show();
        YearOut();
        $(this).addClass("fc-state-active");});
   $(".fc-button-agendaWeek").click(function() {
        $(".fc-year-view").hide(); 
        $(".fc-button-Year").removeClass("fc-state-active");
        $(".fc-view-agendaWeek").show();
        YearOut();
        $(this).addClass("fc-state-active");});
   $(".fc-button-agendaDay").click(function() {
        $(".fc-year-view").hide(); 
        $(".fc-button-Year").removeClass("fc-state-active");
        $(".fc-view-agendaDay").show();
        YearOut();
        $(this).addClass("fc-state-active");});
   $(".fc-button-List").click(function() {
        YearOut();
   });
   
    $(".fc-button-month a").click(function() {
        refetchEvents(this);
        });
   $(".fc-button-agendaWeek a").click(function() {
          refetchEvents(this);
        });
   $(".fc-button-agendaDay a").click(function() {
        refetchEvents(this);
      });
      
            closeFloatBox();
      
 }
);
}

function YearOut()
{
    $(".fc-content").removeClass("m-list");  //Added 13/3/10 by CMR
    $(".calendar").show();
    $(".calendar-Year").hide();
    
    $(".fc-header-title").show();
    $(".fc-header-title-monogold-year").hide();
    $(".fc-button-prev").show();
    $(".fc-button-prev-list").hide();
    $(".fc-button-prev-year").hide();
    
    $(".fc-button-next").show();
    $(".fc-button-next-list").hide();
    $(".fc-button-next-year").hide();
    
}


function UserCalendarChange(obj){
	var checkvalue = "0";
	if ($(obj).attr("checked"))	{
		checkvalue = "1";
	}

			$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='loading..' />");
					
    $.get("action.aspx?action=usercalendarschange&r=" + $(obj).val() + "&s=" + checkvalue,function(){
       
        
    if($(".fc-state-active a span").text() == "Year")
    {
      YearView();  
    }
    else if($(".fc-state-active a span").text() == "List")
    {
        ListView();
    }
    if($("#calendar").html() != null)
    {
	    $("#calendar").fullCalendar("refetchEvents");
    }
    else{
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
                    $("#floatbox-backgroundWhite").remove();
    }


    });   
    

}


function DateTimeChanged(o) {
	var datetimeval = $("#date_" + o).val() + " " + $("#time_" + o).val();
	$("#" + o).val(datetimeval);
	returnObjById("@" +o).value = "1"; 
	     
}



function CalendarItemDelete(r, dmode) {
    
    if (dmode == null) {
        var dmode = $("input[name=btnRepeatDeleteMode]:checked").val();
		if (dmode != null) {
			$("#msgbox").css("display","none");
		} else {
			$("#msgbox").css("display","block");
			$("#msgbox").html("<p style='font-size:1em; padding:5px; border:1px solid red; background-color:yellow;'>You must select a delete option before Confirming.</p>");
			return;
		}
    }
    
	$.get("action.aspx?action=calendaritemdelete&r=" + r + "&dmode=" + dmode,function(){
               
         closeFloatBox();
         
        if($(".fc-state-active a span").text() == "Year")
        {
          YearView();  
        }
        else if($(".fc-state-active a span").text() == "List")
        {
            ListView();
        }
	    $("#calendar").fullCalendar("refetchEvents");
    		
	 });
}


function webpagePopup(page){
    $.get("action.aspx?action=webpagepopup&page=" + page,function(data){ 
        floatbox("large","");
        /*$("#heading").html("Web Page");*/
        $("#floatboxcontent").css("overflow","scroll");
        $("#floatboxcontent").css("height","460px");
        $("#floatboxcontent").attr("class","webpagepopup");
        $("#floatboxcontent").html(data);
    });
}



function CalendarSelectAll(o,r){


			$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");
					
    $.get("action.aspx?action=usercalendarsSelectAll&o=" + o + "&r=" + r,function(){
       
    var arr = [];

    arr = $("input[name='actionselect']");

    for( var i = 0; i < arr.length; i++ ) {
    if($(arr[i]).val().length > 0 )
    {
        $(arr[i]).attr("checked","true");     
    }
    }
       
	  if($("#calendar").html() != null)
    {
	    $("#calendar").fullCalendar("refetchEvents");
    }
    else{
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
                    $("#floatbox-backgroundWhite").remove();
    }
	
    });   
    

}

function CalendarDeselectAll(o,r){
		$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");
					
    $.get("action.aspx?action=usercalendarsDeselectAll&o=" + o + "&r=" + r,function(){
    
    var arr = [];

    arr = $("input[name='actionselect']");

    for( var i = 0; i < arr.length; i++ ) {
    if($(arr[i]).val().length > 0 )
    {
        $(arr[i])[0].checked = false;     
    }
    }
       
	  if($("#calendar").html() != null)
    {
	    $("#calendar").fullCalendar("refetchEvents");
    }
    else{
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
                    $("#floatbox-backgroundWhite").remove();
    }
	
    });   
}



function CalendarSelectAllList(o,r,SelectedValue){


			$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");
					
    $.get("action.aspx?action=usercalendarsSelectAll&o=" + o + "&r=" + r +"&SelectedValue=" + SelectedValue,function(){
       
    var arr = [];

    arr = $("input[name='actionselect']");

    for( var i = 0; i < arr.length; i++ ) {
    if($(arr[i]).val().length > 0 )
    {
        $(arr[i]).attr("checked","true");     
    }
    }
       
	$("#calendar").fullCalendar("refetchEvents");
	
    });   
    

}

function CalendarDeselectAllList(o,r,SelectedValue){
		$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");
					
    $.get("action.aspx?action=usercalendarsDeselectAll&o=" + o + "&r=" + r +"&SelectedValue=" + SelectedValue,function(){
    
    var arr = [];

    arr = $("input[name='actionselect']");

    for( var i = 0; i < arr.length; i++ ) {
    if($(arr[i]).val().length > 0 )
    {
        $(arr[i])[0].checked = false;     
    }
    }
       
	$("#calendar").fullCalendar("refetchEvents");
	
    });   
}




function CalendarListSelection(o,r,SelectedValue){


			$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");
				
				
					
    $.get("action.aspx?action=UserCalendarsList&o=" + o + "&r=" + r +"&SelectedValue=" + SelectedValue,function(data){
       
       
       
       $("#CalendarList").html(data);
       
	$("#calendar").fullCalendar("refetchEvents");
	
    });   
    

}



function ExportToExcel(URL){


			/*$.floatbox( {
				content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "loading"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Refreshing calendar, please wait.");    
				$("#floatboxcontent").html("<img src='../common/images/loading.gif' alt='Loading..' />");*/
					
    $.get(URL + "&IsComfirm=false",function(data){
       
        var xml =  $(data);
        xml.find("Root RowGUID").size()
         
        
        var html = "<div style='overflow:auto;width:550px;height:450px;border:1px solid #336699;padding-left:5px'>";
        
        

  
    for( var i = 0; i <  xml.find("Root RowGUID").size(); i++ ) {
    if(xml.find("Root Name").eq(i).text().length > 0 )
    {
           
           html += "<input type='checkbox' name='wow[]' value='" + xml.find("Root RowGUID").eq(i).text() + "'> " + xml.find("Root Name").eq(i).text() + "<br>" 
    }
    }
	
	$.floatbox( {
				content: "<p class='floatboxaction'><a id='close-floatbox' onclick='closeFloatBox(); ExportToExcelFile(\"" + URL + "\");' href='javascript:void(0);'  >Comfirm</a><a class='createFolderCancel' onclick='closeFloatBox();' href='javascript:void(0);'> </a></p><h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "medium"
				,
				bg : "floatbox-backgroundWhite"
				});


				$("#heading").html("Select the attribute.");    
				$("#floatboxcontent").html(html + "</div>");
				
				
	            
	
    });   
    

}

function ExportToExcelFile(URL){

 var arr = [];

var attrRowGUID = "";

    arr = $("input:checked[name='wow[]']");

    for( var i = 0; i < arr.length; i++ ) {
    if($(arr[i]).val().length > 0  &&  $(arr[i]).attr("checked") == true )
    {
       if(i == arr.length - 1)
       {
        attrRowGUID += "SELECT '" + $(arr[i]).val() + "'" ; 
       }
       else
       {
        attrRowGUID += "SELECT '" + $(arr[i]).val()+  "' UNION " ;
       }    
    }
    }

    
if(arr.length > 0) {

location.href=URL + "&IsComfirm=true&AttributeRowGUIDTxt=" + attrRowGUID;

    //$.get(URL + "&IsComfirm=true&AttributeRowGUIDTxt=" + attrRowGUID);
}

}


function IncludeJS(jsFile) {
if (js_scripts[jsFile] != null) return;
var scriptElt = document.createElement('script');
scriptElt.type = 'text/javascript';
scriptElt.src = jsFile;
document.getElementsByTagName('head')[0].appendChild(scriptElt);
js_scripts[jsFile] = jsFile;
}

function IncludeCSS(cssFile) {
if (css_scripts[cssFile] != null) return;

 var link = document.createElement('link'); 
	    link.href = cssFile; 
	    link.rel = 'stylesheet'; 
	    link.type = 'text/css'; 
	    document.getElementsByTagName('head')[0].appendChild(link);

    css_scripts[cssFile] = cssFile;
}


function FormPost(FormObject,IsConfirm){

 MyObject.UpdateEditorFormValue();

 var form = FormObject;

                if(IsConfirm == 1)
                {
				    var action = form.attr("action") + "?IsConfirmValid=1";
                }
                else{
                    var action = form.attr("action");
                }

				var serialized_form = form.serialize();
			    
                 
  $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small"
    });
    
    $("#heading").html("Processing your request, please wait");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    




				    $.post(action, serialized_form,function(data){
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
                     
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
				    
				    if($(data).find("hasError").text()== '0')
				    {
				        $(window.location).attr('href', $(data).find("RedirectURL").text());
				    }
				    else
				    {
                        var content = $(data).find("msg").text()
                        var reg=new RegExp("&lt;","g"); 
						content = content.replace(reg, "<")
                        var reg2=new RegExp("&gt;","g"); 
						content = content.replace(reg2, ">")
                        if($(data).find("IsConfirmPOPUP").text()== '1')
                        {
				            floatbox("medium","");
                        }
                        else{
                           floatbox("small","");
                        }
                        
                        $("#heading").html("Validation Failed");
                        $("#floatboxcontent").html("<p>" + content + "</p>");
                        if($(data).find("IsConfirmPOPUP").text()== '1')
                        {
                        $("#floatboxaction").html("<li><a href='javascript:FormPost($(\"#objectsaveeditorform\"),1);'>Confirm</a><a href='javascript:closeFloatBox()'>Cancel</a></li>");                 
                        }
                        else{
                        $("#floatboxaction").html("<li><a href='javascript:closeFloatBox()'>OK</a></li>");                 
                        }
                        
                        $("#floatboxcontent").attr("class","webpagepopup");

                        if($("#ErrorList") != null)
                        {
                            $('#ErrorList').scroll();
                        }
				    }
				});	
}



function FormPost2(FormObject,IsConfirm){


for ( i = 0; i < this.frames.length; ++i ){
if ( this.frames[i].FCK )
{

this.frames[i].FCK.UpdateLinkedField();
}
}


 var form = FormObject;

                if(IsConfirm == 1)
                {
				    var action = form.attr("action") + "?IsConfirmValid=1";
                }
                else{
                    var action = form.attr("action");
                }

				var serialized_form = form.serialize();
			    
                 
  $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small"
    });
    
    $("#heading").html("Processing your request, please wait");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    




				    $.post(action, serialized_form,function(data){
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
                     
                    $("#floatbox-box").remove();
                    $("#floatbox-background").remove();
				    
				    if($(data).find("hasError").text()== '0')
				    {
				        $(window.location).attr('href', $(data).find("RedirectURL").text());
				    }
				    else
				    {
                        var content = $(data).find("msg").text()
                        var reg=new RegExp("&lt;","g"); 
						content = content.replace(reg, "<")
                        var reg2=new RegExp("&gt;","g"); 
						content = content.replace(reg2, ">")
                        if($(data).find("IsConfirmPOPUP").text()== '1')
                        {
				            floatbox("medium","");
                        }
                        else{
                           floatbox("small","");
                        }
                        
                        $("#heading").html("Validation Failed");
                        $("#floatboxcontent").html("<p>" + content + "</p>");
                        if($(data).find("IsConfirmPOPUP").text()== '1')
                        {
                        $("#floatboxaction").html("<li><a href='javascript:FormPost($(\"#objectsaveeditorform\"),1);'>Confirm</a><a href='javascript:closeFloatBox()'>Cancel</a></li>");                 
                        }
                        else{
                        $("#floatboxaction").html("<li><a href='javascript:closeFloatBox()'>OK</a></li>");                 
                        }
                        
                        $("#floatboxcontent").attr("class","webpagepopup");

                        if($("#ErrorList") != null)
                        {
                            $('#ErrorList').scroll();
                        }
				    }
				});	
}




function MyClass()
{
this.UpdateEditorFormValue = function()
{
for ( i = 0; i < parent.frames.length; ++i )
if ( parent.frames[i].FCK )
parent.frames[i].FCK.UpdateLinkedField();
}
}
// instantiate the class
var MyObject = new MyClass();


function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}


function DeleteCalendarSeries(calEventid)
{
$.get("Calendar.aspx?module=GetCalendarRepeatList&CalendatItemGUID=" + calEventid,function(data){


 
var content = "<div><p>This item belongs to a calendar repeat series. Please select delete option:</p>" +
"<p id='msgbox' class='error' style='display:none;'></p>" + 
"<p><input style='width:20px;'type='radio' name='btnRepeatDeleteMode' value='DeleteOnly'>Delete Item - only the selected item is deleted</input></p>"+
"<p><input  style='width:20px;' type='radio'  name='btnRepeatDeleteMode' value = 'DeleteFull' >Delete Full Series - all items in the series are deleted (except items occurring in the past)</input></p>"+
"<p><input  style='width:20px;' type='radio'   name='btnRepeatDeleteMode' value = 'DeleteFuture' >Delete Future Series - all future items in the series from this item onward are deleted</input><p>"+

"<p id='RepeatItemList' style='height:100px;overflow:scroll;width:200px;'>" + data +  "</p>"  +

"<p><input type='button' value='Confirm' onclick = 'CalendarItemDelete(\"" + calEventid + "\", null);' /> &nbsp;&nbsp;"+
"<input type='button' value= 'Cancel' onclick='closeFloatBox()'></input></p></div>";



floatbox("","");
$("#heading").html("Delete Calendar Item/Series");
$("#floatboxcontent").html(content);

});

}

function LangingPageloadSectionHtml(object)
{
     reload();
     return
     var ObjectRecord = $("#ContentItemSelected" + object).val().split(':');

     var F1 = "";
     var F2 = "";
     $(ObjectRecord).each(function () {

           F1 += "'" + this.split('#')[0] + "',";
           F2 += "'" + this.split('#')[1] + "',";

     });

     F1 = F1.substring(0, F1.length - 1);
     F2 = F2.substring(0, F2.length - 1);

    var path = "pagenoheader.aspx?t=WebHome&p=" +  $("#FormTabGUID" + object).val() +
        "&o=" + $("#objectsaveeditorform input[name='objectguid']").val() +"&r=" + $("#objectsaveeditorform input[name='RowGUID']").val() +
        "&f1=" + F1 + "&f2=" + F2;
       
     $.get(path,function(data){
           
          //$("#" + object + " div.rhs_widget").html("");
          //alert($("#" + object + " div.rhs_widget").html());
          
        $("#" + object + " div.rhs_widget").html($(data).find('div#rhs').html());	
        	   
        //alert($("#" + object + " div.rhs_widget").html());
        //ReadMore(data,"#HelpDescrip");
    });
}


function addWidget(object)
{
    
    var path = 'action.aspx?action=AddWidget&RowGUID=' + object;
      $.get(path,function(data){
      if(data == "done")
        $("#bot_" + object).parent().parent().slideUp(function () {
                                $(this).remove();
        });
      //$("#bot_" + object).val("remove");  
      });
}

function removeWidget(object)
{
    

    var path = 'action.aspx?action=RemoveWidget&RowGUID=' + object;
      $.get(path,function(data){
      if(data == "done")
      $("#bot_" + object).parent().parent().slideUp(function () {
                                $(this).remove();
        });
      //$("#bot_" + object).val("add");
      });
}

 $(document).ready(function () {

 $("#navigation li.TTnavLink").each(
 function () {
       if($(this).children().find("ul:first").children().length < 7)
       {
    
         var textlength = (($(this).children().find("ul:first").children().find("a").text().length - $(this).children().find("ul:first").children().children().find("a").text().length ) + ($(this).children().find("ul:first").children().length * 10 )) * 3;
          var position =  $(this).offset().left / 900 * 700 - textlength;
        if(position > 0)
         {
         //$(this).css('background-color', 'red');
            $(this).children().find("ul:first").prepend("<li><a name='" + textlength + " : " + position + "' style='padding-left:" + position + "px;'></a></li>");
         }
       }
  } 
 );
 
 $("#navigation li.highlight div.TTlevel2 li").each(
 function () {
       
       if($(this).find("ul.TTlevel3").children().length < 7 && $(this).find("ul.TTlevel3").children().length > 0 && $(this).find("ul.TTlevel3 div table").children().length <= 0)
       {
            
         var textlength = (($(this).find("ul.TTlevel3").children().find("a").text().length - $(this).find("ul.TTlevel3").children().children().find("a").text().length ) + ($(this).find("ul.TTlevel3").children().length * 10 )) * 3;
          var position =  ($(this).offset().left / 1180 * 900) - textlength;
        if(position > 0)
         {
           // $(this).css('background-color', 'red');
            $(this).find("ul.TTlevel3").prepend("<li><a name='" + textlength + " : " + position + " : " + $(this).offset().left + " : " + $(this).find("ul.TTlevel3").children().children().find("a").text().length + "' style='padding-left:" + position + "px;'></a></li>");
         }
       }
  } 
 );


 $("#navigation li:not(.highlight) div.TTlevel2 li").hover(
 function () {
       if($(this).find("ul.TTlevel3").children().length < 7 && $(this).find("ul.TTlevel3").children().length > 0  && $(this).find("ul.TTlevel3 div table").children().length <= 0)
       {
            
         var textlength = (($(this).find("ul.TTlevel3").children().find("a").text().length - $(this).find("ul.TTlevel3").children().children().find("a").text().length ) + ($(this).find("ul.TTlevel3").children().length * 10 )) * 3;
          var position =  ($(this).offset().left / 1180 * 900) - textlength;
        if(position > 0)
         {
           // $(this).css('background-color', 'red');
            $(this).find("ul.TTlevel3").prepend("<li class='AUadd'><a name='" + textlength + " : " + position + " : " + $(this).offset().left + " : " + $(this).find("ul.TTlevel3").children().children().find("a").text().length + "' style='padding-left:" + position + "px;'></a></li>");
         }
       }
  } ,
  function () {
     $(this).find("li.AUadd").remove();
  }
 );


 $("#navigation li div.TTlevel2 li ul.TTlevel3 li").hover(
 function () {
       if($(this).find("ul.TTlevel4").children().length < 7 && $(this).find("ul.TTlevel4").children().length > 0)
       {
            
         var textlength = (($(this).find("ul.TTlevel4").children().find("a").text().length - $(this).find("ul.TTlevel4").children().children().find("a").text().length ) + ($(this).find("ul.TTlevel4").children().length * 10 )) * 3;
          var position =  ($(this).offset().left / 1180 * 900) - textlength;
        if(position > 0)
         {
           // $(this).css('background-color', 'red');
            $(this).find("ul.TTlevel4").prepend("<li class='AUadd'><a name='" + textlength + " : " + position + " : " + $(this).offset().left + " : " + $(this).find("ul.TTlevel4").children().children().find("a").text().length + "' style='padding-left:" + position + "px;'></a></li>");
         }
       }
  } ,
  function () {
     $(this).find("li.AUadd").remove();
  }
 );
 });

function GetSectionHTML(url)
{
       
     $.get(url,function(data){
           
          //$("#" + object + " div.rhs_widget").html("");
          //alert($("#" + object + " div.rhs_widget").html());

          $.floatbox( {
				content: "<p class='floatboxaction'><a id='close-floatbox' onclick='closeFloatBox(); href='javascript:void(0);'  >Confirm</a><a class='createFolderCancel' onclick='closeFloatBox();' href='javascript:void(0);'> </a></p><h3 id='heading'></h3><div id='floatboxcontent' style='overflow: scroll; width: 700px; height: 460px;'></div><ul id='floatboxaction' class='action'></ul>",
				fade: true,
				boxsize : "medium"
				,
				bg : "floatbox-backgroundWhite"
				});


				//$("#heading").html("Select the attribute.");    

				$("#floatboxcontent").html($(data).find('div#rhs').html());

                $("#floatboxcontent").scroll();
          
        //$("#" + object + " div.rhs_widget").html($(data).find('div#rhs').html());	
        	   
        //alert($("#" + object + " div.rhs_widget").html());
        //ReadMore(data,"#HelpDescrip");
    });
}


function AddBookmark()
{
    $("a.bookmark img").css('border','2px solid #f11');
    //$("a.bookmark").addClass("bookmarked");
    //alert($("a.bookmark").html());

                     
  $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small",
        bg : "floatbox-backgroundWhite"
    });
    
    $("#heading").html("Processing your request, please wait");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    

    var path = 'action.aspx?action=AddBookmark';
    var pt = $("h1.sectionheading span").html();
    var lo = window.location + "";
      $.get(path,{location:lo,PageTitle:pt },function(data){
      
                  closeFloatBox();
      });

     
    
}

function RemoveBookmark(object)
{   
    var path = 'action.aspx?action=RemoveBookmark';

      $.get(path,{RowGUID:object},function(data){
      
      $("#" + object).slideUp(function () {
                                $(this).remove();
        });
      });
}

function EditBookMark(object)
{   
    var bm = $("#EditV_" + object).val();
    //var bmo = $("#Desc_" + object + " a").html();

    if(bm.length == 0)
    {
      bm = $("#Desc_" + object + " a").html();
    }
    

    var path = 'action.aspx?action=EditBookMark';

      $.get(path,{RowGUID:object,PageTitle:bm},function(data){
      
      $("#Desc_" + object + " a").html(bm);
      $("#Desc_" + object).show();
      $("#EditS_" + object).next().show();
      $("#EditS_" + object).hide();
      $("#Edit_" + object).hide();

      //$("#Edit_" + object).slideUp(function () {
                                //$(this).hide();
                                
       // });
      });
}

function MarkPortfolio(isconfirm,heading) {

            $.get("action.aspx?action=MarkPortfolio&" + document.location.search.replace("?","") + "&isconfirm=" + isconfirm ,function(data){ 
                if(isconfirm == "1") {  
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                }
                else {
             floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='javascript:MarkPortfolio(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }
            });
        
}

function ClearMarkPortfolio(isconfirm,heading) {

            $.get("action.aspx?action=ClearMarkPortfolio&" + document.location.search.replace("?","") + "&isconfirm=" + isconfirm ,function(data){ 
                if(isconfirm == "1") {
                    $("#floatboxcontent").html($(data).find("Display").text());
                    $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
                }
                else {
                     floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='javascript:ClearMarkPortfolio(1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }
            });
        
}

function MarkTag(isconfirm,heading,url,id) {
 $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small",
        bg : "floatbox-backgroundWhite"
    });
    
    $("#heading").html("Processing your request, please wait");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    
            $.get("action.aspx?action=MarkPortfolio&" + url + "&isconfirm=1",function(data){ 
               /* if(isconfirm == "1") {  
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href='javascript:void(0);' onclick=\"AfterMarkTag('" + heading + "','"+ url +"','" + id + "','[Remove Tag Item]');\">OK</a></li>");
                }
                else {
             floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href=\"javascript:MarkTag(1,'" + heading + "','"+ url +"','" + id + "');\">Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }*/
                AfterMarkTag(heading, url , id ,'[Remove Tag]');
            });
        
}

function ClearMarkTag(isconfirm,heading,url,id) {
 $.floatbox( {
        content: "<h3 id='heading'></h3><div id='floatboxcontent'></div><ul id='floatboxaction' class='action'></ul>",
        fade: true,
        boxsize : "small",
        bg : "floatbox-backgroundWhite"
    });
    
    $("#heading").html("Processing your request, please wait");    
    $("#floatboxcontent").html("<div id='loading'><img src='../common/images/loading.gif' alt='loading..' /><div>");
    
            $.get("action.aspx?action=ClearMarkPortfolio&" + url + "&isconfirm=1",function(data){ 
               /* if(isconfirm == "1") {
                    $("#floatboxcontent").html($(data).find("Display").text());
                    $("#floatboxaction").html("<li><a href='javascript:void(0);' onclick=\"AfterMarkTag('" + heading + "','"+ url +"','" + id + "','[Tag Item]');\">OK</a></li>");
                }
                else {
                     floatbox("small","");
            $("#heading").html(heading);    
            $("#floatboxcontent").html($(data).find("Display").text());
            $("#floatboxaction").html("<li><a href=\"javascript:ClearMarkTag(1,'" + heading + "','"+ url +"','" + id + "');\">Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                }
                */
                AfterMarkTag(heading, url , id ,'[Tag Item]');
            });
        
}
function AfterMarkTag(heading,url,id,val) {
//alert(id);
//alert(val);
//alert($("#tag_" + id).html());
$("#tag_" + id).html(val);

 var js = "";

 if(val == "[Remove Tag]")
 {
 js = "ClearMarkTag(0,'" + heading + "','"+ url +"','" + id + "');";
 $("#tag_" + id).css('color','red');
 }
 else{
 js = "MarkTag(0,'" + heading + "','"+ url +"','" + id + "');";
 $("#tag_" + id).css('color','green');
 }
 

    // create a function from the "js" string
    var newclick = new Function(js);

    // clears onclick then sets click using jQuery
    $("#tag_" + id).attr('onclick', '').click(newclick);

    closeFloatBox();
}



function MarkFileAsOffline(ListGUID,PerspectiveRecordGUID){
$.get("action.aspx?action=MarkFileAsOffline&ListGUID=" + ListGUID + "&PerspectiveRecordGUID=" + PerspectiveRecordGUID,function(data){ 
  if(data == "Error")
         {
             floatbox("");
            $("#heading").html(data);
            $("#floatboxcontent").html("<p>You must first select items in the list.</p>");
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
         }
         else{
            floatbox("");
            $("#heading").html(data);
            $("#floatboxcontent").html("<p>The selected files/documents have successfully been marked as 'offline'.</p>");
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
        }
}
);

}


function MarkFileAsOnline(PerspectiveRecordGUID){
$.get("action.aspx?action=MarkFileAsOnline&PerspectiveRecordGUID=" + PerspectiveRecordGUID,function(data){ 
        
         if(data == "Error")
         {
             floatbox("");
            $("#heading").html(data);
            $("#floatboxcontent").html("<p>You must first select items in the list.</p>");
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
         }
         else{
            floatbox("");
            $("#heading").html(data);
            $("#floatboxcontent").html("<p>The selected files/documents have successfully been marked as 'online'.</p>");
            $("#floatboxaction").html("<li><a href='' onclick='reload();'>OK</a></li>");
        }
}
);

}

/* 22/11/2011: Added, extended with 'action' (vs tis) */
function QuickAdd(Object, Record, action,showMessage,Confirm){
    
    closeFloatBox();
        if(showMessage != null)       
        {
            $.get("action.aspx?action=QuickAddRemoveItem&ObjectGUID=" + Object +  "&RecordGUID=" + Record + "&a=" + action + "&showMessage=" + showMessage + "&Confirm=" + Confirm , function (data){                       
               
               if (data != null) {
                        var Message = $(data).find("Message").text();
                        
                        
				            floatbox("small","");
                            $("#heading").html("");
                            $("#floatboxcontent").html("<p>" + Message + "</p>");
                            
                            if($(data).find("Comfirm").text()== 'False')
                            {     
                                $("#floatboxaction").html("<li><a href='javascript:closeFloatBox(); QuickAdd(\"" + Object + "\",\"" + Record + "\", \"" + action + "\"," + showMessage + " ,0);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                            }
                            else{
                            $("#floatboxaction").html("<li><a href='javascript:reload();'>OK</a></li>");
                            }
                        
                        }
            });
        }
        else
        {
        $.get("action.aspx?action=QuickAddRemoveItem&ObjectGUID=" + Object + "&RecordGUID=" + Record + "&a=" + action, function (data){                       
           reload();
        });
        }


}

/* 22/11/2011: Added, extended with 'action' (vs tis) */
function QuickRemove(Object,Record, action,showMessage,Confirm){

closeFloatBox();

       if(showMessage != null)       
        {
            $.get("action.aspx?action=QuickAddRemoveItem&ObjectGUID=" + Object +  "&RecordGUID=" + Record + "&a=" + action + "&showMessage=" + showMessage + "&Confirm=" + Confirm , function (data){                       
               
               if (data != null) {
                        var Message = $(data).find("Message").text();
                        
                        
				            floatbox("small","");
                            $("#heading").html("");
                            $("#floatboxcontent").html("<p>" + Message + "</p>");
                            if($(data).find("Confirm").text()== '0')
                            {     
                                $("#floatboxaction").html("<li><a href='javascript:QuickAdd(\"" + Object + "\",\"" + Record + "\", \"" + action + "\"," + showMessage + " ,1);'>Confirm</a></li> <li><a href='javascript:closeFloatBox()'>Cancel</a></li>");
                            }
                            else{
                            $("#floatboxaction").html("<li><a href='javascript:reload();'>OK</a></li>");
                            }
                        
                        }
            });
        }
        else
        {
        $.get("action.aspx?action=QuickAddRemoveItem&ObjectGUID=" + Object + "&RecordGUID=" + Record + "&a=" + action, function (data){                       
           reload();
        });
        }
}

/* 22/11/2011: Added - clears UserSelection table to ensure no selection is available when popping up selection forms */
function ClearUserSelection(){
    
        $.get("action.aspx?action=ClearUserSelection" ,function (data){                       
         
        });


}




