// JavaScript Document
//change response
function bigLoader(){
	document.getElementById('result').innerHTML='<img src="javascripts/img/indicator.gif">';
	}
function preLoader(){
	document.getElementById('result').innerHTML='<img src="javascripts/img/progress.gif">';
	}
function getResponse(oReq){
	document.getElementById('result').innerHTML=oReq.responseText;
}
// tabs
function tabLoader(){
	document.getElementById('contents').innerHTML='<img src="javascripts/img/progress.gif">';
	}
function tabResponse(oReq){
	document.getElementById('contents').innerHTML=oReq.responseText;
}
function editorLoader(){
	document.getElementById('editor').innerHTML='<img src="javascripts/img/progress.gif">';
	}
function editorResponse(oReq){
	document.getElementById('editor').innerHTML=oReq.responseText;
}
//update entry
function updated(id,table,row,data){
	preLoader();
	new Ajax.Request('inc/general.php?do=update&id='+id+'&table='+table+'&row='+row+'&data='+encodeURIComponent(data),{method:'get',onComplete: getResponse});
}
//Inputs(Enable || Disable)
function editField(checked,num){
	field = "input"+num;
	if(checked==true){
	document.getElementById(field).disabled=false;
	}else{
	document.getElementById(field).disabled=true;
	}
}
//Inputs(Enable || Disable) All!
function editAll(checked,num){
	for(i=1;i<=num;i++){
		checkbox = "checkbox"+i;
		field = "input"+i;
		if(checked==true){
			document.getElementById(checkbox).checked=true;
			document.getElementById(field).disabled=false;
		}else{
			document.getElementById(checkbox).checked=false;
			document.getElementById(field).disabled=true;
		}
	}
}
function buildNews(data,row,id){
	tabLoader();
	new Ajax.Request('inc/general.php?do=buildNews&data='+encodeURIComponent(data)+'&row='+encodeURIComponent(row)+'&id='+encodeURIComponent(id),{method:'get',onComplete: tabResponse});
}
//please modify this when you reach to managing news part!
function tabData(data){
	tabLoader();
	new Ajax.Request('inc/general.php?do=content&data='+encodeURIComponent(data),{method:'get',onComplete: tabResponse});
}
function mainEditor(row,task,id){
	editorLoader();
	new Ajax.Request('maineditor.php?row='+encodeURIComponent(row)+'&task='+encodeURIComponent(task)+'&id='+encodeURIComponent(id),{method:'get',onComplete: editorResponse});
}
function mainSave(row,task,id,title,data){
	editorLoader();
	new Ajax.Request('inc/general.php?do=mainSave&row='+encodeURIComponent(row)+'&task='+encodeURIComponent(task)+'&id='+encodeURIComponent(id)+'&title='+encodeURIComponent(title)+'&data='+encodeURIComponent(data),{method:'get',onComplete: editorResponse});
}
function mainDel(id){
	editorLoader();
	new Ajax.Request('inc/general.php?do=mainDel&id='+encodeURIComponent(id),{method:'get',onComplete: editorResponse});
}
function showAmount(id){
	preLoader();
	new Ajax.Request('inc/general.php?do=showAmount&id='+id,{method:'get',onComplete: getResponse});
}

