//transparent png
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s($){3.1s.1k=s(j){j=3.1a({12:\'1m.1j\'},j);8 k=(n.P=="r 10 Z"&&U(n.v)==4&&n.v.E("14 5.5")!=-1);8 l=(n.P=="r 10 Z"&&U(n.v)==4&&n.v.E("14 6.0")!=-1);o(3.17.16&&(k||l)){3(2).L("1r[@m$=.M]").z(s(){3(2).7(\'q\',3(2).q());3(2).7(\'p\',3(2).p());8 a=\'\';8 b=\'\';8 c=(3(2).7(\'K\'))?\'K="\'+3(2).7(\'K\')+\'" \':\'\';8 d=(3(2).7(\'A\'))?\'A="\'+3(2).7(\'A\')+\'" \':\'\';8 e=(3(2).7(\'C\'))?\'C="\'+3(2).7(\'C\')+\'" \':\'\';8 f=(3(2).7(\'B\'))?\'B="\'+3(2).7(\'B\')+\'" \':\'\';8 g=(3(2).7(\'R\'))?\'1d:\'+3(2).7(\'R\')+\';\':\'\';8 h=(3(2).1c().7(\'1b\'))?\'19:18;\':\'\';o(2.9.y){a+=\'y:\'+2.9.y+\';\';2.9.y=\'\'}o(2.9.t){a+=\'t:\'+2.9.t+\';\';2.9.t=\'\'}o(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}8 i=(2.9.15);b+=\'<x \'+c+d+e+f;b+=\'9="13:11;1q-1p:1o-1n;O:W-V;N:1l;\'+g+h;b+=\'q:\'+3(2).q()+\'u;\'+\'p:\'+3(2).p()+\'u;\';b+=\'J:I:H.r.G\'+\'(m=\\\'\'+3(2).7(\'m\')+\'\\\', D=\\\'F\\\');\';b+=i+\'"></x>\';o(a!=\'\'){b=\'<x 9="13:11;O:W-V;\'+a+h+\'q:\'+3(2).q()+\'u;\'+\'p:\'+3(2).p()+\'u;\'+\'">\'+b+\'</x>\'}3(2).1i();3(2).1h(b)});3(2).L("*").z(s(){8 a=3(2).T(\'N-S\');o(a.E(".M")!=-1){8 b=a.X(\'1g("\')[1].X(\'")\')[0];3(2).T(\'N-S\',\'1f\');3(2).Q(0).Y.J="I:H.r.G(m=\'"+b+"\',D=\'F\')"}});3(2).L("1e[@m$=.M]").z(s(){8 a=3(2).7(\'m\');3(2).Q(0).Y.J=\'I:H.r.G\'+\'(m=\\\'\'+a+\'\\\', D=\\\'F\\\');\';3(2).7(\'m\',j.12)})}1t 3}})(3);',62,92,'||this|jQuery||||attr|var|style|||||||||||||src|navigator|if|height|width|Microsoft|function|padding|px|appVersion|margin|span|border|each|class|alt|title|sizingMethod|indexOf|scale|AlphaImageLoader|DXImageTransform|progid|filter|id|find|png|background|display|appName|get|align|image|css|parseInt|block|inline|split|runtimeStyle|Explorer|Internet|relative|blankgif|position|MSIE|cssText|msie|browser|hand|cursor|extend|href|parent|float|input|none|url|after|hide|gif|pngFix|transparent|blank|line|pre|space|white|img|fn|return'.split('|'),0,{}))
//chat function 
function enterEvent(e, aUserId, aChatHash){kc = e.keyCode?e.keyCode:e.which;if(kc == 13){addMsg(aUserId, aChatHash);}}
function updAnketa(anketaID, isVote){var ans_id = $('#anketaAns').val(); $.post("http://bgjokes.com/backend.php",{'mode':6,'q_id':anketaID,'isVote':isVote,'ans_id':ans_id},function(data){$("#a_"+anketaID).html(data);});}
function addMsg(aUserId, aChatHash){
	var textMsg = $("#textMsg").val();
	if(textMsg.length > 0){
		changePic('sendButton', 'http://img.bgjokes.com/aqua/ajax-circle.gif');
		$.post("http://bgjokes.com/chat_backend.php",{
             message: textMsg,
             user_id : aUserId,
             chat_hash : aChatHash,
             action: "postmsg"
           }, function(data){
        	 $("#textMsg").val('');
        	changePic('sendButton', 'http://img.bgjokes.com/aqua/send_msg.png');
         $("#chatHolder").append(data);
			scrollTobottomOfDiv('chatHolder');
			$("#textMsg").focus();
       });
	}
}
function fadeSuccessDiv(){ $('.successMsg').fadeOut('slow'); }
function checkNewMsg(){
	var menuLength = $('#dynamicMenu').width();
	var chatUserHolder = $('#chatUser');
	$.post("http://bgjokes.com/chat_backend.php",{
       action: "checkUserMsg",
       menuWidth: menuLength
   }, function(xml){
   	var downMenuMsg = $('downMenuNewMsg',xml).text();
  		$('#dynamicMenu').html(downMenuMsg);
		var menuUser = $('menuUser',xml).text();
		if(chatUserHolder.length > 0){
			$('#chatUser').html(menuUser);
		}
  		setTimeout("checkNewMsg()",60000);
  	});
}
function checkOnline(){$("#crawl_user").load('http://bgjokes.com/backend.php?mode=1', function(){setTimeout("checkOnline()",180000);});}
function getCheckedValue(radioObj){	if(!radioObj)return "";	var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) {if(radioObj[i].checked) { return radioObj[i].value;}} return "";}
function changePic(buttonID, picture){document.getElementById(buttonID).src = picture}
function soundMsg(){$("#sndHolder").html('<embed src="http://bgjokes.com/audio/sndIncMsg.wav" height="0" type="audio/x-ms-wma"></embed>');}
function scrollTobottomOfDiv(divName) {mydiv = document.getElementById(divName);mydiv.scrollTop = mydiv.scrollHeight;} 
/// ajax function
function getData(toPut, param){$("#AjaxLoading").toggle();$("#"+toPut).load(param, function(){$("#AjaxLoading").toggle();});}
function getDataInline(toPut, param){$("#"+toPut).html('<img src="http://bgjokes.com/images/processing2.gif" alt="" />');$("#"+toPut).load(param, null);}
function validData(pagetype, whatID){$.post("http://bgjokes.com/getdata.php",{'type': pagetype,'what': escape(whatID)}, function(data) {$("#errdiv").html(data);});}
function updateBgtop(){$.post("http://bgjokes.com/getdata.php",{'type':'bgtop'},function(data){$("#bgtopDiv").remove();});}
function get(el){return document.getElementById(el);}
function selectCode(f){var oWhatToCopy=get(f);oWhatToCopy.focus();oWhatToCopy.select();}
function copyToClipboard(el){var text2copy=get(el).value;if(window.clipboardData){window.clipboardData.setData("Text",text2copy);}else{var flashcopier='flashcopier';if(!document.getElementById(flashcopier)){var divholder=document.createElement('div');divholder.id=flashcopier;document.body.appendChild(divholder);}document.getElementById(flashcopier).innerHTML='';var divinfo='<embed src="clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="30" height="30" type="application/x-shockwave-flash"></embed>';document.getElementById(flashcopier).innerHTML = divinfo;}}
function capLock(err,e){kc = e.keyCode?e.keyCode:e.which;sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false);if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))document.getElementById(err).innerHTML='Caps Lock бутонът е включен!';else document.getElementById(err).innerHTML='';}
function validateContactForm(oForm){
	var errdiv = document.getElementById('errdiv');
 	oForm.onsubmit = function(){
 		var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 		var regex3 = /^([a-zA-Zа-яА-Я0-9])+$/;
 		if(oForm.elements['inputMail'].value.length<1){
 			errdiv.innerHTML = "Полето email трябва да съдържа данни!";
 			return false;
 		} else if(!regex.test(oForm.elements['inputMail'].value)){
 			errdiv.innerHTML = "Невалиден email!";
 			return false;
 		}

 		if(oForm.elements['yourName'].value.length<1){
 			errdiv.innerHTML = "Полето Име трябва да съдържа данни!";
 			return false;
 		} else if(!regex3.test(oForm.elements['yourName'].value)){
 			errdiv.innerHTML = "Полето Име може да съдържа само букви и цифри!";
 			return false;
 		} 	

 		if(oForm.elements['inputText'].value.length<1){
 			errdiv.innerHTML = "Полето Message трябва да съдържа данни!";
 			return false;
 		} else if(!regex3.test(oForm.elements['inputText'].value)){
 			errdiv.innerHTML = "Полето Message може да съдържа само букви и цифри!";
 			return false;
 		} 		
 		return true;
 	}
}

