
var clicked = 0;
var url = window.location.href;
if ( url.match(/\?s=[^\&]+/) ) {
	var clicked2 = 1;
} else {
	var clicked2 = 0;
}

function ClearSearch(it){
	if (clicked2 == 0) {
		it.value = '';
		clicked2 = 1;
	}
	return true;
}

function addToCompare(id) {
	var form = document.getElementById('compareForm');
	var inp = document.getElementById('compareId');
	var act = document.getElementById('compareAction');
	inp.value = id;
	act.value = 'add';
	form.submit();
	return false;
}

function purgeCompare() {
	var form = document.getElementById('compareForm');
	var act = document.getElementById('compareAction');
	act.value = 'purge';
	form.submit();
	return false;
}

function removeFromCompare(id) {
	var form = document.getElementById('compareForm');
	var inp = document.getElementById('compareId');
	var act = document.getElementById('compareAction');
	inp.value = id;
	act.value = 'remove';
	form.submit();
	return false;
}
$(document).ready(function() {

    $('#icqbl .arr').css('top',$('#icqb').offset().top-$('#icqbl').offset().top+4);

    $('#icqb').click(function(){    
        ans = jQuery.ajax({
            type: 'GET',
            url: __WWWHOST+'one.php',
            data: {
                __one_b: 'IcqContacts',
                __one_a: 'Header'
            },
            dataType: 'html',
            success: function(data) {
                var ib = $('#icqbl');
                ib.hide();
                ib.css('visibility','visible');
                ib.html(data);
                ib.fadeIn(400);
                $('#icqbl .close').click(function(){    
                    var ib = $('#icqbl');
                    ib.fadeOut(200);
                    ib.css('visibility','hidden');
                    ib.show();
                    return false;
                });
            }
        });

        return false;
    });
    
    
    

 //Callback appearing window
 var coordl = $("#call_order").offset().left;
 var coordt = $("#call_order").offset().top;
 $("#callback").css({left: coordl-80});
 $("#callback").css({top: coordt+10});
 
	$("#call_order").click(function() {
		$("#callback").fadeIn("slow");
		return false;
	});  
	  
	$("#cbf-close").click(function() {
		$("#callback").fadeOut("fast");
		return false;
	});
		
	//universal switcher
	$(".switchers a").click(function() {
		var acont =  $(this).parent();
		if ($(this).hasClass('active')) return false;

                acont.find("a").removeClass('active');
                $(this).addClass('active');

                var content = $(this).attr('id');

                acont.nextAll(".switchcontent").removeClass('active');
                $('#'+content+'_switch').addClass('active');
		return false;
	});  
		
 }); 
 
 
/*  AddToBookMarks  */
function getBrowserInfo() {
	var t,v = undefined;
	if (window.opera) t = 'Opera';
	else if (document.all) {
		t = 'IE';
		var nv = navigator.appVersion;
		var s = nv.indexOf('MSIE')+5;
		v = nv.substring(s,s+1);
	} else if (navigator.appName) t = 'Netscape';
	return {type:t,version:v};
}

function bookmark(a){
	var url = window.document.location;
	var title = window.document.title;
	var b = getBrowserInfo();
	if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
	else if (b.type == 'Opera') {
		a.href = url;
		a.rel = "sidebar";
		a.title = url+','+title;
		return true;
	}
	else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
	else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
	return false;
}
 
 
