function goPostHit(id) {
	$.post(
		'http://droginfo.com.ua/cron/hitpost.php', {
			id: id
		},
		function(data){
			$('.hitpost').html(data);
		}
	);
}

function CommentRate(id, cid, score, hash) {
	$("div#vote"+cid+".commentvote a").hide();
	$.post(
		'http://droginfo.com.ua/cron/comment_rate.php', {
			id: id,
			cid: cid,
			score: score,
			hash: hash
		},
		function(data){
			if (data.search(/\0/) == -1) {
				if (data.substring(0, 1) == '-') $("span#rate" + cid + "m").html(data);
				else $("span#rate" + cid + "p").html(data);
			}
			$.cookie('akocomment'+cid, score, { expires: 7, path: '/', domain: 'droginfo.com.ua', server: 'droginfo.com.ua' });
		}
	);
}

function CommentCheckCookie(cid) {
	var cookieValue = $.cookie("akocomment"+cid);
	cookieValue = parseInt(cookieValue, 10);
	if (!isNaN(cookieValue)) {
		$("#vote"+cid+" a").hide();
	}
}

$(function(){
	if (typeof $.Lightbox !== "undefined") {
		$.Lightbox.construct({
			text: {
				image: "Фото",
				of: "із",
				close: "Закрити",
				download: "Повний розмір"
			},
			show_linkback: false,
			show_helper_text: false,
			show_info: false,
			show_extended_info: true,
			download_link: true
		});
	}
});

function addBookmark() {
	var title="Інформаційний портал Дрогобич Інфо";
	var url="http://droginfo.com.ua/";

	//Gecko 
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, ""); 
	//IE4+ 
	else if (typeof window.external == "object") window.external.AddFavorite(url, title); 
	//Opera7+ 
	else if (window.opera && document.createElement) {
		var a = document.createElement('A'); 
		if (!a) return false; //IF Opera 6 
		a.setAttribute('rel','sidebar'); 
		a.setAttribute('href',url); 
		a.setAttribute('title',title); 
		a.appendChild(document.createTextNode('Add Bookmark'));
		document.getElementsByTagName('body')[0].appendChild(a);

		//a.click(); 
		//window.external.AddFavorite(this.href, this.title); 
		alert("Натисніть CTRL-D, щоб додати сайт в закладки.");
	} 
	else return false; 
	//return true; 
}

function setHomePage(obj) {
	var url="http://droginfo.com.ua/";
	if (this.setHomePage) {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(url);
	}
}

function pause(ms) {   
	var date = new Date();   
	var curDate = null;   
	do { curDate = new Date(); }   
	while(curDate-date < ms);   
} 
function hider(sum){
	var i=0;
	for (i = 6; i <= sum; i++) { 
		document.getElementById('s'+i).style.display=(document.getElementById('s'+i).style.display=='none')?'block':'none';
		document.getElementById('show1').style.display=(document.getElementById('s6').style.display=='none')?'block':'none';
		document.getElementById('show2').style.display=(document.getElementById('s6').style.display=='none')?'none':'block';
		//pause(200);
	}
}



function scrollMarquee(){
	var crossMarqueeLeft = parseInt($("#iemarquee").css('left'));
	if (crossMarqueeLeft > actualwidth) $("#iemarquee").css('left', (crossMarqueeLeft - copyspeed) + 'px');
	else $("#iemarquee").css('left', parseInt(marqueewidth)+8+'px');
}

	var marqueewidth = "1000px";
	var marqueeheight = "20px";
	var marqueespeed = 1;
	//if ($.browser.msie) marqueespeed = 1.5;
	var copyspeed = marqueespeed;
	var pausespeed = 0;
	var actualwidth; 
	
	var runLineContent = '<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>';
	runLineContent += '<table border="0" cellspacing="0" cellpadding="0"><td>';
	runLineContent += '<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">';
	runLineContent += '<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">';
	runLineContent += '<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>';
	runLineContent += '</div></div>';
	runLineContent += '</td></table>';
	$("#runbar").append(runLineContent);

$(window).load(function() {
	$("#iemarquee").css('left', parseInt(marqueewidth)+8+'px').html(marqueecontent);	
	actualwidth = (parseInt($("#temp").width()) * (-1) + 8);
	lefttime = setInterval(function() {scrollMarquee();}, 20);
	//$("img[src*='abglogo']").hide();
	//console.dir($("img[src*='abglogo']"));
});



