// JavaScript Document
function createClient() {
/*
	if($("id_client_name").value == "") {
			alert("Client Name is required");
			return false;
		}
*/
   var success = true;
	if(success == true) {
		var url = base_path+"/control.php?action=create_client"
	//	Fader.showWaiting("Please wait....");
		new Ajax.Request(url,{method:'post',
					onSuccess: function(transport){
					var response = transport.responseText.split("::");	
						if(response[0]=="ok") {
							$("notice").style.visibility = "visible";
							$("notice").innerHTML = response[1];
							new Effect.Highlight('notice',{duration:1.5});
							$("list_container").innerHTML = response[2];
							
						}	
						
						else if(response[0]=="error") {
							$("notice").style.visibility = "visible";
							$("notice").innerHTML = response[1];
							new Effect.Highlight('notice',{duration:1.5});
					
						}
						
						else {
							alert(transport.responseText);
							}
				},
					onFailure: function(){ 
					alert("System Error!");
				}, 
				parameters: $('create_client_form').serialize(true)
			}
		);
//		Fader.hideWaiting("Please wait....");		
	}
}



function updateClient(id) {
   var success = true;
	if(success == true) {
		var url = base_path+"/control.php?action=update_client&id="+id;
	//	Fader.showWaiting("Please wait....");
		new Ajax.Request(url,{method:'post',
					onSuccess: function(transport){
					var response = transport.responseText.split("::");	
						if(response[0]=="ok") {
							$("notice").style.visibility = "visible";
							$("notice").innerHTML = response[1];
							new Effect.Highlight('notice',{duration:1.5});
							$("list_container").innerHTML = response[2];							
						}	
						
						else if(response[0]=="error") {
							$("notice").style.visibility = "visible";
							$("notice").innerHTML = response[1];
							new Effect.Highlight('notice',{duration:1.5});
					
						}
						
						else {
							alert(transport.responseText);
							}
				},
					onFailure: function(){ 
					alert("System Error!");
				}, 
				parameters: $('edit_client_form').serialize(true)
			}
		);
//		Fader.hideWaiting("Please wait....");		
	}
}

function deleteClient(id) {
	if(confirm("Are you sure you want to continue?")) {
		var url = base_path+"/control.php?action=delete_clients&id="+id;
	//	Fader.showWaiting("Please wait....");
		new Ajax.Request(url,{method:'post',
					onSuccess: function(transport){
					var response = transport.responseText.split("::");	
						if(response[0]=="ok") {
							$("notice").style.visibility = "visible";
							$("notice").innerHTML = response[1];
							new Effect.Highlight('notice',{duration:1.5});
							$("list_container").innerHTML = response[2];
						}  else {
							alert(transport.responseText);
							}
				},
					onFailure: function(){ 
					alert("System Error!");
				}
			}
		);
//		Fader.hideWaiting("Please wait....");		
	}
}


function deleteFile(id, fid, t) {
	if(confirm("Are you sure you want to continue?")) {
		var url = base_path+"/control.php?action=delete_file&id="+id+"&fid="+fid+"&t="+t;
	//	Fader.showWaiting("Please wait....");
		new Ajax.Request(url,{method:'post',
					onSuccess: function(transport){
					var response = transport.responseText.split("::");	
						if(response[0]=="ok") {
							$("notice").style.visibility = "visible";
							$("notice").innerHTML = response[1];
							new Effect.Highlight('notice',{duration:1.5});
							$("filelist").innerHTML = response[2];
						}  else {
							alert(transport.responseText);
							}
				},
					onFailure: function(){ 
					alert("System Error!");
				}
			}
		);
//		Fader.hideWaiting("Please wait....");		
	}
}


function toggleBlindClient(id1, id2){
	if($(id1).style.display == "none"){
		new Effect.BlindDown(id1);
		new Effect.BlindUp(id2);
	}
}

function toggleBlindProject(id1, id2, id3, id4){
	if($(id1).style.display == "none"){
		new Effect.BlindDown(id1);
		new Effect.BlindUp(id2);
		new Effect.BlindUp(id3);
		new Effect.BlindUp(id4);
	}
}

function toggleBlindMyProject(id1, id2, id3, id4){
	if($(id1).style.display == "none"){
		new Effect.BlindDown(id1);
		new Effect.BlindUp(id2);
		new Effect.BlindUp(id3);
		new Effect.BlindUp(id4);
	}
}


function toggleBlindUser(id1, id2){
	if($(id1).style.display == "none"){
		new Effect.BlindDown(id1);
		new Effect.BlindUp(id2);
}
	else{
		new Effect.BlindUp(id1);
	}
}
