function ProgramTransfer(info) {
	var iWidth = 450; var iHeight = 300;

	var result = window.showModalDialog("/Meetings/ProgramTransfer.aspx?info=" + info, "Transfer", "dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;center:yes;scroll:no;status:no");
	if (result) __doPostBack('UpdateDisplay');	
}

function Trim(string) {
	return string.replace(/(^\s*)|(\s*$)/g, "")
}

function OpenPersonProfile(id,type,tab) {
	var profilePath = "/Common/PersonProfile.aspx?id=" + id + "&type=" + type;
	if (tab) profilePath += "&tab=" + tab;
	var windowName = "PersonProfile";
	
	if (window.name == windowName) {
		parent.document.location.href = profilePath;
	}else {
		var iWidth = 775; var iHeight = 500;
		var iLeftPos = (screen.width) ? (screen.width-iWidth)/5 : 0;
		var iTopPos = (screen.height) ? (screen.height-iHeight)/4 : 0;
		
		newWindow = window.open(profilePath, windowName, "top=" + iTopPos + ",left=" + iLeftPos + ",toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,height=" + iHeight + ",width=" + iWidth)
		newWindow.focus()
	}
}

function OpenVenueProfile(id) {
    var profilePath = "/Common/VenueProfilePage.aspx?globalId=" + id;
    var windowName = "VenueProfile";

    if (window.name == windowName) {
        parent.document.location.href = profilePath;
    }
    else {
        var iWidth = 650; var iHeight = 720;
        var iLeftPos = (screen.width) ? (screen.width - iWidth) / 5 : 0;
        var iTopPos = (screen.height) ? (screen.height - iHeight) / 4 : 0;

        newWindow = window.open(profilePath, windowName, "top=" + iTopPos + ",left=" + iLeftPos + ",toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,height=" + iHeight + ",width=" + iWidth)
        newWindow.focus()
    }
}

function OpenMeetingProfile(id,step) 
{
	var profilePath = "/Common/MeetingProfile.aspx?id=" + id;
	var windowName = "MeetingProfile";
	
	if(step!=null && step!='')
		profilePath = profilePath + "&step=" + step;
	
	if (window.name == windowName)
	{
		parent.document.location.href = profilePath;
	}
	else
	{
		var iWidth = 900; var iHeight = 500;
		var iLeftPos = (screen.width) ? (screen.width-iWidth)/1.5 : 0;
		var iTopPos = (screen.height) ? (screen.height-iHeight)/4 : 0;
		
		newWindow = window.open(profilePath, windowName, "top=" + iTopPos + ",left=" + iLeftPos + ",toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,height=" + iHeight + ",width=" + iWidth)
		newWindow.focus()
	}
}

function ViewDay(param) {
	var iWidth = 500; var iHeight = 500;
	var iLeftPos = (screen.width) ? (screen.width-iWidth)/2 : 0;
	var iTopPos = (screen.height) ? (screen.height-iHeight)/3 : 0;

	if (!param) param = "";
		
	newWindow = window.open("/Meetings/CalendarDay.aspx?params=" + param, "MonthDay", "top=" + iTopPos + ",left=" + iLeftPos + ",toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,height=" + iHeight + ",width=" + iWidth)
	newWindow.focus()
}

function MergeDocument() {
	var iWidth = 775; var iHeight = 500;
	var iLeftPos = (screen.width) ? (screen.width-iWidth)/1.5 : 0;
	var iTopPos = (screen.height) ? (screen.height-iHeight)/4 : 0;
	
	newWindow = window.open("/Common/DocMergeServices/MSWord.aspx", "MergeDoc", "top=" + iTopPos + ",left=" + iLeftPos + ",toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,height=" + iHeight + ",width=" + iWidth)
	newWindow.focus();
}

function DisplayNote(id) {
	var div = document.getElementById(id);
	
	if (div.style.display == "")
		div.style.display = "none";
	else
		div.style.display = "";
}

function ViewChart(id, param) {
	var iWidth = 500; var iHeight = 500;
	if (!param) param = "";
	
	window.showModalDialog("/Common/Chart.aspx?id=" + id + "&params=" + param, "", "dialogHeight:500px;dialogWidth:800px;center:yes;scroll:yes;status:yes;resize:yes;");
}

