	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  = 'Spiest lai atceltu';
	hs.focusTitle  = 'Spiest lai izvirzītu uz priekšu';
	hs.fullExpandTitle  = 'Palielināt līdz īstajam izmēram (f)';
	hs.creditsText  = '';
	hs.creditsTitle  = '';
	hs.previousText  = 'Iepriekšējā';
	hs.nextText  = 'Nākošā';
	hs.moveText  = 'Pārvietot';
	hs.closeText  = 'Aivērt';
	hs.closeTitle  = 'Aizvērt (esc)';
	hs.resizeTitle  = 'Mainīt izmēru';
	hs.playText  = 'Sākt spēlēt';
	hs.playTitle  = 'Spēlēt (spacebar)';
	hs.pauseText  = 'Pause';
	hs.pauseTitle  = 'Sākt spēlēt  (spacebar)';
	hs.previousTitle  = 'Iepriekšējā (arrow left)';
	hs.nextTitle  = 'Nākošā (arrow right)';
	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(document).ready(function() {

    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(".discount").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('.bannertracker').click(function(e) {
        link = '/bannertracker.php?tracker='+this.id;
        dataString = '';
		jQuery.ajax({
            type: "POST",
            data: dataString,
            url: link,
            success: function(data) {
                //alert(data);
            }
        });
    });


});

function submitform(parameter){
    jQuery("#ListLoadingGif").show();
    jQuery("#F_ACTION").val(parameter);
    //var l = jQuery("#limit").val();
    //alert(l);
    jQuery("#adminform").submit();
    //document.getElementById("adminForm").submit();

}

function submituserform(lang){
        jQuery('#loadingform').show();

        var name = jQuery("#login_name").val();
        var pass = jQuery("#login_password").val();
        jQuery('#loginform').hide();
        var dataString = 'F_USER_NAME='+ name+'&F_USER_PASSWORD='+pass;

        if(lang!=''){lang = '/'+lang;}
        var link = lang+'/login/';
		jQuery.ajax({
            type: "POST",
            url: link,
            data: dataString,
            success: function(data) {
                if(data==1){
                    window.location.href = lang+'/objects/object_details/';
                }else{
                    //jQuery('#loginform').html(data);
                    jQuery('#wronglogin').show();
                    jQuery('#loadingform').hide();
                }
            }
     });
}

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 urlencode(str) {
    return escape(str).replace(/%2C/gi, ',');
}

