	hs.graphicsDir = '/highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.wrapperClassName = 'dark borderless floating-caption';
	hs.fadeInOut = true;
	hs.dimmingOpacity = .75;

    hs.loadingText = 'Ielādē';
    hs.closeTitle = 'Aiavērt';
	hs.loadingTitle  = 'Atceltt';
	hs.focusTitle  = 'Izvirzītu uz priekšu';
	hs.fullExpandTitle  = 'Palielināt līdz īstajam izmēram';
	hs.creditsText  = '';
	hs.creditsTitle  = '';
	hs.previousText  = 'Iepriekšējā';
	hs.nextText  = 'Nākošā';
	hs.moveText  = 'Pārvietot';
	hs.closeText  = 'Aivērt';
	hs.closeTitle  = 'Aizvērt';
	hs.resizeTitle  = 'Mainīt izmēru';
	hs.playText  = 'Sākt spēlēt';
	hs.playTitle  = 'Spēlēt';
	hs.pauseText  = 'Pause';
	hs.pauseTitle  = 'Sākt spēlēt';
	hs.previousTitle  = 'Iepriekšējā';
	hs.nextTitle  = 'Nākošā';
	hs.moveTitle  = 'Pārvietot';
	hs.fullExpandText  = 'Pilnais izmērs';
	hs.number = 'Attēls %1 no %2';
	hs.restoreTitle  = '';

	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: .6,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});