function validatePassForm(oForm){
	var errdiv = document.getElementById('errdiv');
 	oForm.onsubmit = function(){
 		var regex2 = /^([a-zA-Z0-9_\.\-])+$/;
 		if(oForm.elements['inputPass1'].value.length<1 || oForm.elements['inputPass2'].value.length<1){
 			errdiv.innerHTML = "Полетата парола и повтори паролата трябва да съдържат данни!";
 			return false;
 		} else if(!regex2.test(oForm.elements['inputPass1'].value) || !regex2.test(oForm.elements['inputPass2'].value)){
 			errdiv.innerHTML = "Паролите могат да съдържат само букви, цифри, '_', '.' и '-'";
 			return false;
 		} else if(oForm.elements['inputPass1'].value != oForm.elements['inputPass2'].value){
 			errdiv.innerHTML = "Полетата парола и повтори паролата не съвпадат!";
 			return false;
 		}
 		return true;
 	}
}

function validateForm2(oForm){
	var errdiv = document.getElementById('errdiv');
 	oForm.onsubmit = function(){
		var regex3 = /^([a-zA-Z0-9])+$/;
		if(oForm.elements['inputNickname'].value.length<1){
			errdiv.innerHTML = "Полето псевдоним трябва да съдържа данни!";
			return false;
		} else if(!regex3.test(oForm.elements['inputNickname'].value)){
			errdiv.innerHTML = "Полето псевдоним може да съдържа само латински букви и цифри!";
			return false;
		} 		
		return true;
 	}
}

