// JavaScript Document
// JavaScript Document



function show_message(html)
{
	$('body').append('<div id="dialog" align="center"></div>');
	$('#dialog').html(html);
	$('#dialog').dialog({title: "Съобщение",
						resizable: false,
						modal: false
						});

}


function change_order(id, act, page)
{
	$.ajax({
			type: "POST",
			url: page,
			data: "id="+id+"&act="+act,
			success: function(msg){
			eval(msg); 
			if(status==1) {location.reload(true);}
			 }
			});

}

function print_this()
{
	newWindow = window.open("http://обяви-оферти.com/print.php", "p_document", "status, menubar, height=500, width=750, scrollbars");
	newWindow.focus();
}

function delete_record(page, id)
{
	$("body").append('<div id="confirm_delete" align="center"></div>');
	$('#confirm_delete').html('<h3 align="center" style="color:#FF0000">ВНИМАНИЕ!</h3>Този запис ще бъде изтрит!<br><b>Наистина ли желаете това?</b>');
		
		$(function() {	
		$("#confirm_delete").dialog({
			title: "Внимание",
			resizable: false,
			modal: false,
			zIndex:10000,
			buttons: {
				'Не': function() {
				    $(this).dialog('close');
				},
				'Да': function() {
					$(this).dialog('close');
					
							$.ajax({
							   type: "POST",
							   url: page,
							   data: "id="+id,
							   success: function(msg){
							   eval(msg);
							   show_message(message)
							   if(status==1) 
									{
									 location.reload(true);
									 }
							   }
							 });
				}
			}

		});
    
	});
}


function manage_file(name, id, act)
{
		
$.ajax({
  url: self.location,
  type: "POST",
  data: 'id='+id+'&file='+name+'&act='+act,
  cache: false,
  success: function(html){
    $("#results").empty().append(html);
  }
});
}

hs.graphicsDir = 'http://' + document.domain+'/scripts/highslide/highslide/graphics/';
hs.outlineType = 'rounded-white';
hs.wrapperClassName = 'draggable-header';
hs.align = 'center';




function check_search_form()
{
	var txt = $('#search_txt').val();
	txt = $.trim(txt);
	if (txt.lenght == 0 || txt== null || txt == '') {show_message("<h3 align='center' class='wrong_message'>Въведете дума или фраза в полето за търсене<h3>"); return false;}
	return true;
}

function firm_info()
			{
				var check= $("#profile input[type='radio']:checked").val();
				if(check == 1) {$('#firm_info').css('display','none'); }
				else {$('#firm_info').css('display','block');}
			}

$(document).ready(function($){
	$("#menu_container .menu_item").hover(
		function(){
			$(this).children("ul").fadeIn(50);},
		function(){
			$(this).children("ul").fadeOut(50);
		}
	); //end hover
	
	$("#menu_container ul li").hover( 
		function(){
			var w =$(this).width();
			$(this).children("a").width(w-20);
			$(this).children("ul").css({'left': w, 'top':'0','position':'absolute'}).fadeIn(50);},
		function(){
			$(this).children("ul").fadeOut(50);
		}
	); //end hover
	
	firm_info();
	
	$(function() {
		$(".datepicker").datepicker({dateFormat:"yy-mm-dd"});
	});

}) //end document.ready