jQuery(function() {

    if(jQuery("#datepicker").length){
        jQuery("#datepicker").datepicker({
            dateFormat: 'dd.mm.yy',
            dayNamesMin: ['Sv', 'P', 'O', 'T', 'C', 'Pk', 'S'],
            firstDay: 1,
            monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs','Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
            onSelect: function(dateText) {
                window.location.href="/pasakumi/?no="+dateText+"&cat=-1&string=&action=filter";
            }
        });
    }

    jQuery("#menu a").hover(
      function () {
        jQuery(this).addClass("menuhover");
      },
      function () {
        jQuery(this).removeClass("menuhover");
      }
    );



    jQuery(".advert").click(function(e) {
        var id = this.id;
        var descr = this.getAttribute("alt");
        var leftVal=(screen.width-755)/2;
        var topVal=(screen.height-520)/2;
        window.open( id, "fffffff", "status=0,height=490,width=755,left="+leftVal+",top="+topVal+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=0,resizable=yes" );

	});
    jQuery(".advert_last").click(function(e) {
        var id = this.id;
        var descr = this.getAttribute("alt");
        var url = this.getAttribute("href");
        var leftVal=(screen.width-755)/2;
        var topVal=(screen.height-500)/2;
        window.open( url, "fffffff", "status=0,height=470,width=755,left="+leftVal+",top="+topVal+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,copyhistory=0,resizable=yes" );

	});
    jQuery('.bannertracker').click(function(e) {
        link = '/bannertracker.php?tracker='+this.id;
        dataString = '';
		jQuery.ajax({
            type: "POST",
            data: dataString,
            url: link,
            success: function(data) {
                //alert(data);
            }
        });
    });

    jQuery(".newscontainer").hover(function() {
    	jQuery(this).css({'background-color' : '#F2F2F2'});

    	} , function() {
    	jQuery(this).css({'background-color' : ''});
    });

    window.setTimeout("changeweathertime()",5000);
});



function changeweathertime(){
    if(document.getElementById("currentdate").style.display=='block'){
        document.getElementById("currentweather").style.display = 'block';
        document.getElementById("currentdate").style.display = 'none';
    }else{
        document.getElementById("currentweather").style.display = 'none';
        document.getElementById("currentdate").style.display = 'block';
    }
    window.setTimeout("changeweathertime()",5000);
}
function genpasts(prefix,postfix)
{
	if (prefix!='' && postfix!='')
	{
		var pasts=prefix;
			pasts=pasts+'@';
			pasts=pasts+postfix;

		document.write('<a href="mailto:'+pasts+'"  <font class="font1">'+pasts+'</font></a>');
	}
	else document.write('-');
}

function submitQuestionForm(parameter){

    jQuery('#action').val(parameter);
    document.pollForm.submit();

}

function page(l){
    //$('templates_loading').show();
    jQuery('#limit').val(l);
    document.adminForms.submit();

}
function submitloginform(ref){
    jQuery('#loginmessageform').hide();
    jQuery('#loading').show();

    var name = jQuery("#username").val();
    var pass = jQuery("#userpassword").val();
    
    jQuery.post("/login/submitmodalwindow/?message=true", {F_LOGIN_NAME:name,F_LOGIN_PASSWORD:pass },
	    function(data) {
            if(data=='true'){
                //if(jQuery('#reload').val()==1){
                window.location.reload();
                //}else{
                //    jQuery.modal.close();
                //    alert('Veiksmīga autorizēšanās, varat turpināt!');
                //}
            }else{
                jQuery('#message').html(data);
                jQuery('#loading').hide();
                jQuery('#loginmessageform').show();
                jQuery("#userpassword").val('');
            }
		}
	);
}
function checkforsubcat(){
    var cat = jQuery('#category').val();
    jQuery.post("/usertools/checkfornewscategory/", {F_CATEGORY:cat },
	    function(data) {
            jQuery('#sub_cat').html(data);;
		}
	);
}
function showeventsubcat(id_category){
    jQuery('#eventcat').val(id_category);
    //alert(jQuery('#eventcat').val());
    jQuery('#subcat').html('');
    jQuery('#subcat').addClass('loadingeventsubcat');
    jQuery('#cat a').css('font-weight','normal');
    jQuery.post("/events/checkforeventssubcategory/", {F_CATEGORY:id_category},
	    function(data) {
            jQuery('#cat'+id_category).css('font-weight','bold');
            jQuery('#subcat').html(data);;
            jQuery('#subcat').removeClass('loadingeventsubcat');
		}
	);
}


function checkeventsubcat(id_category){
    var l = jQuery('#pcat'+id_category+' input:checked').length;
    //var tl = jQuery('#pcat'+id_category+' input').length;

    if (l==0) {
        jQuery('#pcat'+id_category+' input').attr('checked',true);
    }else {
        jQuery('#pcat'+id_category+' input').attr('checked',false);
    }
}
function showevent(id_event,link){
    jQuery('#'+id_event).toggle();
    if(jQuery('#'+id_event).is(':visible')){
        dataString = 'id_event='+id_event;
		jQuery.ajax({
            type: "GET",
            data: dataString,
            url: link,
            success: function(data) {
            }
        });


    }
}
function cleareventfilter(link){
    jQuery('#no').val('');
    jQuery('#lidz').val('');
    jQuery('#string').val('');
    jQuery('.eventsubcategories input').attr('checked',false);
    //jQuery('#subcat').html('');
    //jQuery('#eventcat').val('');
    window.location.href=link;
    //jQuery('#cat a').css('font-weight','normal');

}
function clearplacefilter(){
    jQuery('#cat input').attr('checked','');
    jQuery('#string').val('');
}
function submituserform(action,lang){
        //var dataString = jQuery("#userForm").serialize();//'folder='+action
        jQuery('#loadingUserForm').addClass('loadingUserForm');
        jQuery('#loadingUserForm').show();
        document.getElementById('userFormDiv').style.display = 'none';
        jQuery('#userFormDiv').hide();

        var inputs = jQuery("#userFormDiv input");
        var queryString = inputs.serialize();
        if(lang!=''){lang = '/'+lang;}
        var link = '/login/';
		jQuery.ajax({
            type: "POST",
            url: "/login/",
            data: queryString,
            success: function(data) {
                if(data=='true'){
                    //jQuery("#username").autocomplete(jQuery("#username").val());
                    //alert(jQuery("#username").val());
                    window.location.reload();
                }else{
                    document.getElementById('loadingUserForm').style.display = 'none';
                    document.getElementById('userFormDiv').style.display = 'block';
                    jQuery('#userFormDiv').html(data);
                    jQuery('#loadingUserForm').removeClass("loadingUserForm");
                }
            }
     });

}
function searchKeyPress(e,button,arg){
    if (window.event) { e = window.event; }
    if (e.keyCode == 13){
        if(button=='submituserbutton'){
            submitloginform(arg);
        }else if(button=='submituserform'){
            submituserform('');
        }else if(button == 'submitforgotpassword'){
            document.userform.submit();
        }
        //document.getElementById(button).click();
    }
}

function submitKeyPress(e,button){
    // look for window.event in case event isn't passed in
    if (window.event) { e = window.event; }
    if (e.keyCode == 13){
        document.getElementById(button).click();
    }
}
function submitcomment(){
    //var name = jQuery('#name').val();

    //var comment = jQuery('#comment').val();
    //if(name.length<2 || comment.length<10 || jQuery('#code').val()!=jQuery('#code_hidden').val()){
    var dataString = jQuery('#commform').serialize();
    jQuery('#commentform').height(jQuery('#commentform').height());
    jQuery('#commentform').html('');
    jQuery('#commentform').addClass('loadingcommentform');

    //jQuery('#commentFormWin').addClass("loadingForm");
        //if(name.length<2){jQuery('#name_warning').show();}else{jQuery('#name_warning').hide();}
        //if(comment.length<10){jQuery('#comment_warning').show();}else{jQuery('#comment_warning').hide();}
        //if(jQuery('#code').val()!=jQuery('#code_hidden').val()){jQuery('#code_warning').show();}else{jQuery('#code_warning').hide();}
    jQuery.ajax({
        type: "POST",
        url: "/news/post_article_comment/",
        data: dataString,
        success: function(data) {
            //alert(data);
            if(data=='1'){
                window.location.href='?opcija=komentari';
            }else{
                jQuery('#commentform').html(data);
                jQuery('#commentform').removeClass('loadingcommentform');
            }
            //document.getElementById('commForm').submit();
            //jQuery('#commentform').show();
        }
    });
    //jQuery('#commentFormWin').removeClass("loadingForm");
    //}else{

    //}
}

function submitjokecomment(){

    var dataString = jQuery('#commform').serialize();
    jQuery('#commentform').html('');
    jQuery('#commentform').addClass('loadingcommentform');

    jQuery.ajax({
        type: "POST",
        url: "/blog/post_joke_comment/",
        data: dataString,
        success: function(data) {
            //alert(data);
            if(data=='1'){
                window.location.reload();
            }else{
                jQuery('#commentform').html(data);
                jQuery('#commentform').removeClass('loadingcommentform');
            }
        }
    });

}

function submitpollcomment(){
    var dataString = jQuery('#commform').serialize();
    jQuery('#commentform').html('');
    jQuery('#commentform').addClass('loadingcommentform');
    jQuery.ajax({
        type: "POST",
        url: "/poll/post_comment/",
        data: dataString,
        success: function(data) {
            //alert(data);
            if(data=='1'){
                window.location.reload();
            }else{
                jQuery('#commentform').html(data);
                jQuery('#commentform').removeClass('loadingcommentform');
            }

        }
    });

}
function submitvideocomment(){
    var dataString = jQuery('#commform').serialize();
    jQuery('#commentform').html('');
    jQuery('#commentform').addClass('loadingcommentform');
    jQuery.ajax({
        type: "POST",
        url: "/video/post_comment/",
        data: dataString,
        success: function(data) {
            //alert(data);
            if(data=='1'){
                window.location.reload();
            }else{
                jQuery('#commentform').html(data);
                jQuery('#commentform').removeClass('loadingcommentform');
            }

        }
    });

}
/* Message length check of comments*/
var len = 0;
var msg = 0;
var max_comments = 1000;
function do_comment_check() {
    //alert(smslen);
    //alert(msgid);
    //alert(id);
    //alert(jQuery('#commentleft').html());

	//if (!len) { len = document.getElementById(smslen); }
	comment = document.getElementById('comment');//jQuery('#comment').val();

	if (comment.value.length > max_comments) { jQuery('#comment').val(comment.value.substring(0, max_comments));}
	 jQuery('#commentleft').html((max_comments - comment.value.length));

}

function submitimagecomment(id_image){
    //var name = jQuery('#name').val();

    //var comment = jQuery('#comment').val();
    //if(name.length<2 || comment.length<10 || jQuery('#code').val()!=jQuery('#code_hidden').val()){

    var inputs = jQuery("input, textarea");
    var queryString = inputs.serialize();

    //var queryString = jQuery('#commform').serialize();
    jQuery('#commentform').html('');
    jQuery('#commentform').addClass('loadingcommentform');
    //jQuery('#commentFormWin').addClass("loadingForm");
        //if(name.length<2){jQuery('#name_warning').show();}else{jQuery('#name_warning').hide();}
        //if(comment.length<10){jQuery('#comment_warning').show();}else{jQuery('#comment_warning').hide();}
        //if(jQuery('#code').val()!=jQuery('#code_hidden').val()){jQuery('#code_warning').show();}else{jQuery('#code_warning').hide();}
    jQuery.ajax({
        type: "POST",
        url: "/gallery/post_image_comment/",
        data: queryString,
        success: function(data) {
            //alert(data);
            if(data=='1'){
                //jQuery('#imagecommentslist').hide();
                //jQuery('#imagecommentslist').show();
                //alert(id_image);
                var  comm = getcommnetlist(id_image);
                //alert(comm);

            }else{
                jQuery('#commentform').html(data);
                jQuery('#commentform').removeClass('loadingcommentform');
            }
            //document.getElementById('commForm').submit();
            //jQuery('#commentform').show();
        }
    });
    //jQuery('#commentFormWin').removeClass("loadingForm");
    //}else{

    //}
}
function getcommnetlist(id_image){
    var dataString = 'F_ID_IMAGE='+id_image;
    var link = "/gallery/comment_list/";
    //alert(link);
    jQuery.ajax({
        type: "POST",
        url: link,
        data: dataString,
        success: function(data) {
            //alert('west');
            //alert(data);
            jQuery('#imagecommentslist').html(data);
        }
    });
}
function submitform(parameter){
    jQuery('#ListLoadingGif').show();
    jQuery("#F_ACTION").val(parameter);
    //document.getElementById('adminForm').submit();
    jQuery("#adminform").submit();
    //document.adminForm.submit();
}
function creategallery(){
    jQuery('#creatinggallery').show();
    var inputs = jQuery("input,select");
    var queryString = inputs.serialize();
    var link = '/usertools/save_gallery/';
	jQuery.ajax({
        type: "POST",
        url: link,
        data: queryString,
        success: function(data){
            //alert(data);

            if(data==parseFloat(data)){
                alert('Galerija veidošana tūlīt tiks pabeigta. To varēsiet publicēt, ja būsiet pievienojis attēlus un atķeksējis "Publicēt".');
                window.location.href=data;
            }else{
                jQuery("#warningfield").html(data);
                jQuery('#creatinggallery').hide();
            }
        }
    });
}
function savecomments(){
    var inputs = jQuery("input");
    var queryString = inputs.serialize();
    var link = '/usertools/save_comments/';
	jQuery.ajax({
        type: "POST",
        url: link,
        data: queryString,
        success: function(data){
            alert('Komentāri un secība saglabāta!');
            window.location.reload();
        }
    });
}
function submitgallery(id){

    jQuery('#addnew div').hide();
    jQuery('#addnew').css('height', '24px');
    jQuery('#addnew').css('background', 'url(/images/ajax_small.gif) center no-repeat');

    var queryString = jQuery('#form1').serialize();
    var link = '/usertools/confirm_gallery/';
	jQuery.ajax({
        type: "POST",
        url: link,
        data: queryString,
        success: function(data){
            if(data=='true'){
                alert('Galerija veidošana pabeigta (tā tiks publicēta, ja būsiet atķeksējis "Publicēt".');
                window.location.reload();
            }else{
                alert(data);
                //setTimeout(function() { }, 2500);
                jQuery('#addnew').css('background-image', '');
                jQuery('#addnew div').show();

            }
        }
    });
}
function submiteditedgallery(id){

    jQuery('#addnew div').hide();
    jQuery('#addnew').css('height', '24px');
    jQuery('#addnew').css('background', 'url(/images/ajax_small.gif) center no-repeat');
    var queryString = jQuery('#form1').serialize();
    var link = '/usertools/confirm_edited_gallery/';

    jQuery.ajax({
        type: "POST",
        url: link,
        data: queryString,
        success: function(data){
            if(data=='true'){
                alert('Galerija saglabāta');
                window.location.reload();
            }else{
                alert(data);
                //setTimeout(function() { }, 2500);
                jQuery('#addnew').css('background-image', '');
                jQuery('#addnew div').show();

            }
        }
    });
}

function delete_advert_image(img,id){
    var queryString = 'F_IMAGE='+img
    var link = '/advert/delete_tmp_image/';

    var limit = parseInt(jQuery('#remaining-img').html());
    if(limit==0)jQuery('#sfw-button').show();

    limit=limit+1;

    //swfu.setFileUploadLimit(limit);
    swfu.settings.file_upload_limit = limit;
    //swfu.settings.file_queue_limit = limit;
    //swfu.callFlash('SetFileUploadLimit', limit);
    //alert(swfu.settings.file_upload_limit);
    //alert(swfu.settings.file_queue_limit);
    jQuery('#remaining-img').html(limit);

    jQuery('#'+id).remove();

  	jQuery.ajax({
        type: "POST",
        url: link,
        data: queryString,
        success: function(data){
            //alert(data);
        }
    });

}

function removeimage(id){
    var queryString = 'F_ID_IMAGE='+id
    var link = '/usertools/delete_image/';

	var answer = confirm("Dzēst galerijas attēlu? Tiks dzēsti arī attēla komentāri!")
	if (answer){
    	jQuery.ajax({
            type: "POST",
            url: link,
            data: queryString,
            success: function(data){
                jQuery('#image'+id).hide();
            }
        });
	}else{
		//alert("Thanks for sticking around!")
	}
}
function deletegallery(id_gallery){

	var answer = confirm("Dzēst visu galeriju? Tiks dzēsti neatgriezeniski visi attēli un to komentāri!")
	if (answer){
        var dataString = 'F_ID_GALLERY='+id_gallery;
        var link = '/usertools/delete_gallery/';
    	jQuery.ajax({
            type: "POST",
            url: link,
            data: dataString,
            success: function(data){
                //alert('Galerija dzēsta!');
                //alert(data);
                window.location.href=data;
            }
        });
	}else{
		//alert("Thanks for sticking around!")
	}
}
function submit_forum_topic(){

    jQuery('.forumcommentform').hide();
    jQuery('#loadingtopic_form').css('background', '#ffffff url(/images/loader_question.gif) center no-repeat');

    document.newtopicform.submit();
}
function add_reply_form(field,id,msg){
        jQuery("#"+field).html("");
        jQuery("#"+field).addClass('replyloading');
        var dataString = 'F_ID_REPLY='+field+'&F_ID_TOPIC='+id+'&F_MSG='+msg;
        var link = '/forum/add_reply_form/';
		jQuery.ajax({
            type: "POST",
            url: "/forum/add_reply_form/",
            data: dataString,
            success: function(data){
                if(data=='false'){
                    window.location.href='/';
                }else if(jQuery("#"+field).html()==""){
                    jQuery("#"+field).html(data);
                }else{
                    jQuery("#"+field).html("");
                }
                jQuery("#"+field).removeClass('replyloading');
            }
     });
}
function add_reply(field,id,forma,hideform){
        jQuery("#"+field).addClass('replyloading');
        jQuery('#'+hideform).hide();
        var link = '/forum/add_reply_form/';
		jQuery.ajax({
            type: "POST",
            url: "/forum/add_reply_form/",
            data: jQuery('#'+forma).serialize(),
            success: function(data){
                if(data=='true'){
                    window.location.reload();
                }
                if(data=='false'){
                    window.location.href='/';
                }
                if(data!='false' && data!='true'){
                    jQuery("#"+field).html(data);
                    jQuery('#'+hideform).show();
                    jQuery("#"+field).removeClass('replyloading');
                }
            }
     });
}
/* Message length check */
var len = 0;
var msg = 0;
var maxlength_notes = 1000;
function doChange_sms_note(smslen,msgid) {
	if (!len) { len = document.getElementById(smslen); }
	if (!msg) { msg = document.getElementById(msgid); }
	if (msg.value.length > maxlength_notes) { msg.value = msg.value.substring(0, maxlength_notes); }
	len.value = (maxlength_notes - msg.value.length);
}


function add_map_place(){
    var submit = true;

    if(jQuery("#coordinates").val()==''){
        jAlert('Nav norādīta vieta kartē!','Paziņojums');
        submit = false;
    }
    if(jQuery("#place_name").val()==''){
        jAlert('Nav norādīta vietas nosaukums!','Paziņojums');
        submit = false;
    }
    if(jQuery("#place_descr").val()==''){
        jAlert('Nav norādīts īss vietas apraksts!','Paziņojums');
        submit = false;
    }

    if(submit!=false){


    	jQuery.ajax({
            type: "POST",
            url: "/lv/objects/save_place_in_map/",
            data: jQuery('#mapform').serialize(),
            success: function(data){
                window.parent.add_selected_place(data);

            }
        });


    }
}
function add_selected_place(id_object){
        dataString = 'F_ID_OBJECT='+id_object;
    	jQuery.ajax({
            type: "POST",
            url: "/lv/objects/publish_google_map/",
            data: dataString,
            success: function(data){

                show_object_points_in_map(id_object);

                jQuery("#place_in_map").html(data);
            }
        });

    SqueezeBox.close();
}

function show_object_points_in_map(id){

	jQuery.ajax({
        type: "POST",
        url: "/catalog/publish_map_coordinates/?F_ID_OBJECT="+id,
        dataType: "xml",
        error: function(xml){
            alert('Error loading XML document: ' + xml);
        },
        success: function(xml) {

            jQuery("map", xml).each(function(i){
                var _maptype = jQuery(this).find('maptype').text();
                var _coordinate = jQuery(this).find('coordinate').text();
                var _name = jQuery(this).find('name').text();
                var _descr = jQuery(this).find('descr').text();
                descr = '<b>' +_name+ '</b><br /><div style="width:200px;">' +_descr+ '</div>';

                showAddress(_maptype,_coordinate,_name,descr);
            });
        }
    });


}

function remove_place_from_map(id_map,id_object){

        var dataString = 'F_ID_MAP='+id_map

    	jQuery.ajax({
            type: "POST",
            url: "/lv/objects/delete_place_in_map/",
            data: dataString,
            success: function(data){
                map.clearOverlays();

                add_selected_place(id_object);
                show_object_points_in_map(id_object);
            }
        });
}




function show_points_window(){

    jQuery.post("/login/user_points/", { },
	    function(data) {
            jQuery.modal(jQuery("#modalmessage").html(data));
		}
	);
}

function show_quiz_points_window(){

    var data = '<div id="loading"></div><div id="quiz_points_content">';
    data = data + jQuery("#quizmodalmessage").html() + '</div>'
    jQuery.modal(data);
}

function show_default_points_window(){
    jQuery.post("/login/user_default_points/", { },
	    function(data) {
            jQuery.modal(data);
		}
	);
}
function showloginform(param){
    jQuery.post("/login/user_register_form/", {param:param },
	    function(data) {
            jQuery.modal(data);
            jQuery('#username').focus();
		}
	);
}
function refresh_quiz_points(){

    jQuery('#quiz_points_content').hide();
    jQuery('#loading').show();

    jQuery.post("/login/get_user_points/", {},
	    function(data) {
            if(data=='false'){
                window.location.href='/';
            }else{
                jQuery('#user_points').html(data);
                jQuery.modal.close();
            }
		}
	);

}
function deleteprofileimage(id){

    jQuery('#profileimage').html('');
    jQuery('#profileimage').addClass('loadingdeleteprofileimage');
    jQuery.post("/userreg/deleteprofileimage/", { id:id },
	    function(data) {
            jQuery('#profileimage').removeClass('loadingdeleteprofileimage');
            alert('Profila attēls dzēsts!');

		}
	);
}


function submitpoll(){
    var pid = jQuery('#id_poll').val();
    var checkValues = [];
    jQuery('#poll_inner input:checked').each(function() {
        checkValues.push(jQuery(this).val());
    });
    var checkSegmentStatus = checkValues.join(",");
    if(checkSegmentStatus==''){
        showpollmodal();
        //alert('Atzīmējiet atbildi!');
        return;
    }

    jQuery.post("/poll/submitpoll/", {pid:pid, answers: checkSegmentStatus },
	    function(data) {
            jQuery('#poll_inner').hide();
            jQuery('#poll_inner').html(data).fadeIn('slow');
            //setTimeout('showpollanswers('+pid+')',2000);
            //showpollanswers(pid,'true');
		}
	);

}

function showpollanswers(pid,t){

    jQuery.post("/poll/showpollanswersinner/", {pid:pid,submit:t },
	    function(data) {
            jQuery('#poll_inner').hide()
            jQuery('#poll_inner').html(data).fadeIn('slow');
		}
	);


}
function showpollmodal(){
    jQuery('#poll_inner').hide();
    jQuery('#seepollresults').hide();
    jQuery('#pollmodalwindow').show();
    jQuery('#pollhidebutton').show();
}
function hidepollmodal(){
    jQuery('#poll_inner').show("slow");
    jQuery('#seepollresults').show();
    jQuery('#pollmodalwindow').hide("slow");
    jQuery('#pollhidebutton').hide();
    jQuery('#loadingsubmitbutton').hide();
    jQuery('#submitbutton').show();
}
function search_in_google_map(){

    jQuery('#mapresultsloading').addClass('loadingmapsearchresults');
    jQuery('#mapsearchresults').html('');
    jQuery.post("/catalog/get_google_map_result/", { address:jQuery("#mapstring").val()},
		  function(data) {
             jQuery('#mapsearchresults').html(data);
             jQuery('#mapresultsloading').removeClass('loadingmapsearchresults');
		  });
}

function DraugiemSay( title, url, titlePrefix ){
    window.open(
        'http://www.draugiem.lv/say/ext/add.php?title=' + encodeURIComponent( title ) +
        '&link=' + encodeURIComponent( url ) +
        ( titlePrefix ? '&titlePrefix=' + encodeURIComponent( titlePrefix ) : '' ),
        '',
        'location=1,status=1,scrollbars=0,resizable=0,width=530,height=400'
        );
    return false;
}
function ratearticle(ar,vote){
    jQuery('#article_'+ar+' .posv').attr('onclick','false');
    jQuery('#article_'+ar+' .negativevote').html('');
    jQuery('#article_'+ar+' .positivevote').html('');
    jQuery.post("/blog/articlevote/", {article: ar, vote: vote},
	    function(data) {
            if(data!=''){
                if(vote=='-1'){
                    jQuery('#article_'+ar+' .negativevoter').html(data);
                }
                if(vote=='+1'){
                    jQuery('#article_'+ar+' .positivevoter').html(data);
                }
            }
		}
	);


}
function ratejoke(joke,vote){
    jQuery('#article_'+joke+' .posv').attr('onclick','false');
    jQuery('#article_'+joke+' .negativevote').html('');
    jQuery('#article_'+joke+' .positivevote').html('');
    jQuery.post("/blog/jokevote/", {joke: joke, vote: vote},
	    function(data) {
            if(data!=''){
                if(vote=='-1'){
                    jQuery('#joke_'+joke+' .negativevoter').html(data);
                }
                if(vote=='+1'){
                    jQuery('#joke_'+joke+' .positivevoter').html(data);
                }
            }
		}
	);


}

function imagecompetitionvote(image,gallery){



    jQuery.post("/gallery/imagecompetitionvote/", {image: image, gallery:gallery},
	    function(data) {
            jQuery('#votebutton').addClass('voted');
            jQuery('#votebutton').html('Balsojums pieņemts');
		}
	);
}

var cat_array = new Array();
function isCheckedObject(isitchecked,val){
	if (isitchecked == true){
		cat_array[cat_array.length] = val;
	}else{
		cat_array.splice(cat_array.indexOf(val),1);
	}
}

function addnewblog(param){

    jQuery('#addnew').css('background', 'url(/images/ajax_small.gif) center no-repeat');
    jQuery('#addnew a span').hide();
    jQuery.post("/usertools/get_form_link/", {param:param },
	    function(data) {
            if(data==-1){
                showloginform(param);
                setTimeout(function() {jQuery('#addnew').css('background', 'url(/images/newsbutton.gif) center no-repeat'); jQuery('#addnew a span').show(); }, 2500);
            }else{
                window.location.href=data;
            }
		}
	);
}


                function nextimage() {
                        firstimage=parseFloat(firstimage)+1;
                        if(!imgarray[firstimage]){
                            firstimage = 0;
                        }
                        jQuery(".overlay").addClass("gallery_wrap_overlay");

                        jQuery("#galleryheader a.numbering").css('font-weight', '');
                        jQuery("#href"+imgarray[firstimage]).css('font-weight', 'bold');

                        //jQuery("#nextimage").hide();
                        //jQuery("#image_wrap").html("");
                        //jQuery("#image_wrap").hide();
                        //jQuery("#image_wrap_loading").addClass("waitingforimage");

                        var queryString = "F_ID_IMAGE="+imgarray[firstimage]+"&url="+current_url;
                        var link = "/gallery/get_image_for_catalog/";
                        //alert(link);
                    	jQuery.ajax({
                            type: "POST",
                            url: link,
                            data: queryString,
                            success: function(data){
                                //alert(data);
                                data = data.split("|",3);
                                //alert(data[0]);

                                jQuery("#image_wrap").html("");
                                jQuery("#image_wrap").hide();
                                //jQuery("#image_wrap").show();
                                jQuery("#image_wrap").html(data[1]).fadeIn("slow");

                                //jQuery("#previmage").height(parseFloat(data[0]));
                                //jQuery("#nextimage").height(parseFloat(data[0]));
                                showvotestars(data[2]);
                                jQuery(".overlay").removeClass("gallery_wrap_overlay");
                                //jQuery("#nextimage").show();

                                //jQuery("#image_wrap_loading").removeClass("waitingforimage");
                            }
                        });
                    }



                function previmage() {
                        firstimage = parseFloat(firstimage) -1;
                        if(!imgarray[firstimage]){
                            firstimage = imgarray.length-1;
                        }
                        jQuery("#galleryheader a.numbering").css('font-weight', '');
                        jQuery("#href"+imgarray[firstimage]).css('font-weight', 'bold');

                        jQuery(".overlay").addClass("gallery_wrap_overlay");

                        //jQuery("#previmage").hide();
                        //jQuery("#image_wrap").html("");
                        //jQuery("#image_wrap").hide();
                        //jQuery("#image_wrap_loading").addClass("waitingforimage");
                        //var current_url = \''.$current_url.'\';
                        var queryString = "F_ID_IMAGE="+imgarray[firstimage]+"&url="+current_url;
                        var link = "/gallery/get_image_for_catalog/";
                    	jQuery.ajax({
                            type: "POST",
                            url: link,
                            data: queryString,
                            success: function(data){
                                //alert(data);
                                data = data.split("|",3);

                                jQuery("#image_wrap").html("");
                                jQuery("#image_wrap").hide();
                                //jQuery("#image_wrap").show();
                                jQuery("#image_wrap").html(data[1]).fadeIn("slow");


                                //jQuery("#previmage").height(parseFloat(data[0]));
                                //jQuery("#nextimage").height(parseFloat(data[0]));

                                //jQuery("#previmage").show();
                                //jQuery("#image_wrap_loading").removeClass("waitingforimage");
                                showvotestars(data[2]);
                                jQuery(".overlay").removeClass("gallery_wrap_overlay");
                            }
                        });
                    }


