﻿function cookiedetect() {    
    if (document.cookie == "") {    
        document.getElementById("cookie").innerHTML = '<p class="text" style="text-align: left;"><font style="color: #FF0000; font-weight: bold;">Dėmesio!</font> Normaliam "Draugas.lt" svetainės darbui yra būtina, kad tavo interneto naršyklė priiminėtų taip vadinamus "sausainėlius" (angl. cookie). Tik jų dėka tu gali prisijungti prie klubo nario zonos, rašyti laiškus ir pan.</p>';
    }
}

var checkflag = false;
function checkall(field) {
if (checkflag == false) {
for (i = 0; i < field.length; i++)
    field[i].checked = true;
    checkflag = true;
}
else {
for (i = 0; i < field.length; i++)
    field[i].checked = false;
    checkflag = false;
} }

function flip(rid) {
    current=(document.getElementById(rid).style.display == 'none') ? 'block' : 'none';
    document.getElementById(rid).style.display = current;
}

function loadinparent(url, closeSelf) {
    self.opener.location = url; if(closeSelf) self.close();
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getFlashMovieObject(movieName)
{
    if (window.document[movieName]) 
    {
         return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1)
    {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName]; 
    }
    else
    {
        return document.getElementById(movieName);
    }
}

function PlayFlashMovie(garsas)
{
    var flashMovie=getFlashMovieObject(garsas);
    flashMovie.Play();
}

function insertAtCursor(myField, myValue) {
    if (document.selection) {
        myField.focus();
    sel = document.selection.createRange();
        sel.text = myValue;
    }
    else if (myField.selectionStart || myField.selectionStart == '0') {
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        myField.value = myField.value.substring(0, startPos)
        + myValue
        + myField.value.substring(endPos, myField.value.length);
    } else {
        myField.value += myValue;
    }	
}

Date.prototype.age = function(at) {
    var value = new Date(this.getTime());
    var age = at.getFullYear() - value.getFullYear();
    value = value.setFullYear(at.getFullYear());
    if (at < value) --age;
    return age;
};

function GetAgeFromDate(year, month, day) {
    return ( new Date(Date.parse(year + "/" + month + "/" + day)) ).age( new Date() );
}

jQuery("document").ready(function() {						
	jQuery("a.meniu_url").mouseenter(function() {
		jQuery(this).find(".meniu_url2").css({ "textDecoration": "underline" });
		jQuery(this).find(".meniu_url3").css({ "cursor": "pointer" });
	});			
	jQuery("a.meniu_url").mouseleave(function() {
		jQuery(this).find(".meniu_url2").css({ "textDecoration": "none" });
	});						
});