function Bottom (id, level)
{
    window.location.href=webroot+'/Admin/Site/Services/EditCat/Bottom/'+id+'/'+level+'.html';
}

function Right (id, level)
{
    window.location.href=webroot+'/Admin/Site/Services/EditCat/Right/'+id+'/'+level+'.html';
}

function Edit (type, id)
{
    if (type == 'C')
    {
        window.location.href=webroot+'/Admin/Site/Services/EditCat/'+id+'.html';
    }
    else if (type == 'I')
    {
        window.location.href=webroot+'/Admin/Site/Services/EditItem/'+id+'.html';
    }
}

function Delete (type, id, cat)
{
    if (type == 'C')
    {
        if (confirm ('Tikrai ištrinti?'))
        {
            window.location.href=webroot+'/Admin/Site/Services/DeleteCat/'+id+'.html';
        }
    }
    else if (type == 'I')
    {
        if (confirm ('Tikrai ištrinti?'))
        {
            window.location.href=webroot+'/Admin/Site/Services/DeleteItem/'+id+'/'+cat+'.html';
        }
    }
}

function UploadPhoto (id)
{
    var ptime = document.getElementById('PTime');

    if (ptime.value != '')
    {
        url = id+'/'+ptime.value+'.html';
    }
    else
    {
        url = id+'.html';
    }

    window.open (webroot+'/Admin/Site/Services/Photo/'+url, '', 'dependent=yes, width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, copyhistory=yes, resizable=no, top=200, left=200');
}

function Uploaded (id, time)
{
    var place = document.getElementById('pp');
    var old = document.getElementById('op');

    if (old != null)
    {
        place.removeChild(old);
    }

    if (document.getElementById('up_'+id))
    {
        place.removeChild(document.getElementById('up_'+id));
    }

    var photo = document.createElement ('img');

    photo.setAttribute ('id', 'up_'+id);

    photo.src = webroot+'/MUP/Services/item_'+id+'T_'+time+'.png';

    place.appendChild(photo);

    document.getElementById('PTime').setAttribute ('value', time);
}

function Preview (id)
{
    window.open (webroot+'/Admin/Site/Services/Preview/'+id+'.html', '', 'width=500, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, copyhistory=yes, resizable=no');
}

function Resize ()
{
    var img = document.getElementById('photo');

    window.resizeTo(img.width+30, img.height+100);
}

function Display ()
{
    var ld = document.getElementById('ld');
    var bd = document.getElementById('Preview');

    ld.style.display = 'none';
    bd.style.display = 'block';
}

function Close ()
{
    window.close();
}

function CheckIndividualFields() {
	var lastname = document.getElementById('lastname');
	var name = document.getElementById('name');
	var middle = document.getElementById('middle');
	var ed_level = document.getElementById('education_level');
	var spec = document.getElementById('specialization');
	var country = document.getElementById('country');
	var contact_email = document.getElementById('contact_email');
	var email = document.getElementById('email');
	var phone = document.getElementById('phone');
	var agree = document.getElementById('agree');
	
	if ((lastname.value != '') && (name.value != '') && (middle.value != '') && (ed_level.value != '') && (spec.value != '') && (country.value != '') && (contact_email.value != '') && (email.value != '') && (phone.value != '')) {
		if (agree.checked == true){
		    return true;
		}
		else {
		    alert ('You have to agree licence');
		    return false;
		}
	} else {
		alert('All fields must be filled in!');
		return false;
	}
		
}


function CheckCollectiveFields() {
	var org = document.getElementById('organization');
	var contact_email = document.getElementById('contact_email');
	var email = document.getElementById('email');
	var phone = document.getElementById('phone');
	var agree = document.getElementById('agree');
	var members = document.getElementById('members');
	
	if ((members.value != '') && (org.value != '') && (contact_email.value != '') && (email.value != '') && (phone.value != '')) {
		if (agree.checked == true){
		    return true;
		}
		else {
		    alert ('You have to agree licence');
		    return false;
		}
	} else {
		alert('All fields must be filled in!');
		return false;
	}
		
}