function sortdata(file,OrderBy,OrderType,FieldName,Keyword,FieldType)
{
	window.location="index.php?view="+file+"&OrderBy="+OrderBy+"&OrderType="+OrderType+"&act=sort_data&FieldName="+FieldName+"&Keyword="+Keyword+"&FieldType="+FieldType;
}
function check_all(Form_Obj,eventgiver)
{
		var ellen=Form_Obj.elements.length;
		if(eventgiver.checked==true)
		{
			for(var i=1;i<ellen;i++)
			{
				if(Form_Obj.elements[i].name=="del[]")
				Form_Obj.elements[i].checked=true;
			}
		}
		else if(eventgiver.checked==false)
		{
			for(var i=1;i<ellen;i++)
			{
				if(Form_Obj.elements[i].name=="del[]")
				Form_Obj.elements[i].checked=false;
			}
		}
}
// --------------- Confirm Delete alert Message ------------------
function confirmDel(formname,ID,Process,act,file)
{
alert(formname);
	if(Process=="DELETE")
		{
			
			if(confirm("Do you really want to delete?"))
			{
				document.getElementById(formname.name).ID.value=ID;
				document.getElementById(formname.name).act.value=act;				
				document.getElementById(formname.name).action  ="index.php?view="+file;				
				document.getElementById(formname.name).submit();
				return true;
			}
			else{				
				return false;
			}
		}
		else
		{
			var ellen=document.getElementById(formname.name).elements.length;
			var count=0;
			for(var i=1;i<ellen;i++)
			{
				if(document.getElementById(formname.name).elements[i].name=="del[]")
				{
					 if(document.getElementById(formname.name).elements[i].checked==true)
						count=count+1;
				}
			}
				if(count==0)
				{
					alert("Please Select Record To Delete");
					return false;
				}
				else
				{
					if(confirm("Do you really want to delete?"))
					{
					document.getElementById(formname.name).ID.value=ID;
					document.getElementById(formname.name).act.value=act;
					document.getElementById(formname.name).action  = "index.php?view="+file;
					document.getElementById(formname.name).submit();
						return true;
					}
					else
						return false;
				}
	}
}
//--- Edit Page for The  Record -----
function edit(formname,id,file)
{
	document.getElementById(formname.name).ID.value=id;
	document.getElementById(formname.name).MODE.value="UPDATE";
	document.getElementById(formname.name).action='index.php?view='+file;
	document.getElementById(formname.name).submit();
}


//--- Add Page For The Record -----
function add(formname,file)
{
	document.getElementById(formname.name).MODE.value="ADD";
	document.getElementById(formname.name).action='index.php?view='+file;
	document.getElementById(formname.name).submit();
}

//--- Go Back To File -----
function goback(file)
{
	window.location="index.php?view="+file;
}
//--- Go To Detail Page -----
function godetail(formname,file,user_id)
{
	document.getElementById(formname.name).action='index.php?view='+file;
	document.getElementById(formname.name).user_id.value=user_id;
	document.getElementById(formname.name).submit();
}

/*================== Get Practitioner List for Exercise Add Edit Page ==================*/
function get_practitioner(c_id, cmb){
	   new ajax ('ajax.php', {postBody: 'method=get_practitioner&cid='+c_id, onComplete: get_practitioner_callback, userVariable:cmb });
	}

function get_practitioner_callback(request, uservar){	
	combo = uservar;
	var clen=combo.options.length;
	for(i=0; i< clen ; i++){
		combo.options[0] = null;
	}
	if(request.responseText!=""){
		arrTmp = request.responseText.split("^");
		for(i=0; i<arrTmp.length; i++){
			arrOption = arrTmp[i].split("|");
			var opt = new Option();
			opt.value = arrOption[0];
			opt.text = arrOption[1];
			combo.options[combo.options.length] = opt;
		}
	}else{
		for(i=0; i<combo.options.length; i++){
			combo.options[0] = null;
		}
	}
}
function confirmDel1(ID,Process,act,file)
{		
	if(confirm("Do you really want to delete?"))
	{					
		window.location.href  ="index.php?view="+file+"&ID="+ID+"&act="+act;								
		return true;
	}
	else{				
		return false;
	}
		
}

/*================== Play Exercise Videos ==================*/
function popup_videoplayer(video_id){
	var popwindow = window.open('index.php?view=playvideo&id='+video_id,'VideoPlayer','width=400,height=300,status=0,address=0,resize=1');
	if(!popwindow){
		alert("Your POP UP Blocker blocked the video player\n\nPlease disable any POP UP Blocker,\nor hold down CNTRL key while clicking on button/link");
	}
}
