
function onContextMenuClicking(sender, args)
{
	
	
	sender.hide();
	var value = args.get_item().get_value();
	var position = sender.get_attributes().getAttribute('PG_Position');
	var patientId = sender.get_attributes().getAttribute('PG_PatientId');
	if(value == "EditPatient")
	{
	  
	    var queryString = "?Mode=E&PatientId=" + patientId + "&Position=" + position;
		var result = window.radopen("/PatientEditor.aspx" + queryString, null);		
		//Mode=E&PatientId=asdasdasd&Position=3 -- Add after before
		result.set_clientCallBackFunction(PatientCallbackFunction);
		result.SetWidth(900);
		result.SetHeight(700);	
		result.Center();	
		args.set_cancel(true);	
		return;
	}  
	
	if(value == "AddPatientBefore")
	{
	    var p = parseInt(position) - 1;
		var queryString = "?Mode=N&PatientId=" + patientId + "&Position=" + p;
		var result = window.radopen("/PatientEditor.aspx" + queryString, null);	
		
		//Mode=N&PatientId=asdasdasd&Position=3 -- Add after before
		
		result.set_clientCallBackFunction(PatientCallbackFunction);
		result.SetWidth(900);
		result.SetHeight(700);	
		
		result.Center();	
		args.set_cancel(true);	
		return;
	}  
	
	if(value == "AddPatientAfter")
	{
	    var p = parseInt(position) + 1;
	    var MySetting = "center:yes;dialogWidth:1040px;dialogHeight:700px;status:yes;scroll:0;help:no";											
		var queryString = "?Mode=N&PatientId=" + patientId + "&Position=" + p;
		var result = window.radopen("/PatientEditor.aspx" + queryString, null);	
		
		//Mode=N&PatientId=asdasdasd&Position=3 -- Add after before
		
		result.set_clientCallBackFunction(PatientCallbackFunction);
		result.SetWidth(900);
		result.SetHeight(700);		
		result.Center();	
		args.set_cancel(true);	
		return;
	} 
	 
	if(value == "MoveTo")
	{
	    var MySetting = "center:yes;dialogWidth:500px;dialogHeight:400px;status:yes;scroll:0;help:no";
	    var queryString = "?PatientId=" + patientId + "&Position=" + position;
		var result = window.radopen("/PatientMove.aspx" + queryString, null);		
		//Mode=E&PatientId=asdasdasd&Position=3 -- Add after before
		result.set_clientCallBackFunction(patientMoveCallbackFunction);
		result.SetWidth(500);
		result.SetHeight(400);	
		result.Center();	
		args.set_cancel(true);	
		return;
	}
	
	if(value == "Delete")
	{
	    if(confirm("Are you sure you want to delete this patient?"))
	    {
		    args.set_cancel(false);	
        }
        else
        {
            args.set_cancel(true);
        }
	}
}

var PatientCallbackFunction = function(sender, args)
{           
    if(args)
    {
        //window.document.location.href=args;
        window.location.reload();
    }
           
}   


var patientMoveCallbackFunction = function(sender, args)
{
    //debugger;
    if(args && args == "reload")
    {
        window.location.reload();
    }
}





function onContextMenuClicking2(sender, args)
{
	
	
	sender.hide();
	var value = args.get_item().get_value();
	var position = sender.get_attributes().getAttribute('PG_Position');
	var patientId = sender.get_attributes().getAttribute('PG_PatientId');
	if(value == "EditPatient")
	{
	  
	    var queryString = "?Mode=E&PatientId=" + patientId + "&Position=" + position;
		var result = window.radopen("/PatientEditor2.aspx" + queryString, null);		
		//Mode=E&PatientId=asdasdasd&Position=3 -- Add after before
		result.set_clientCallBackFunction(PatientCallbackFunction);
		result.SetWidth(900);
		result.SetHeight(700);	
		result.Center();	
		args.set_cancel(true);	
		return;
	}  
	
	if(value == "AddPatientBefore")
	{
	    var p = parseInt(position) - 1;
		var queryString = "?Mode=N&PatientId=" + patientId + "&Position=" + p;
		var result = window.radopen("/PatientEditor2.aspx" + queryString, null);	
		
		//Mode=N&PatientId=asdasdasd&Position=3 -- Add after before
		
		result.set_clientCallBackFunction(PatientCallbackFunction);
		result.SetWidth(900);
		result.SetHeight(700);	
		
		result.Center();	
		args.set_cancel(true);	
		return;
	}  
	
	if(value == "AddPatientAfter")
	{
	    var p = parseInt(position) + 1;
	    var MySetting = "center:yes;dialogWidth:1040px;dialogHeight:700px;status:yes;scroll:0;help:no";											
		var queryString = "?Mode=N&PatientId=" + patientId + "&Position=" + p;
		var result = window.radopen("/PatientEditor2.aspx" + queryString, null);	
		
		//Mode=N&PatientId=asdasdasd&Position=3 -- Add after before
		
		result.set_clientCallBackFunction(PatientCallbackFunction);
		result.SetWidth(900);
		result.SetHeight(700);		
		result.Center();	
		args.set_cancel(true);	
		return;
	} 
	 
	if(value == "MoveTo")
	{
	    var MySetting = "center:yes;dialogWidth:500px;dialogHeight:400px;status:yes;scroll:0;help:no";
	    var queryString = "?PatientId=" + patientId + "&Position=" + position;
		var result = window.radopen("/PatientMove2.aspx" + queryString, null);		
		//Mode=E&PatientId=asdasdasd&Position=3 -- Add after before
		result.set_clientCallBackFunction(patientMoveCallbackFunction);
		result.SetWidth(500);
		result.SetHeight(400);	
		result.Center();	
		args.set_cancel(true);	
		return;
	}
	
	if(value == "Delete")
	{
	    if(confirm("Are you sure you want to delete this patient?"))
	    {
		    args.set_cancel(false);	
        }
        else
        {
            args.set_cancel(true);
        }
	}
}

var PatientCallbackFunction = function(sender, args)
{           
    if(args)
    {
        //window.document.location.href=args;
        window.location.reload();
    }
           
}   


var patientMoveCallbackFunction = function(sender, args)
{
    //debugger;
    if(args && args == "reload")
    {
        window.location.reload();
    }
}
