﻿// JScript File

function ShowCollegues(pageNumber, fromCache){
	CommonShowList("Colleagues", pageNumber, fromCache);
}
function ShowCollegue(lngUserID){

	CommonShow("Colleagues", lngUserID);
}

function ShowCollegueByIndex(index){

	CommonShowByIndex("Colleagues", index);
}

function ShowCollegueData(lngUserID)
{
   var addinfo=document.getElementById("User"+lngUserID);
    if(addinfo.style.display == "none")
        addinfo.style.display = ""
    else
        addinfo.style.display = "none"
}
function ShowInviteByIndex(index){

	var paging = new Paging();
	paging.recordIndex = index;
	
    var soapData = SoapDataBuilder("InviteColleagueShare",null,paging);

    AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
}
function ShowRequestByIndex(index){

	var paging = new Paging();
	paging.recordIndex = index;
	
    var soapData = SoapDataBuilder("RequestColleagueShare",null,paging);

    AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
}

function SendMessage(){
    var	params = CustomParamBuilder(
            "emailRecipient", document.getElementById("emailRecipient").value,
			"fullname", document.getElementById("fullNameColleague").value,
			"emailBody", document.getElementById("txtAddress").value
		);
	var soapData = SoapDataBuilder("SendMassage", params);
	
	AjaxRequest("Colleagues" + ".asmx", soapData, "Colleagues" + ".xsl");
	
	 document.getElementById("lblmessage").value = "Message has been sent!";
	 pausecomp(2000);

	 ShowCollegues();
}
function SendInviteMessage(){
   
    if(document.getElementById("chkAgreed").checked)
    {
        var access;
        var accessID;
        var accessExplanation;
        //ExplanationOfAccessLevel
        if (document.getElementById("radio0") != null)
        {
            if(document.getElementById("radio0").checked){
                access = 'Remove Access';
                accessExplanation = 'Remove Access';
                accessID = "0";}
        }
        if(document.getElementById("radio1").checked){
            access = 'limited view';
            accessExplanation = 'view only the incident details but without the name of the injured person';
            accessID = "1";}
        if(document.getElementById("radio2").checked){
            access = 'full view';
            accessExplanation = 'view the full incident details including the name of the injured person';
            accessID = "2";}
        if(document.getElementById("radio3").checked){
            access = 'full edit';
            accessExplanation = 'view and change any of the details of the incident';
            accessID = "3";}
        var	params = CustomParamBuilder(
			    "emailRecipient", document.getElementById("emailRecipient").value,
			    "fullname", document.getElementById("fullNameColleague").value,
			    "access", access,
			    "ExplanationOfAccessLevel", accessExplanation,
			    "accessID", accessID,
			    "colleagueID", document.getElementById("idLngUserID").value
		    );
        var soapData = SoapDataBuilder("SendInviteMassage", params);
    	
	    AjaxRequest("Colleagues" + ".asmx", soapData, "Colleagues" + ".xsl");
	    
	    message(document.getElementById("fullNameColleague").value);
	    pausecomp(2000);

	    ShowCollegues();
	}
	
}
function message(fullName){
    document.getElementById("lblmessage").value = fullName + " has been invited!";
}
function pausecomp(millis){
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); } 
    while(curDate-date < millis);
} 

function SendRequestMessage(){
    if(document.getElementById("chkAgreed").checked)
    {
        var access;
        var accessID;
        var accessExplanation;
        if (document.getElementById("radio0") != null)
        {
            if(document.getElementById("radio0").checked){
                access = 'Remove Access';
                accessExplanation = 'Cancel Request';
                accessID = "0";}
        }
        if(document.getElementById("radio1").checked){
            access = 'limited view';
            accessID = "1"
            accessExplanation = 'view only the incident details but without the name of the injured person';
            }
        if(document.getElementById("radio2").checked){
            access = 'full view';
            accessID = "2"
            accessExplanation = 'view the full incident details including the name of the injured person';
            }
        if(document.getElementById("radio3").checked){
            access = 'full edit';
            accessID = "3"
            accessExplanation = 'view and change any of the details of the incident';}
        var	params = CustomParamBuilder(
			    "emailRecipient", document.getElementById("emailRecipient").value,
			    "fullname", document.getElementById("fullNameColleague").value,
			    "access", access,
			    "accessID", accessID,
			    "ExplanationOfAccessLevel", accessExplanation,
			    "colleagueID", document.getElementById("idLngUserID").value
		    );
        var soapData = SoapDataBuilder("SendRequestMassage", params);
    	
	    AjaxRequest("Colleagues" + ".asmx", soapData, "Colleagues" + ".xsl");
	    
	    messageRequest(document.getElementById("fullNameColleague").value);
	    pausecomp(2000);

	    ShowCollegues();
	}
}
function messageRequest(fullName){
    document.getElementById("lblmessage").value = "Your request to " + fullName + " has been sent!";
}

function InviteShow(lngUserID){
	var params = CustomParamBuilder(
			"lngUserID", lngUserID,
			"change", "0"
		);
	var soapData = SoapDataBuilder("InviteColleagueShare", params);
	
	AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
}
function InviteShowChange(lngUserID){
	
	var params = CustomParamBuilder(
			"lngUserID", lngUserID,
			"change", "1"
		);
	var soapData = SoapDataBuilder("InviteColleagueShare", params);
	
	AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
	
	
	
	//CommonInviteShow("Colleagues", lngUserID);
}

function CommonInviteShow(module, idValue) {
	
	var params = CustomParamBuilder("lngUserID", idValue);
	var soapData = SoapDataBuilder("InviteColleagueShare", params);
	
	AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
}
//RequestShowChange
function RequestShow(lngUserID){
	var params = CustomParamBuilder(
			"lngUserID", lngUserID,
			"change", "0"
		);
	var soapData = SoapDataBuilder("RequestColleagueShare", params);
	
	AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
}
function RequestShowChange(lngUserID){
	//CommonInviteShow("Colleagues", lngUserID);
	var params = CustomParamBuilder(
			"lngUserID", lngUserID,
			"change", "1"
		);
	var soapData = SoapDataBuilder("RequestColleagueShare", params);
	
	AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
}


function PageSizeChangedColleagues(objSelect) {
	if(objSelect == null) return;
	
	var strVenue = document.getElementById("strPageSize");
	var paging = new Paging();
		paging.pageSize = strVenue.value;
		paging.fromCache = true;
		var soapData = SoapDataBuilder("ShowColleaguess", null, paging);
		glbListCacheXml = AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
		if(glbIsSearchResult) {
		Search("Incident");
	}
	
}
function SortColleagues(sortColumn) {
	var paging = new Paging();
	paging.sortColumn = sortColumn;

	if(glbIsSearchResult) {
		Search("Colleagues", sortColumn);
	}
	else {
		var soapData = SoapDataBuilder("ShowColleaguess", null, paging);
		glbListCacheXml = AjaxRequest("Colleagues.asmx", soapData, "Colleagues.xsl");
	}
	
//	alert("glbIsSearchResult:" + glbIsSearchResult);	
}
function ShowForum(){

var load = window.open('http://www.sportsinjurytracker.com.au/forum.aspx','','');

}