function AddToFavorites(title, url)
{
        if (window.sidebar) { // Mozilla Firefox Bookmark
                window.sidebar.addPanel(title, url,"");
                return false;
        }
        else if( window.external) { // IE Favorite
                window.external.AddFavorite( url, title);
                return false;
        }
};

function addClick(id,title) {
	var xhr = $.ajax({
		url: ROOT_URL+'_ajax/klikniecia_artykuly.php',
		type: 'POST',
		dataType: 'HTML',
		data: "id="+id,
		timeout: '2000',
		error: function() {
//			location.href=link;
		},
		success: function(txt) {
//			location.href=link;
		}
	});
};
function usunPracodawce() {
	if (confirm("Na pewno chcesz usunąć swoje konto?")) {
		if (confirm("Usunięcie konta spowoduje usunięcie zamieszczonych ogłoszeń.\nCzy na pewno usunąć konto?")) {
			document.location.href=ROOT_URL+'dla_pracodawcow/strefa_pracodawcy/?usun=1';
		}
	}
};

function removeEmployer() {
	if (confirm("Are you sure you want to delete my account?")) {
		if (confirm("Deleting an account will delete the advert. \nAre you sure you delete your account?")) {
			document.location.href=ROOT_URL+'for_employers/employer_zone/?usun=1';
		}
	}
};

function usunKandydata() {
	if (confirm("Na pewno chcesz usunąć swoje konto?")) {
		if (confirm("Usunięcie konta spowoduje także usunięcie Twojego CV.\nCzy na pewno usunąć konto?")) {
			document.location.href=ROOT_URL+'dla_kandydatow/twoj_profil/?usun=1';
		}
	}
};
function candidateRemove() {
	if (confirm("Are you sure you want to delete my account?")) {
		if (confirm("Deleting an account will also delete your CV.\nAre you sure you delete your account?")) {
			document.location.href=ROOT_URL+'for_candidates/your_profile/?usun=1';
		}
	}
};
function usunOgloszenie(idO) {
	if (confirm("Na pewno chcesz usunąć to ogłoszenie?")) {
			document.location.href=ROOT_URL+'dla_pracodawcow/strefa_pracodawcy/moje_ogloszenia/?usun=1&idO='+idO;
	}
};

function confirmationAction(text,url) {
	if (confirm(text)) {
		document.location.href=url;
	}
};

var max_width = 180;
var max_height = 125;
function resize_image(img) {
    // jeśli szerokość obrazka jest większa niż dopuszczalna maksymalna szerokość
    if(img.width > max_width) {
        // obliczamy proporcje szerokość do wysokość
        factor = img.width / img.height;
        // obliczamy proporcjonalną wysokość, zaokrąglamy ją używając Math.floor();
        height = Math.floor(max_width / factor);
        // nadajemy obrazkowi nowe wymiary
        img.width = max_width;
        img.height = height;
    }
    if(img.height > max_height) {
	factor = img.height / img.width;
	width = Math.floor(img.height / factor);
	img.width = width;
        img.height = max_height;
    }
};
function setCookie(c_name,value,expiredays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
};
function deleteCookie( name ) {
    document.cookie = name + "=" +";expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/";
};
function sendPoll(check,id){
    if(typeof check=='undefined'){
	return false;
    }
    $.ajax({
	url: ROOT_URL+'_ajax/poll.php',
	type: 'post',
	dataType: 'html',
	data: "field="+check+"&id="+id,
	success: function(msg){
	 $("#sonda_box").hide();
	 $("#sonda_box").html(msg);
	 $("#sonda_box").fadeIn('slow');
	 setCookie('sonda_'+id,id,365);
	}
    })
};