// Java Document
// SEND EMAILS
function php( p_script_url ) {
      script = document.createElement( 'script' );
      script.src = p_script_url;
      document.getElementsByTagName( 'head' )[0].appendChild( script );}
function check_chislo(obj) {
	var t=obj.value;
	var l=obj.value.length;
	l--;
	if (t != Number(t)) obj.value=obj.value.substr(0,l);
		//document.getElementById().length
		}
function confirm_link (url,msg) {
	var yes=confirm(msg);
	if (yes) window.location=url;
 };
function check_email(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
   }
// JavaScript Document
 function show_system_message () {
  $("#system_messanger").animate({  top: "0px"  }, 1500 );
  $("#system_messanger").click(function()  {$("#system_messanger").animate({  top: "-170px"  }, 1500 );});
  var t=setTimeout("$('#system_messanger').animate({  top: '-170px'  }, 1500 );",3000);}
 function alert_error(title,msg) {
	 document.getElementById('system_title').innerHTML=title;
	 document.getElementById('system_msg').innerHTML=msg;
	 document.getElementById('system_img').src=CONFIG_HOST+'/images/error.png';
	 document.getElementById('system_messanger').className='system_error';
	 show_system_message();
 }
 function alert_result(title,msg) {
	 document.getElementById('system_title').innerHTML=title;
	 document.getElementById('system_msg').innerHTML=msg;
	 document.getElementById('system_img').src=CONFIG_HOST+'/images/result.png';
	 document.getElementById('system_messanger').className='system_result';
	 show_system_message();
 }
  function SaveShowOrder_all(obj,what,table) {
			var ids='';
			obj=$('#'+obj);
			obj=$(obj).find(what);
			var i=0; var id;
			while (obj[i]) {
				id=obj[i]["id"];
				ids+=id+',';
			i++;
			}
			php (CONFIG_HOST+'/js.php?action=save_sort&ids='+ids+'&table='+table);
			
		}
function delete_photo (id) {
	  $.ajax({type: "POST",
        url: CONFIG_HOST+"/ajax.php",
        data: {action: 'delete_photo',id: id},
        dataType: "json",
        success: function(data){
		if (data.status=="1") {
			$('#photo_'+id).hide();  
			alert_result('Information','The photo is deleted!');
		}
					}
			
    });	
}
function set_main (table,id,this_id) {
	  $.ajax({type: "POST",
        url: CONFIG_HOST+"/ajax.php",
        data: {action: 'set_main',id: id,table:table,this_id:this_id},
        dataType: "json",
        success: function(data){
			if (data.status=="1") alert_result('Information','The photo is now main!');
					}
			
    });	
}