function pop(urls) {var st=new String(urls); prev = window.open(urls,'preview','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=no,top=180,left=350,width=500,height=340'); prev.focus(); } 
function CreateBookmarkLink() {title = "Webpage Title"; url = "Webpage URL"; if (window.sidebar) {window.sidebar.addPanel(title, url,"");} else if( window.external ) {window.external.AddFavorite( url, title); }else if(window.opera && window.print) {return true; }}

jQuery.fn.rater = function(url,options){
	if(url == null) return;var settings={url:url,maxvalue:5,curvalue:0};
	if(options){jQuery.extend(settings, options);};
	var container = jQuery(this);
	if(!settings.style || settings.style == null || settings.style == 'basic') {
		var raterwidth = settings.maxvalue * 25;
		var ratingparent = '<ul class="star-rating" style="width:'+raterwidth+'px">';
	}
	container.append(ratingparent);
	
	// create rater
	var starWidth, starIndex, listitems = '';
	var curvalueWidth = Math.floor(100 / settings.maxvalue * settings.curvalue);
	for(var i = 0; i <= settings.maxvalue ; i++) {
		if (i == 0) {
			listitems+='<li class="current-rating" style="width:'+curvalueWidth+'%;">'+settings.curvalue+'/'+settings.maxvalue+'</li>';
		} else {
			starWidth = Math.floor(100 / settings.maxvalue * i);
			starIndex = (settings.maxvalue - i) + 2;
			listitems+='<li class="star"><a href="#'+i+'" title="'+i+'/'+settings.maxvalue +'" style="width:'+starWidth+'%;z-index:'+starIndex+'">'+i+'</a></li>';
		}
	}
	container.find('.star-rating').append(listitems);
}
function commentTpl(aType, itemid, itemType){
	if(aType == 'add'){
		$('#commentHolder').html('<span id="comment_error"></span><h3>Текст *</h3><textarea name="text" id="comment_input" rows="3" cols="40" class="idle" style="width:590px;height:130px;"></textarea><br /><div class="buttonDiv" style="width:150px;margin:0 auto;"><button type="button" name="submitSend" class="button" onclick="commentAction(' + itemid + ', \'' + itemType + '\');">Запиши</button></div>');
	} else if(aType == 'list'){
		$("#commentHolder").html('<img src="http://bgjokes.com/images/processing2.gif" alt="" />');
		$.post("http://bgjokes.com/backend.php",{
		       "mode": "10",
		       "comment_text": '',
		       "itemid": itemid,
		       "type": itemType
		   }, function(xml){
			   var value = $('value',xml).text();
			   var error = $('holder',xml).text();
			   $('#comment_count').html(value);
			   $('#commentHolder').html(error);
		   });
	} else if(aType == 'nologin'){
		$('#commentHolder').html('<div style="color:red;">За да можете да пишете коментари трябва да сте влезли в системата. Ако имате регистрация влезте с псевдоним и парола през формата за ВХОД по-горе в дясно. Ако нямате регистрация направете си за 5 секунди от <a href="http://bgjokes.com/signup.php">ТУК</a></div>');
	}
}

