var banner_types = Array();
function showBanner(object, type, num) {
    if (type != 3 && type != 7 && type != 8){
        for(i = 1; i <= 6; i++) {
            if (i == 3) continue;
            if (frames['banner_' + banner_types[i]]){
                id = 0;
                eval('id = banners_' + banner_types[i] + '[' + num + '];');
                frames['banner_' + banner_types[i]].location = '/baner/index/id/' + id;
            }
        }
    }
    else {
        id = 0;
        eval('id = banners_' + object + '[' + num + '];');
        frames['banner_' + object].location = '/baner/index/id/' + id;
    }
}

function searchGo(){
    document.location = '/search/index/search/' + document.getElementById('searchstr').value + '/';
}

function searchGo2(){
    parent.document.location = '/search/index/search/' + document.getElementById('searchstr').value + '/';
}

function login(){
    document.getElementById('loginForm').submit();
}

function loginClick(e){
    if (e.keyCode == 13)
        login();
    return false;
}

function changeCountry(country){
    if (country == 'Latvija') {
        document.getElementById('town_select').style.display = 'block';
        document.getElementById('town_text').style.display = 'none';
    }
    else {
        document.getElementById('town_select').style.display = 'none';
        document.getElementById('town_text').style.display = 'block';
    }
}

function confirmDelete(){
    return window.confirm('Vai tiešām vēlaties dzēst savu profilu?');
}

function testCheckIfChecked(){
    var elements = document.getElementsByTagName('input');
    var checked = false;
    if (elements.length != 0) {
        for(var i = 0; i < elements.length; i++){
            if (elements[i].type == 'radio' && elements[i].checked == true){
                checked = true;
                break;
            }
        }
    }
    return checked;
}

function showFooterBanner(id){
	document.getElementById('footerBanner' + id).style.display = 'block';
}

/**
 * Dispay random text banner
 *
 * return boolean (always false)
 */
function showTextBanner()
{
	$.ajax({
		url: "http://www.espati.lv/baner/showtext",
		success: function(data){
			$("#text-banner-area").html(data);
		}
	});
	
	return false;
}

var sayTitle  = '';
var sayUrl    = '';
var sayPrefix = '';

function DraugiemSay(){
    window.open(
        'http://www.draugiem.lv/say/ext/add.php?title=' + encodeURIComponent( sayTitle ) +
        '&link=' + encodeURIComponent( sayUrl ) +
        ( sayPrefix ? '&titlePrefix=' + encodeURIComponent( sayPrefix ) : '' ),
        '_blank',
        'location=1,status=1,scrollbars=0,resizable=0,width=530,height=400'
    );
    return false;
}

function TwitterSay(){
	window.open('http://twitter.com/home/?status=' + sayTitle + ' - ' + sayUrl, '_blank', '');
	return false;
}

function FacebookSay(){
	window.open('http://www.facebook.com/share.php?u=' + encodeURIComponent( sayUrl ) + '&t=' + encodeURIComponent( sayTitle ), '_blank', '');
	return false;
}
