 function ImgShw(ID, width, height, alt)
               {
    var scroll = "no";
    var top=0, left=0;
    if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
    if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
    if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
    width = Math.min(width, screen.width-10);
    height = Math.min(height, screen.height-28);
    var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
    wnd.document.write("<html><head>\n");

    wnd.document.write("<title>"+(alt == ""? "Photo":alt)+"</title></head>\n");
    wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n");
    wnd.document.write("<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\" onclick=\"javascript:window.close();\n\">");
    wnd.document.write("</body>");
    wnd.document.write("</html>");
    wnd.document.close();
}
               

function opencloselk() {
	var objlk = document.getElementById("lk");
	var ish = objlk.style.display;
	if(ish == 'none') {
		objlk.style.display = 'block';
	} else {
		objlk.style.display = 'none';	
	}
}


function toggleVisible(id) 
{
	if (obj = document.getElementById(id))
	{
		if (obj.style.display == "block")
		{
			obj.style.display = "none";
		} else
		{
			obj.style.display = "block";
		}
	}	
}

function clearSelect(id)
{
	select = document.getElementById(id);
	while (select.length>0)
	{
		select.remove(0);
	}
}


function toggleVisibleCustomCity()
{
	city = document.getElementById('citySelect');
	customcity = document.getElementById('customCityInput');
	
	if (city.value == '')
	{
		customcity.style.display = 'block';
	} else
	{
		customcity.style.display = 'none';
	}
}

function togglePassFormVisible()
{
	pf = document.getElementById('passform');
	knpko = document.getElementById('knopko');

	pf.style.display = 'block';
	knpko.style.display = 'none';
	
}

function up(id)
{
	if (obj = document.getElementById('pod'+id))
	{
		obj.style.visibility = 'visible';
	}
}

function hide(id)
{
	if (obj = document.getElementById('pod'+id))
	{
		obj.style.visibility = 'hidden';
	}
}

function OpenPage(param, w, h){
	n=window.open(param,"welcome","menubar=none, scrollbars=no, width="+w+", height="+h);
}

function show(url, w, h) {
	var s = 0;
	var n = '_blank';
	attr = 'width=' + w + ',height=' + h + ',location=0,menubar=0,resizable=0,scrollbars=' + s + ',status=0,titlebar=0,toolbar=0,hotkeys=0'
	if (parseInt(navigator.appVersion) >= 4) {
		x = (screen.width - w) / 2;
		y = (screen.height - h) / 2;
		if(x < 0) x = 0;
		if(y < 0) y = 0;
		attr += ',xposition=' + x + ',left=' + x + ',yposition=' + y + ',top=' + y;
	}
	window.open(url, n, attr);
	return false;
}

function clearavatar() {
	document.getElementById('hiddenavatar').value='';
	document.getElementById('avatarka').style.display="none";
}


    function drag_initiate() {
    
		$(function () {
		    var root = $('#carSellItems');
		    
		    /*
		    $('> *', root).each(function (index) {
		        this.id = 'item-' + index;
		    });*/
		    
		    root.sortable({
		        'update': function (event, ui) {
		            var order = $(this).sortable('serialize');
		            $.cookies.set('sortable', order);
		            
				    $.ajax({
					    url:'/ajax/carSale.php',
				        type: 'GET',
				        data: 'type=5',
				        cache: false,
				        success: function(table){
				        },
				        error: function(){
				          //  alert('ERROR');
				        } 
				    });
		        }
		    });
		    
		    var c = $.cookies.get('sortable');
		    if (c) {
		        $.each(c.split('&'), function () {
		            var id = this.replace('[]=', '-');
		            $('#' + id).appendTo(root);
		        });
		    }
		    
		});
	
    }
    
	function initDeleteButton() {
    	$('#carSellItems > li').mouseover(function(){
    		var id = '#'+$(this).attr('id') + ' > a';
			$(id).show();
	    });
    	$('#carSellItems > li').mouseout(function(){
    		var id = '#'+$(this).attr('id') + ' > a';
			$(id).hide();
	    });
	}
	