function commentTpl2(aType, itemid, itemType){
	if(aType == 'add'){
		$('#commentHolder' + itemid).html('<span id="comment_error"></span><h3>Текст *</h3><textarea name="text" id="comment_input" rows="3" cols="40" class="idle" style="width:590px;height:130px;"></textarea><br /><div class="buttonDiv" style="width:150px;margin:0 auto;"><button type="button" name="submitSend" class="button" onclick="commentAction(' + itemid + ', \'' + itemType + '\');">Запиши</button></div>');
	} else if(aType == 'list'){
		$("#commentHolder" + itemid).html('<img src="http://bgjokes.com/images/processing2.gif" alt="" />');
		$.post("http://bgjokes.com/backend.php",{
		       "mode": "10",
		       "comment_text": '',
		       "itemid": itemid,
		       "type": itemType
		   }, function(xml){
			   var value = $('value',xml).text();
			   var error = $('holder',xml).text();
			   $('#comment_count' + itemid).html(value);
			   $('#commentHolder' + itemid).html(error);
		   });
	} else if(aType == 'nologin'){
		$('#commentHolder' + itemid).html('<div style="color:red;">За да можете да пишете коментари трябва да сте влезли в системата. Ако имате регистрация влезте с псевдоним и парола през формата за ВХОД по-горе в дясно. Ако нямате регистрация направете си за 5 секунди от <a href="http://bgjokes.com/signup.php">ТУК</a></div>');
	}
}

function commentAction(itemid, itemType){
   $.post("http://bgjokes.com/backend.php",{
       "mode": "10",
       "comment_text": $('#comment_input').val(),
       "itemid": itemid,
       "type": itemType
   }, function(xml){
	   var value = $('value',xml).text();
	   var error = $('holder',xml).text();
	   $('#comment_count').html(value);
	   $('#commentHolder').html(error);
   });
}

function editComment(aComment_id){
	$.post("http://bgjokes.com/backend.php",{
	       "mode": "13",
	       "id": aComment_id
	   }, function(data){
		   $('#text_'+ aComment_id).html('<textarea name="text" id="comment_input" rows="3" cols="40" class="idle" style="width:500px;height:130px;">' + data + '</textarea>');
			$('#linkEdit_'+ aComment_id).html('<a href="#" onclick="saveComment(\'' + aComment_id + '\');return false;" style="color:red;">Запиши</a>');
	   });
	
}

function saveComment(aComment_id){
	$.post("http://bgjokes.com/backend.php",{
       "mode": "14",
       "comment_text": $('#comment_input').val(),
       "id": aComment_id
   }, function(data){
	   $('#text_'+ aComment_id).html(data);
	   $('#linkEdit_'+ aComment_id).html('<a href="#" onclick="editComment(\'' + aComment_id + '\');return false;">Редактирай</a>');
   });
}

function sendStuff(aType, aId){
	$("#loadingSender"+ aId).html('<img src="http://bgjokes.com/images/processing2.gif" alt="Loading..." />');
	$.post("http://bgjokes.com/sendto.php",{
       "mode": "temp",
       "senderName": $('#senderName'+aId).val(),
       "senderMail": $('#senderMail'+aId).val(),
       "type": aType,
       "id": aId
	}, function(data){
	   var msg = $("msg", data).text();
	   var statusche = $("status", data).text();
	   statusche = parseInt(statusche);
	   if(statusche == 1){
		   $("#senderName" + aId).val('');
		   $("#senderMail" + aId).val('');
		   $("#loadingSender"+ aId).html(msg);
	   } else{
		   $("#loadingSender"+ aId).html(msg);
	   } 
	   
   });
	
}

$(document).ready(function(){
	$('#smsBanner').html('<a href="http://www.send-sms-now.com/" title="Безплатен SMS до целия свят" target="_blank"><img src="/images/banner/sendsms.gif" alt="" /></a>');
	$('#lifestyleBanner').html('<a href="http://www.hot-lifestyle-news.com/" title="Free Celebrity Photos" target="_blank"><img src="/images/banner/hot-lifestyle-news-88x31.gif" alt="" /></a>');
	$('#loadingDiv').html('<div id="AjaxLoading" style="display:none;">..Loading..<br /><img src="http://img.bgjokes.com//processing3.gif" id="wait" alt="..Loading.." title="..Loading.." /></div>');
});