function clearInput(inputId)
{
	var el = document.getElementById(inputId);
	if(el.title == el.value){
		el.value='';
	}
}

//Loads example panel "drop down"
function initSearch()
{
	
	if (document.getElementById('overlay1').style.visibility == 'visible')
	{
		closeSearch();
		
	}
	else 
	{
		YAHOO.namespace("example.container");
		YAHOO.example.container.overlay1 = new YAHOO.widget.Overlay("overlay1", { fixedcenter:false,
		  width:"236px",
		  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.35} });
		YAHOO.example.container.overlay1.render();
		
	}
	
}

function closeSearch()
{
	YAHOO.example.container.overlay1.hide();
	
}


// BEGIN : Get error messages via aSync POST request
var div = document.getElementById('container');
var handleSuccess = function(o){
var div = document.getElementById('container');
	
	if(o.responseText !== undefined)
	{
		if(o.responseText.search('success') == -1) 
		{
			var messages = []; 
			messages = YAHOO.lang.JSON.parse(o.responseText);
			div.innerHTML =  "" ;
		 try {
                messages = YAHOO.lang.JSON.parse(o.responseText);
            }
            catch (x) 
			{
                alert("JSON Parse failed!");
                return;
            }
         
		
		 YAHOO.util.Dom.addClass('container','errorDiv');
		 for (var i = 0, len = messages.length; i < len; ++i) 
			 { 
				 var m = messages[i];
				 YAHOO.util.Dom.addClass(m.id,'errorInput');
				// YAHOO.util.Dom.addClass(m.id +'Text','error');
				
				// uncomment this if you want the errors to be displayed at top of the form
				 div.innerHTML +=  '<span class="error">' + m.message + '</span><br>';
				 			 
			 }
			 if (document.getElementById('success')) {
			 	document.getElementById('success').innerHTML = '';
			 }
		
		}
		else
		{
			
			eval (action);
		}
	}
};

var handleFailure = function(o){
	var div = document.getElementById('container');
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";	
	}
};

var callback =
{
  success:handleSuccess,
  failure:handleFailure
 
};



function checkErrors(e)
{
	
	YAHOO.util.Event.preventDefault(e);
	
	var removeStyle = YAHOO.util.Dom.getElementsByClassName('errorInput', 'input');
	for (var i=0; i<removeStyle.length; i++) 
	{
		
		YAHOO.util.Dom.removeClass(removeStyle[i].id,'errorInput');
		YAHOO.util.Dom.removeClass(removeStyle[i].id,'errorText');
		YAHOO.util.Dom.removeClass(removeStyle[i].id +'Text','error');
			
	};
	document.getElementById('container').innerHTML = "";
	YAHOO.util.Dom.removeClass('container','errorDiv');
	var formObject = document.getElementById(formName);
	YAHOO.util.Connect.setForm(formObject);
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback);
	
}

function asyncRequest(url,method,displayDiv,removeContent)
{
	var div = document.getElementById(displayDiv);

	var handleSuccess = function(o){
	if(o.responseText !== undefined){
		if (removeContent == 1)
		{
			div.innerHTML = '';
		}
		div.innerHTML += o.responseText;
	}
}

var handleFailure = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
}

var callback =
{
  success:handleSuccess,
  failure: handleFailure
};
var request = YAHOO.util.Connect.asyncRequest(method, url, callback);
}
// END : Get error messages via aSync POST request




	
function imageDestroy(imageName)
{
	YAHOO.util.Dom.get(imageName).innerHTML = '';
}

function imageShow(imageName)
{
	asyncRequest('../showImage/' + imageName,'GET','imgDiv',1);
	YAHOO.namespace("example.container");
		YAHOO.example.container.imagepanel = new YAHOO.widget.Panel("imagepanel", { context:["news_table_top"],
																		  constraintoviewport:true,
																		  width:"100%",
																		  close:true,
																		  
																		  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.35},modal:true } );
		YAHOO.example.container.imagepanel.render();
}


//BEGIN : Content slider
YAHOO.util.Event.onContentReady('akcent_table_right', changeAnnounce); 

YAHOO.util.Event.on('akcent1', 'mouseover', function(){
		
		newsRotate(1);
	});

YAHOO.util.Event.on('akcent2', 'mouseover', function(){
		
		newsRotate(2);
	});

YAHOO.util.Event.on('akcent3', 'mouseover', function(){
		
		newsRotate(3);
	});
