jQuery = jQuery.noConflict();
var core_url = '/index.php';

jQuery(document).ready(function(){
	jQuery("form.top_search .search").focus(function(){
		jQuery(this).css("background","#fff")
	}).blur(function(){
		if (jQuery(this).val() == '') jQuery(this).css("background","#fff url('/i/input_bg_search.gif') left center no-repeat")
	})
})

var list = {
	back: []
}


function LoadDataURL(url) {
	jQuery.ajax({
		url: core_url,
		type: 'POST',
		data: url,
		dataType : 'json',
		beforeSend: function() {
			return php.beforeSend();
		},
		success: function(data, textStatus) {
			return php.success(data, textStatus);
		},
		error: function (xmlEr, typeEr, except) {
			return php.error(xmlEr, typeEr, except);                  
		},
		complete: function (XMLHttpRequest, textStatus) {
			return php.complete(XMLHttpRequest, textStatus);
		}
	});
	return false;
}

function AutoSearchCity(input, module, op) {
    var length = input.length;
    var rep = /[/^[à-ÿ0-9]]/; 
    if (!rep.test(input) && length>=3) { 
       LoadData(op, module, input);
    } else if (!rep.test(input) && length==0) {
    	LoadDataURL('module_name='+module+'&op=view_country');
    }
}

function CommentsLoad(op, module_name, id) {
	jQuery.ajax({
		url: core_url,
		type: "POST",
		data: "module_name=comments&op="+op+"&module="+module_name+"&value="+id,
		dataType : "json",
		beforeSend: function() {
			return php.beforeSend();
		},
		success: function(data, textStatus) {
			return php.success(data, textStatus);
		},
		error: function (xmlEr, typeEr, except) {
			return php.error(xmlEr, typeEr, except);                  
		},
		complete: function (XMLHttpRequest, textStatus) {
			return php.complete(XMLHttpRequest, textStatus);
		}
	});
	return false;
}

function SaveForm() {
	jQuery('#send_comments').remove();
	jQuery('#submit_button_message').click();
	jQuery('#is_save').val(1);
	jQuery('#submit_button_message').click();
}

function LoadForm(form) {
	jQuery.ajax({
		url: core_url,
		type: "POST",
		data: jQuery('#'+form).formToArray(true),
		enctype: "multipart/form-data",
		dataType : "json",
		beforeSend: function() {
			return php.beforeSend();
		},
		success: function(data, textStatus) {
			return php.success(data, textStatus);
		},
		error: function (xmlEr, typeEr, except) {
			return php.error(xmlEr, typeEr, except);                  
		},
		complete: function (XMLHttpRequest, textStatus) {
			return php.complete(XMLHttpRequest, textStatus);
		}
	});
	return false;
}

function LoadData(op, module_name, value) {
	jQuery.ajax({
		url: core_url,
		type: "POST",
		data: "op=" + op + "&module_name=" + module_name + "&value=" + value,
		dataType : "json",
		beforeSend: function() {
			return php.beforeSend();
		},
		success: function(data, textStatus) {
			return php.success(data, textStatus);
		},
		error: function (xmlEr, typeEr, except) {
			return php.error(xmlEr, typeEr, except);                  
		},
		complete: function (XMLHttpRequest, textStatus) {
			return php.complete(XMLHttpRequest, textStatus);
		}
	});
	return false;
}
function sendJson() {
	return php.beforeSend();
}

function successJson(data, status) { 
	return php.success(data, status);
}

function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}