function BudgetTransfer(info)
{
	var iWidth = 450; var iHeight = 275;
	var result = window.showModalDialog("/Meetings/BudgetTransfer.aspx?info=" + info, "Transfer", "dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;center:yes;scroll:no;status:no");
	if (result) __doPostBack('UpdateDisplay');	
}

function ViewRequestAttachment(rid,aid)
{
	window.location.href = "/Common/ViewFile.aspx?rid=" + rid + "&aid=" + aid
}


//makeAJAXRequest will create the request
//  detailType - The name of the key from Details.xml
//  div - The div which will contain the code retrieved from the AJAX Request
//  rowid - The rowid which will matched against the detailRow from Details.xml
//  querystring - The querystring sent to the AjaxGetDetails page.
//  a - The a tag which contains the link to the makeAJAXRequest function
//  collapsedText - The Text which will be shown in the a Tag when the div should be collapsed
//  expandedText - The Text which will be shown in the a Tag when the div should be expanded
//  divAnimation - The div which contains the Animation
function makeAJAXRequest(detailType, div, rowid, querystring, a, collapsedText, expandedText, divAnimation) { 
    
  var aTag = document.getElementById(a);

  if (aTag.innerText == collapsedText) {
    //Do the AJAX Request
      if (window.XMLHttpRequest) { // Mozilla, Safari, IE7... 
          http_request = new XMLHttpRequest(); 
      } else if (window.ActiveXObject) { // IE6 and older 
          http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
      }

      http_request.onreadystatechange = function() {
          var divTag = document.getElementById(div);

          //document.getElementById
          if (http_request.readyState == 4) {
              if (http_request.status == 200) {
                  if (divAnimation != null) {
                      divTag.innerHTML = http_request.responseText;                   
                      $(document).ready(function() {
                         // Get a reference to the container.                                                
                          var div = $("#" + divAnimation);                                               
         
                          // Toggle the slide based on its current visibility.
                          if (div.not(":visible")) {				                                        
                            div.slideToggle('slow');
                         }
                     });

                  }
                  else {
                      divTag.innerHTML = http_request.responseText;
                  }
                  aTag.innerText = expandedText;
              }
              else
              { alert('problem'); }
          }
          else {
              aTag.innerText = 'loading';
          }
      };


      http_request.open('GET', "/Common/Ajax/AjaxGetDetails.aspx?dtype=" + detailType + "&rowid=" + rowid + "&" + querystring, true); 
      http_request.send(null); 
        
      //aTag.innerText = expandedText;
  }
  else
  {
    //Undo the AJAX Request
    if (divAnimation != null)
    {
        $(document).ready(function() {

            // Get a reference to the container.
           var div = $("#" + divAnimation);
           // Toggle the slide based on its current visibility.
           if (div.is(":visible")) {           
               div.slideToggle('fast');
             }
        });

    }
    else
    {
        var divTag = document.getElementById(div);
        divTag.innerHTML = "";
    }
    aTag.innerText = collapsedText;

}
} 



function Select_Click(objRef)
{

    //Get the Row based on lick
    var row = objRef.parentNode.parentNode;
    //change color to Aqua
    row.style.backgroundColor = "aqua";
//   
//        //If not checked change back to original color

//        if(row.rowIndex % 2 == 0)

//        {

//           //Alternating Row Color

//           row.style.backgroundColor = "#C2D69B";

//        }

//        else

//        {

//           row.style.backgroundColor = "white";

//        }

//    }

    //Get the reference of GridView
    var GridView = row.parentNode;
}

function expandDIV(div, a, collapsedText, expandedText, divAnimation) {

    var aTag = document.getElementById(a);

    if (aTag.innerText == expandedText) {

        //Undo the AJAX Request
        if (divAnimation != null) {
            $(document).ready(function() {
                var div = $("#" + divAnimation);
                if (div.is(":visible")) {
                    div.slideToggle('fast');
                }
            });
        } else {
            var divTag = document.getElementById(div);
            divTag.innerHTML = "";
        }

        aTag.innerText = collapsedText;
    }
    else {


        $(document).ready(function() {
            var div = $("#" + divAnimation);
            if (div.not(":visible")) {
                div.slideToggle('slow');
            }
        });
        aTag.innerText = expandedText;
    }

}  
