function defvalue_email(txt){
   if(document.forms['mail'].email.value=="")  document.forms['mail'].email.value=txt;
}
function defvalue_msg(txt){
   if(document.forms['mail'].msg.value=="") document.forms['mail'].msg.value=txt;
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), 
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), 
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}



function alignBlocks()
{
	var h_header = $("#header").height();
	var h_footer = $("#footer").height();
	var h = $("#container").height();
	h = h - h_header - h_footer - 47;
	
    $("#menu").css({'height': h + 'px'});
    $("#members").css({'height': h + 'px'});
	
}

	 
function addLoadEvent(func) 
{ 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') 
	{ 
		window.onload = func; 
	} 
	else
	{ 
		window.onload = function() 
		{ 
			if (oldonload) 
			{ 
				oldonload(); 
			} 
			func(); 
	    } 
	} 
} 




function login(form)
{
	$('#login_loader').css("display" , "block");
	$('#login_report').css("display" , "none");

	jQuery.ajax(
		{	
			data: $(form).serialize(),
			url:  $(form).attr('action'),
			type: $(form).attr('method'),
			success:  	function(msg)
						{
							$('#login_loader').css("display" , "none");
							
							msg = msg.split('|');
							var rtype = parseInt(msg[0]);
							msg = msg[1];
							
							if(rtype < 2)
							{
								$("#login_report").attr("innerHTML", msg);
								$('#login_report').css("display" , "block");
							}
							else
							{
								document.location = document.location;
							}
							
						}
		}
	); 			
	return false;		
			
}

function vote(id, num)
{
  $("#div"+id).load("/img/vote.php?id="+id+"&num="+num);
  $("#divb"+id).load("/img/bals.php?id="+id+"&num="+num);
	return false;		
			
}

function news_subs(form)
{
	$('#news_loader').css("display" , "block");
	$('#news_report').css("display" , "none");

	jQuery.ajax(
		{	
			data: $(form).serialize(),
			url:  $(form).attr('action'),
			type: $(form).attr('method'),
			success:  	function(msg)
						{
							$('#news_report').removeClass("newsletter_ok");
							$('#news_loader').css("display" , "none");
							
							msg = msg.split('|');
							var rtype = parseInt(msg[0]);
							msg = msg[1];
							
							if(rtype < 1)
							{
								$("#news_report").attr("innerHTML", msg);
								$('#news_report').css("display" , "block");
							}
							else
							{
								$("#news_report").attr("innerHTML", msg);
								$('#news_report').css("display" , "block");
								$('#news_report').addClass("newsletter_ok");
								$("#newsletter").value="";
							}
						}
		}
	); 			
	return false;		
			
}



function initDuk() {
	$('#duk ul').hide();
//	$('#duk ul:first').show();
	$('#duk li a').click(function() {
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
		}
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#duk ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
			return false;
		}
	});
}

var pagalba2=1;

function pagalba(){
  if(pagalba2==1){
   document.getElementById('pagalba').innerHTML="<div style=\"width:198px; height:128px; background:url(img/pagalba2.png);\"><div style=\"padding-top: 60px; padding-left:28px;\"><li> Pasakyk suaugusiam, kuriuo pasitiki. <li> Paskambink 11-61-11.</div></div>";
  }
  else document.getElementById('pagalba').innerHTML="<div><img src=\"img/pagalba.png\" alt=\"\" /></div>";
  pagalba2=pagalba2*(-1);
}

var xmlHTTP;
 
function sendmail(email, msg)
{
        if(window.XMLHttpRequest)
        {
                xmlHTTP = new XMLHttpRequest();
        }
        else if(window.ActiveXObject)
        {
                xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
        }
        
        if(xmlHTTP==null)
        {
                alert("Sorry You Browser No Supports XMLHTTP");
                return;
        }
        var url;
        url = "mail.php?email="+email;
        url+= "&msg="+msg;
        xmlHTTP.onreadystatechange=state;
        xmlHTTP.open("GET",url,true);
        xmlHTTP.send(null);
}
 
function state()
{
        var Message = document.getElementById('div_msg');
        var str;
        if(xmlHTTP.readyState==4)
        {
                str = xmlHTTP.responseText;               
        }
        else
        {
                str = "";
        }
        Message.innerHTML = str;
}

function send()
{
        var email = document.getElementById('email').value;
        var msg = document.getElementById('msg').value;
        sendmail(email, msg);       
}


