
// START JQUERY
$(function() 
{
	$('.balloon').bt({
		padding: 10,
		shrinkToFit: true,
		spikeLength: 20,
		spikeGirth: 20,
		cornerRadius: 8,
		fill: 'rgba(0, 0, 0, .8)',
		strokeWidth: 2,
		strokeStyle: '#AF009B',
		positions: ['top','left', 'right', 'bottom'],
		cssStyles: {color: '#FFF', fontWeight: 'bold'}
		});
		
	$('#profile-center-forMe-h > a:first').css({"text-decoration":"underline", "color" : "black"});
	$('#profile-center-widgets > a > img:first').removeClass('opacity-2');
	
	var contaner = $("#profile-center-widgets > a");
	contaner.find('img').click(function() 
	{
		contaner.find('img').addClass('opacity-2');
		$(this).removeClass('opacity-2');
		
		
	});
	
	var contaner2 = $("#profile-center-forMe-h");
	contaner2.find('a').click(function() 
	{
		contaner2.find('a').css({"text-decoration":"none", "color" : ""});
		$(this).css({"text-decoration":"underline", "color" : "black"});
	});
	
});
			$(function() 
			{
				$(".profile_panel_left_vote").bind("mouseenter",function()
				{
					$(this).find('.profileVoteButt:hidden').fadeIn();
				})
				.bind("mouseleave",function()
				{
					$(this).find('.profileVoteButt:visible').fadeOut();
				});
				
				$(".profile").bind("mouseenter",function()
				{
					$(this).find('.profile_sh').fadeTo(350, 0.90);
				})
				.bind("mouseleave",function()
				{
					$(this).find('.profile_sh').hide(150);
				});
				
				
			});
			
			function windowScrollTo(to)
			{
				$('html, body').animate({
											scrollTop: $(to).offset().top
										}, 1000);
			}
			
			function showDiv(id)
			{
				var el = (!id) ? '.ShowThisDiv' : id;
				$(el).toggle();
			}
			
			function showDivYes(id)
			{
				var el = (!id) ? '.ShowThisDiv' : id;
				$(el).show();
			}
			
			function showDivNo(id)
			{
				var el = (!id) ? '.ShowThisDiv' : id;
				$(el).hide();
			}
			
			function forJax(id,file,fId)
			{
				if(fId.indexOf('=') != -1)
					{
						var vtvt = fId;
						//$(id).hide();
					}
					else if(getFormValues(fId) != "")
					{
						var vtvt = getFormValues(fId);
					}
					else
					{
						var vtvt =  $(id).attr('name');
					}
					var vtvt = vtvt+"&JS=1";
					$.post(file,vtvt,function(response)
					{
						if(response.indexOf("loc:") != -1)
						{
							var sez = response.split('loc:');
							var sez = sez[1].split(':loc');
							window.location = sez[0];
						}
						else
						{
							Boxy.alert(response);
						}
					});
					return false;
			}
			window.Jax = function(id,file,fId)
			{
				if(fId.indexOf('=') != -1)
				{
					forJax(id,file,fId);
				}
				else
				{
					$(id).click(function()
					{
						forJax(id,file,fId);
						return false;
					});
				}
			}
			window.pages = function(file,ops,id)
			{
				$(id).html("Зареждане <img src=\""+_URL()+"/templates/tic2/images/loading.gif\" alt=\"loading\" />");
				$.post(file,ops,function(response)
								{
									$(id).hide().html(response).fadeIn("fast");
								}
					);
			}
// END JQUERY
function addChat(e)
{
	if(e)
	{
		if(e.keyCode == 13)
		{
			pages('__global_chat.html','msg='+document.getElementById("chatArea").value,'#show-chat');
			document.getElementById("chatArea").value = "";
		}
	}
	else
	{
		pages('__global_chat.html','msg='+document.getElementById("chatArea").value,'#show-chat');
		document.getElementById("chatArea").value = "";
	}
}

function _URL()
{
	return document.URL.replace(/(\\|\/)[^\\\/]*$/, '/');
}
myid = function (Id) {
    if (!Id) {
        return null;
    }
    var returnObj = document.getElementById(Id);
    if (!returnObj && document.all) {
        returnObj = document.all[Id];
    }
    if (!returnObj) {
        return false;
    }
    return returnObj;
}
			
			getFormValues = function(frm) {
    //alert('1');
    var objForm;
    var submitDisabledElements = false;
    if (arguments.length > 1 && arguments[1] == true)
        submitDisabledElements = true;
    var prefix="";
    if(arguments.length > 2)
        prefix = arguments[2];
    
    if (typeof(frm) == "string")
        objForm = myid(frm);
    else
        objForm = frm;
    var sXml = "";
    if (objForm && objForm.tagName == 'FORM')
    {
        var formElements = objForm.elements;
        for( var i=0; i < formElements.length; i++)
        {
            if (!formElements[i].name)
                continue;
            if (formElements[i].name.substring(0, prefix.length) != prefix)
                continue;
            if (formElements[i].type && (formElements[i].type == 'radio' || formElements[i].type == 'checkbox') && formElements[i].checked == false)
                continue;
            if (formElements[i].disabled && formElements[i].disabled == true && submitDisabledElements == false)
                continue;
            var name = formElements[i].name;
            if (name)
            {
                if (sXml != '')
                    sXml = sXml + '&'; 
                if(formElements[i].type=='select-multiple')
                {
                    for (var j = 0; j < formElements[i].length; j++)
                    {
                        if (formElements[i].options[j].selected == true)
                            sXml = sXml + name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";
                    } 
                }
                else
                {
                    sXml = sXml + name + "=" + encodeURIComponent(formElements[i].value); 
                }
            } 
        }
    }
    
    
    return sXml;
}

			
var xmlHttp 
function GetXmlHttpObject() 
{ 
var xmlHttp=null; 

try 
{ 
// Firefox, Opera 8.0+, Safari 
xmlHttp=new XMLHttpRequest(); 
} 
catch (e) 
{ 
// Internet Explorer 
try 
{ 
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
} 
catch (e) 
{ 
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
} 
} 
return xmlHttp; 
} 


function conf(text,link)	
{
	if(confirm(text))
	{
		if(link.toLowerCase().indexOf('/') != -1)
		{
			window.location = link;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}

function checkboxs()
{
	var obj = document.getElementsByTagName("*");
	var mas = new Array();
	for(i=0; i<obj.length; i++) 
	{
		if((obj[i].className).indexOf("check_this") != -1) 
		{
			if(!obj[i].checked)
			{
				obj[i].checked = true;
			}
			else
			{
				obj[i].checked = false;
			}
		}
	}
}

function cap(id)
{
	var rL = document.URL.replace(/(\\|\/)[^\\\/]*$/, '/');
	document.getElementById(id).src = rL+"include/captcha.php?"+Math.random();
}

function winOpen(url,wid,hei) 
{
	var tim = Math.floor(Math.random()*11);
	window.open(url, tim,'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=no,width='+wid+',height='+hei+',left=100,top=50');
}

function addemo(newemo,sel,form) 
{
	if(sel == 0)
	{
		var emoid =  document.getElementById(form).value;
		emoid = document.getElementById(form).value += newemo; 
		document.getElementById(form).focus();
	}
	else if(sel == 1)
	{
		var doti = opener.document.getElementById(form).value;
		doti = opener.document.getElementById(form).value += newemo;
	}
}