YAHOO.util.Event.on('akcent4', 'mouseover', function(){
		
		newsRotate(4);
	});


function changeAnnounce()
{
	i = 0;
	n = 0;
	YAHOO.namespace("news.container");
	
	timeout = 0;
	
	while( i < 2000)
	{
		
		i++;
		if ( n == 4)
		{
			n = 1;
		}
		else
		{
			n  ++;
		}
		setTimeout('newsRotate('+ n +')',timeout);
		timeout = timeout + 2000;	
		
	}

}
function newsRotate(i)
{
	a = i-1;
	p = 0;
	while(p<4)
	{
		p++;
		YAHOO.util.Dom.removeClass('akcent' + p,'akcent_news_block_selected');
		YAHOO.util.Dom.removeClass('slider','akcetn_table_left'+ p);
	}
	//YAHOO.util.Dom.removeClass('akcent' + a,'akcent_news_block_selected');
	YAHOO.util.Dom.addClass('akcent' + i,'akcent_news_block_selected');
	//YAHOO.util.Dom.removeClass('slider','akcetn_table_left'+ a);
	YAHOO.util.Dom.removeClass('slider','akcetn_table_left');
	YAHOO.util.Dom.addClass('slider','akcetn_table_left'+ i);
	if (i == 1)
	{
		YAHOO.util.Dom.removeClass('slider','akcetn_table_left4');
		YAHOO.util.Dom.removeClass('akcent4','akcent_news_block_selected');
	}
	YAHOO.util.Dom.get('trans_text').innerHTML = YAHOO.util.Dom.get('akcent_p'+i).innerHTML;
	
}


//END: Content slider

//BEGIN : Increase/Decrease Font
function changeFontSize(increase)
{
	var fontText = document.getElementById('fontText');
	var dsi = fontText.style.fontSize;
	if (dsi == '')
	{
		dsi =  12;
	}
	else
	{
		      dsi = parseInt(fontText.style.fontSize.replace("px",""));
	}
	
		if (increase == 0 && dsi < 16) {
			dsi++;
		}
		else if (dsi > 10 ){
			dsi--;
		}
	
fontText.style.fontSize=dsi +"px";

}
//END : Increase/Decrease Font


YAHOO.util.Event.addListener(window,'load',function(){
	var rf = new YAHOO.util.Element('rf');
	rf.on('click', function(){
		var sel = new YAHOO.util.Element('sy'); 
		sel.setStyle('display','none');
	});

	var rp = new YAHOO.util.Element('rp');
	rp.on('click', function(){
		var sel = new YAHOO.util.Element('sy'); 
		sel.setStyle('display','inline-block');
	});
	
	var rr = new YAHOO.util.Element('rr');
	rr.on('click', function(){
		var sel = new YAHOO.util.Element('sy'); 
		sel.setStyle('display','inline-block');
	});
	/*
	var wait_child = new YAHOO.util.Element('wait_child');
	wait_child.on('click', function(){
		var sel = new YAHOO.util.Element('term'); 
		sel.setStyle('display','inline-block');
	});
	*/
});

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}


Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}


