// JavaScript Document
//============================obsługa stron statycznych================================
var scripts = new Scripts(reviewCallback);

//============================obsługa programu================================
function showscripts(ord, ser, ret){
	if (action != scripts_action){
		action = scripts_action;
		resetvariables();
	}
	else {
		order = ord;
		search_ = ser;
	}
	action = scripts_action;
	showloading();
	scripts.showscripts(order, search_, ret);
}
function standard_scripts_perform(result){
	hideloading();
	if (result == '0') showscripts(order, search_);
	else alertmsg(result);
}
function showscripts_find(){
	showscripts(order, $('search_us').value);
}
function addscript(ret){
	showloading();
	scripts.addscript(ret);
}
function doaddscript(form){
	if (check_script()){
		showloading();
		scripts.doaddscript(getPayload(form));
	}
}
function lockscript(id){
	showloading();
	scripts.lockscript(id);
}
function unlockscript(id){
	showloading();
	scripts.unlockscript(id);
}
function editscript(id, ret){
	showloading();
	scripts.editscript(id, ret);
}
function doeditscript(form){
	if (check_script()){
		showloading();
		scripts.doeditscript(getPayload(form));
	}
}
function remscript(id){
	var answer = confirm("Na pewno chcesz usunąć skrypt?");
	if (answer){
		showloading();
		scripts.remscript(id);
	}
}
function check_script(){
	if ($('name').value == ''){
		alertmsg('Podaj nazwę skryptu');
		$('name').focus();
		return false;
	}
	return true;
}