function submitSearchForm(parameter){
    var dis = urlencode(dis_array.join('-'));
    var cat = urlencode(cat_array.join('-'));

    if(dis!='' || cat!='' || document.getElementById('search').value !=''){
        jQuery('#dis').val(dis);
        jQuery('#cat').val(cat);
        jQuery('#action').val(parameter);
        document.searchForm.submit();
    }else{
        jAlert('Nav norādīti meklēšanas parametri!', 'Paziņojums');
        return false;
    }
}
function submitMapSearchForm(parameter){
    var cat = '';
    jQuery("input:checked").each(function(){
        if(cat!=''){
            cat = cat+'-'+jQuery(this).val();
        }else{
            cat = cat+''+jQuery(this).val();
        }

    });

    jQuery('#category').val(cat);
    jQuery('#action').val(parameter);

    document.searchform.submit();

}
function submitQuestionForm(parameter){

    jQuery('#faction').val(parameter);
    document.pollForm.submit();

}
function submitcomment(){

        var dataString = jQuery('#commForm').serialize();
        var link = jQuery('#link').val();
        jQuery('#commentform').html("");
        jQuery('#commentform').addClass("loadingcommentform");

        jQuery.ajax({
            type: "POST",
            url: "/"+language+"/news/",
            data: dataString,
            success: function(data) {
                if(data=='1'){
                    window.location.reload();
                }else{
                    jQuery('#commentform').html(data);
                    jQuery('#commentform').removeClass("loadingcommentform");
                }
            }
        });


}
function submitblogcomment(){
        var dataString = jQuery('#commForm').serialize();
        var link = jQuery('#link').val();
        jQuery('#commentform').html("");
        jQuery('#commentform').addClass("loadingcommentform");

        jQuery.ajax({
            type: "POST",
            url: "/"+language+"/blog/",
            data: dataString,
            success: function(data) {
                if(data=='1'){
                    window.location.reload();
                }else{
                    jQuery('#commentform').html(data);
                    jQuery('#commentform').removeClass("loadingcommentform");
                }
            }
        });
}
function submitguestcomment(){

    var dataString = jQuery('#commform').serialize();
    jQuery('#guestcomments').html('');
    jQuery('#guestcomments').addClass('loadingcommentform');

    jQuery.ajax({
        type: "POST",
        url: "/lv/catalog/post_comment/",
        data: dataString,
        success: function(data) {
            if(data=='1'){
                //alert(objectlink);
                window.location.href=objectlink;//+'#viesugramata';
            }else{
                jQuery('#guestcomments').html(data);
                jQuery('#guestcomments').removeClass('loadingcommentform');
            }

        }
    });

}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.getElementById('box').value++;
	}
	else {
		document.getElementById('box').value--;
	}
}
var dis_array = new Array();
function isCheckedDistinct(isitchecked,val){
	if (isitchecked == true){
        dis_array[dis_array.length] = val;
	}else {
        dis_array.splice(dis_array.indexOf(val),1);
	}
}
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 selectDistinct(id){
    if(document.getElementById('distinct_'+id).checked==false){
        document.getElementById('distinct_'+id).checked=true;
        dis_array[dis_array.length] = document.getElementById('distinct_'+id).value;
        //document.getElementById('box').value++;
    }else{
        document.getElementById('distinct_'+id).checked=false;
        dis_array.splice(dis_array.indexOf(document.getElementById('distinct_'+id).value),1);
        //document.getElementById('box').value--;
    }

}
function searchKeyPress(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 show_file_input(id){
    if(id=='file'){
        jQuery("#url").hide();
        jQuery("#code").hide();
        jQuery("#file").show(500);
    }else if(id=='code'){
        jQuery("#url").hide();
        jQuery("#file").hide();
        jQuery("#code").show(500);
    }else{
        jQuery("#file").hide();
        jQuery("#code").hide();
        jQuery("#url").show(500);
    }
}

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 = '/lv/forum/add_reply_form/';
		jQuery.ajax({
            type: "POST",
            url: "/lv/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 = '/lv/forum/add_reply_form/';
		jQuery.ajax({
            type: "POST",
            url: "/lv/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'){
                    alert(data);
                    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){

    var dataString = 'F_ID_OBJECT='+id;
	jQuery.ajax({
        type: "POST",
        url: "/lv/objects/publish_map_coordinates/",
        data: dataString,
        dataType: "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 loadimage(img){

    jQuery('#map_canvas').hide();
    jQuery('#video').hide('');
    jQuery('#image').html('');
    jQuery('#image').show();

    jQuery('#image').addClass('loadingobjectimage');

    jQuery.get("/inc/objectdetailsimagejquery.php?foto="+img, {},
	    function(data) {
            jQuery('#image').html(data);
            jQuery('#image').removeClass('loadingobjectimage');
		}
	);

}
function show_map(id_object){
    jQuery('#image').html('');
    jQuery('#image').show();
    jQuery('#image').show();
    jQuery('#video').hide();
    jQuery('#image').addClass('loadingobjectimage');
    //alert(id_object);
    jQuery('#image').hide();
    jQuery('#map_canvas').show();
    checkmap();
    jQuery('#image').removeClass('loadingobjectimage');
}

function loadvideo(id){

    jQuery('#image').html('');
    jQuery('#map_canvas').hide();
    jQuery('#image').show();
    jQuery('#video').hide();
    jQuery('#image').addClass('loadingobjectimage');

    var link = jQuery("#"+id).attr("href")+"?video=true&detailsvideo=true";
    //alert(link);
    jQuery.ajax({
        type: "POST",
        url: link,
        data: "",
        success: function(data){
            //alert(data);
            //dialog.data.hide();
            jQuery('#video').html(data);
            jQuery('#video').show();
            jQuery('#image').removeClass('loadingobjectimage');
            jQuery('#image').hide();
            //dialog.data.slideDown("slow");
        }
    });


}


function show_points_window(){
    jQuery.post("/"+language+"/login/user_points/", { },
	    function(data) {
            jQuery.modal(data);
		}
	);
}


function show_default_points_window(){
    jQuery.post("/"+language+"/login/user_default_points/", { },
	    function(data) {
            jQuery.modal(data);
		}
	);
}
function showloginform(param){
    jQuery.post("/"+language+"/login/user_register_form/", {param:param },
	    function(data) {
            jQuery.modal(data);
            jQuery('#username').focus();
		}
	);
}
function submitloginform(ref){
    jQuery('#loginmessageform').hide();
    jQuery('#loading').show();

    var name = jQuery("#username").val();
    var pass = jQuery("#userpassword").val();

    jQuery.post("/"+language+"/login/submitmodalwindow/?message=true", {F_USER_NAME:name,F_USER_PASSWORD:pass },
	    function(data) {
            if(data=='true' || data=='1'){
                //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('');
            }
		}
	);
}