jQuery(document).ready(function(){
	
	/* hide & show element */
	jQuery('a.hidebar').click(function(){
		var el=this.rel;
		var link = this;
		//alert(jQuery("#" + el).css('display'));
		jQuery("#" + el).animate({"height": "toggle"}, 500, function(){
			if(jQuery(this).css('display')=='block'){
				jQuery(link).html('прибери<span><img src="/img/closePanel.jpg" style="margin: 0 0 2px 5px;" width="8" height="4" alt="" /></span>');	
			}
			else{
				jQuery(link).html('отвори<span><img src="/img/plusIcon.gif" style="margin: 0 0 0px 5px;" width="8" height="8" alt="" /></span>');
			}
		});
		return false;
	});
	
	jQuery("input#wait_child").click( function(){
		var check = jQuery(this).attr("checked");
		if(check==true){
			jQuery("div#term").fadeIn();
		}
		else{
			jQuery("div#term").fadeOut();
		}
	});
	
	jQuery('a#addImage').click(function(){
		var html = jQuery('#childdata').html();
		jQuery("#htmlinput").append(html);
		return false;
	});
	
	jQuery('a#addKids').click(function(){
		var html = jQuery('#childdata').html();
		jQuery("#htmlinput").append(html);
		return false;
	});
	
	jQuery('a.lightbox').click(lightbox_show);
	
	jQuery('a.delete').click(function(){
		if(!confirm('Наистина ли искате да изтриeте това?')){
			return false;
		}
	});

	jQuery('a.star').click(function(){
		jQuery.get(this.href,function(response){
			lightbox_message(response);
		});
		return false;
	});
		
	jQuery("a.changeNameBut").click( function(){
		var id = jQuery(this).closest("p").attr("id");
		jQuery("form#changeName-" + id).submit();
	});
	
	jQuery("input.changeCover").click( function(){
		var id = jQuery(this).attr("rel");
		jQuery("form#changeCover-" + id).submit();
	});
	
	/* user menu */
	jQuery("#underMenu li").hover(
		function(){ jQuery("ul", this).fadeIn("fast"); }, 
		function() { jQuery("ul", this).fadeOut("fast"); } 
	);
  
	jQuery.fn.hoverClass = function(c) {
		return this.each(function(){
			jQuery(this).hover( 
				function() { jQuery(this).addClass(c);  },
				function() { jQuery(this).removeClass(c); }
			);
		});
	}
	/* user menu */
	
	jQuery("a[rel^='lightbox']").slimbox({overlayOpacity: 0.3}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
	
	/* album right Block */
	jQuery('#most #sidebarBlock a').click(function(){
		jQuery('#most #sidebarBlock a').removeClass('on');
		jQuery(this).addClass('on');
		jQuery('#most div.middle_main_cal').hide();
		jQuery(this.hash).fadeIn();
		return false;
	});
	
	/* names right Block */
	jQuery('#name #sidebarBlock a').click(function(){
		jQuery('#name #sidebarBlock a').removeClass('on');
		jQuery(this).addClass('on');
		jQuery('#name div.middle_main_cal').hide();
		jQuery(this.hash).fadeIn();
		return false;
	});
	
	jQuery("select#sortfriend option").click( function(){
		jQuery("form#friend").submit();
	});
		
	jQuery("a#searchfriend").click( function(){
		jQuery("form#friend").submit();
	});
	
	jQuery("select#limitfriend option").click( function(){
		jQuery("form#friend").submit();
	});
	
	jQuery('a.addfriend').click(function(){
		var el = this;

		//var block = jQuery(this).closest('div.friendspannel');
		//jQuery(block).addClass('loading');
		
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery(el).html('Поканен преди 1 секунда').unbind('click').attr('href','#');
					lightbox_message('Поканата за приятелство беше изпратена успешно!');
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				//jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.makefriend').click(function(){
		var el = this;
		var id = this.rel;
		var name = this.title;
		var block = jQuery(this).closest('div.friendspannel');
		jQuery(block).addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery('p.dateFriends',jQuery(block)).html('Поканен преди 1 секунда');
					jQuery(el).unbind('click');
					jQuery(block).removeClass('loading');
					lightbox_message('Поканата за приятелство беше изпратена успешно!');
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.acceptfriend').click(function(){
		var el = this;
		var id = this.rel;
		var name = this.title;
		var block = jQuery(this).closest('div.friendspannel');
		jQuery(block).addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery('p.textfriend',jQuery(block)).html('Добавихте <a href="/users/index/'+ id +'">'+ name +'</a>  като приятел.');
					jQuery('p.dateFriends',jQuery(block)).html('(Преди 1 секунда)');
					jQuery(el).unbind('click');
					jQuery(block).removeClass('loading');
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.deletefriend').click(function(){
		var el = this;
		var id = this.rel;
		var block = jQuery(this).closest('div.friendspannel');
		jQuery(block).addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery(block).slideUp();
					jQuery(el).unbind('click');
					jQuery(block).remove();
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.blockadedfriend').click(function(){
		var el = this;
		var block = jQuery(this).closest('div.friendspannel');
		jQuery(block).addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery(block).slideUp();
					jQuery(el).unbind('click');
					jQuery(block).remove();
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.blockadedfriendall').live('click',function(){
		
		var el = this;
		var id = this.rel.split(';');
		var block = jQuery(this).closest('div.friendspannel');
		
		//jQuery(block).addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery('div.friendsSettings div',jQuery(block)).html('<a href="/users/index/' + id[0] +'">Профил</a> | <a href="ajax.php?url=friends/allowfriend/'+ id[0] +'/nob/'+ id[1] +'" rel="'+ id[0] +';'+ id[1] +'" class="allowfriend">Разреши</a>| <a href="/ajax.php?url=friends/delete/'+ id +'" rel="'+ id +'" class="deletefriend">Откажи</a>');
					jQuery(el).unbind('click');
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.allowfriend').live('click',function(){
		var el = this;
		var id = this.rel.split(';');
		var block = jQuery(this).closest('div.friendspannel');
		//jQuery(block).addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(xhr.responseText);
				if(xhr.status==200){
					jQuery('div.friendsSettings div',jQuery(block)).html('<a href="/users/index/' + id[0] +'">Профил</a> | <a href="/ajax.php?url=friends/invitation/'+ id[0] +'/b/'+ id[1] +'" rel="'+ id[0] +';'+ id[1] +'" class="blockadedfriendall" >Блокирай</a>| <a href="/ajax.php?url=friends/delete/'+ id +'" rel="'+ id +'" class="deletefriend">Откажи</a>');
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или тази операция не е разрешена!');
				}
				jQuery(block).removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery('a.votingname').click(function(){
		var el = this;
		var id = parseInt(jQuery(this).attr("rel"));
		jQuery('#insideNameText').addClass('loading');
		jQuery.ajax({
		    url: this.href,
		    complete: function(xhr, statusText) {
		        //alert(statusText);
				if(xhr.status==200){
					jQuery("p.voteok").html('Това име се е харесало на <strong>'+ (id + 1) +'</strong> потребителя');
					jQuery('a.votingname').attr("rel",(id + 1));
					//alert(jQuery(el).attr("rel");
				}
				else if(xhr.status==403){
					lightbox_message('Не сте влязъл/а в системата или вече сте гласували за това име!');
				}
				jQuery('#insideNameText').removeClass('loading');
		    }
		});
		return false;
	});
	
	jQuery("a#closeBlock").click( function(){
		jQuery('#hintNames').hide();
		return false;
	});
	
	jQuery("#labelshow").click( function(){
		jQuery('#labelshows').show();
		return false;
	});
	
	/*
	 * hide & show dates in form suggest names
	jQuery('#typename').change(function(){
		if(jQuery('#typename').val()=='1' || jQuery('#typename').val()=='2' || jQuery('#typename').val()=='4'){
			jQuery('#shownamedates').hide();
		}
		else{
			jQuery('#shownamedates').show();
		}
	});
	*/
	
	jQuery('tr.bNames, tr.bNamesno').hover(
			function(){
				jQuery('td.votingn *',this).css('visibility','visible');
			},
			function(){
				//jQuery('td.votingn *',this).css('visibility','hidden');
				jQuery('td.votingn *',this).css('visibility','visible');
			}
	);
	
	//jQuery('tr.bNames td.votingn *, tr.bNamesno td.votingn *').css('visibility','hidden');
	jQuery('tr.bNames td.votingn *, tr.bNamesno td.votingn *').css('visibility','visible');
	

	jQuery('select.labelMessage').change(function(){
		var el = this;
		
		if(el.value!=''){
	
			jQuery(el).addClass('loading');
			
			var np = el.name.split(/[\[\]]+/);
			var ID_PM = np[1];
	
			jQuery.ajax({
			    url: '/ajax.php?url=messages/labelMessage/' + ID_PM + '/' + el.value,
			    complete: function(xhr, statusText) {
			        //alert(statusText);
					if(xhr.status==200){
						lightbox_message(xhr.responseText);
					}
					else if (xhr.status==204){
						lightbox_message('Eтикетът е редактиран успешно!');
					}
					else if(xhr.status==500){
						lightbox_message('Възникна грешка при редактиране на етикетът!');
					}
					jQuery(el).removeClass('loading');
			    }
			});
			
		}		
	});
	
	jQuery('input.allmessage').change(function(){
		var el = this;
		var toRemove = new Array();
		var toRemoveNames = new Array();
		jQuery('#messageForm .masCells input:checked').each(function() {
			jQuery.each(currentLabels[this.value], function(i, val) {
				if(i!='' && !toRemove.in_array(i)){
					toRemove.push(i);
					toRemoveNames.push(val);
				}
			});
		});
		//alert(toRemove.toString());
		var d = 0;
		var sel = document.getElementById('labels');
		for(i=sel.options.length-1;i>=0;i--){
			if(sel.options[i].disabled){
				break;
			}
			sel.options[i] = null;
		}
		for(i = 0; i < toRemove.length; i++ ){
			sel.options[sel.options.length] = new Option(toRemoveNames[i],'rem_' + toRemove[i]);
		}
		
	});
	
	jQuery('select#labels').change(function(){
		jQuery('form#messageForm').attr("action","/messages/putlabel/");
		jQuery("form#messageForm").submit();
		return false;
	});
	
});

function lightbox_show(){

	if(document.getElementById('TB_overlay')){
		jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
	}

	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		jQuery("body,html").css({height: "100%", width: "100%"});
		jQuery("html").css("overflow","hidden");
		if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
			jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div><div id='TB_loader'></div>");
			//jQuery("#TB_overlay").click(lightbox_remove);
		}
	}else{//all others
		if(document.getElementById("TB_overlay") === null){
			jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div><div id='TB_loader'></div>");
			//jQuery("#TB_overlay").click(lightbox_remove);
		}
	}

	if(tb_detectMacXFF()){
		jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
	}

	jQuery('object, embed').hide();
	
	//jQuery("#TB_window").append("<a id='TB_closeWindow' href=''></a><div id='TB_ajaxContent'></div><div id='TB_ajaxFooter'></div>");
	jQuery("#TB_window").append("<div id='TB_ajaxContent'></div><div id='TB_ajaxFooter'></div>");
	
	jQuery('#TB_ajaxContent').load(this.href,function(){
		jQuery('#littleCloseBut').click(lightbox_remove);
		jQuery('#baloonClose a').click(lightbox_remove);
		//jQuery('#TB_closeWindow').click(lightbox_remove);
		//if (typeof document.body.style.maxHeight !== "undefined") {//if IE 6
		//	jQuery("#TB_window").css({marginTop: '-' + (jQuery("#TB_window").innerHeight()/2) + 'px' });
		//}
		jQuery("#TB_window").fadeIn(function(){
			jQuery("#TB_loader").remove();

			w = parseInt(jQuery('#cropbox').width());
			//alert(w);
			if (w>580){
				jQuery('#TB_window').css({
					width: (w+20) + 'px',
					marginLeft: '-' + (w/2 + 10) + 'px' 
				});
				jQuery('#TB_ajaxContent').css({
					width: (w+20) + 'px'
				});
				jQuery('#mydiv').css({
					width: (w+20) + 'px'
				});
			}
			
			jQuery("#TB_window").css({marginTop: '-' + (jQuery("#TB_window").height()/2) + 'px' });

		});
	});
	return false;
	
}

function lightbox_message(message){

	if(document.getElementById('TB_overlay')){
		jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
	}

	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		jQuery("body","html").css({height: "100%", width: "100%"});
		jQuery("html").css("overflow","hidden");
		if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
			jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
			//jQuery("#TB_overlay").click(lightbox_remove);
		}
	}else{//all others
		if(document.getElementById("TB_overlay") === null){
			jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
			//jQuery("#TB_overlay").click(lightbox_remove);
		}
	}
	
	if(tb_detectMacXFF()){
		jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
	}

	jQuery('object, embed').hide();
	
	//jQuery("#TB_window").append("<a id='TB_closeWindow' href=''></a><div id='TB_ajaxContent'></div><div id='TB_ajaxFooter'></div>");
	jQuery("#TB_window").append("<div id='TB_ajaxContent'></div><div id='TB_ajaxFooter'></div>");
	
	jQuery('#TB_ajaxContent').html('<div class="top_dashboard"><p style="padding-left:10px;">Съобщение</p></div><div class="middle_dashboard"><div style="margin-left: 10px;"><p class="copyLinkPic">'+message+'</p><div style="float: right; margin-right: 7px;"><input id="littleCloseBut" style="margin: 5px 0 0 0;" type="submit" value="" name=""/>	</div><br style="clear: both;" /></div></div><div class="bottom_dashboard"></div>');
	jQuery('#littleCloseBut').click(lightbox_remove);
	jQuery('#baloonClose a').click(lightbox_remove);
	//jQuery('#TB_closeWindow').click(lightbox_remove);
	if (typeof document.body.style.maxHeight !== "undefined") {//if IE 6
		jQuery("#TB_window").css({marginTop: '-' + (jQuery("#TB_window").innerHeight()/2) + 'px' });
	}
	jQuery("#TB_window").fadeIn();

	return false;
}

function lightbox_remove() {
	jQuery("#TB_window, #TB_overlay").fadeOut("fast",function(){
		jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
		jQuery('object, embed').show();
	});
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		jQuery("body","html").css({height: "auto", width: "auto"});
		jQuery("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}

