var lang = 'pl_PL';
var classname_err_msg = "error";
var blocker = false;

var cm_art = null;
function putFlash(sPath, iWidth, iHeight, sID) {
    with (document) {
        write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+iWidth+'" height="'+iHeight+'" id="'+sID+'">');
        write('  <param name="movie" value="'+sPath+'" />');
        write('  <param name="quality" value="high" />');
        write('  <param name="loop" value="true" />');
        write('  <param name="wmode" value="transparent" />');
        //write('  <param name="menu" value="false" />');
        //write('  <embed src="'+sPath+'" quality="high"
        write('  <embed src="'+sPath+'" quality="high" width="'+iWidth+'" height="'+iHeight+'" wmode="transparent" menu="false" swLiveConnect="true" loop="true" name="'+sID+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
        write('</object>');
    }
}

//prostsze pobieranie document.getElementById...
function de(id) {
    return document.getElementById(id);
}
function dc(name) {
    return document.getElementsByClassName(name);
}



function opImg(strona) {
    lupka(strona, 330, 330, 'no');
}

function lupka(plik_strony, w, h, przew) {
    if (!w) {w=500;}
    if (!h) {w=400;}
    if (!przew) {przew='yes';}

    if (window.screen){
        aw=screen.availWidth;
        ah=screen.availHeight;
    } else{
        aw=640;
        ah=450;
    }

    ustawienia=
    "left=" + (aw-w)/2 + ","
    +"top=" + (ah-h)/2 + ","
    +"screenX=" + (aw-w)/2 + ","
    +"screenY=" + (ah-h)/2 + ","
    +"width=" + w + ","
    +"height=" + h + ","
    +"innerWidth=" + w + ","
    +"innerHeight=" + h + ","
    +"toolbar=no,"
    +"location=no,"
    +"directories=no,"
    +"status=no,"
    +"menubar=no,"
    +"scrollbars=" +przew+ ","
    +"resizable=yes"
    self.window.name='glowne';
    noweOkienko = window.open(plik_strony,'noweOkienko',ustawienia);

    noweOkienko.document.close();
    noweOkienko.focus();
}
// nowa opcja obrazkow +++++++++++++++++++++++
function reSizeToImage( ){
    var isNN, isIE;

    if ( parseInt( navigator.appVersion.charAt( 0 ) ) >= 4 ){
        isNN = ( navigator.appName == "Netscape" ) ? 1 : 0;
        isIE = ( navigator.appName.indexOf( "Microsoft" ) != -1 ) ? 1 : 0;
    }

    if ( isNN ){
        width = document.images["obrazek"].width;
        height = document.images["obrazek"].height;

        if( width > screen.availWidth ){
            width = screen.availWidth - screen.availWidth/5;
            document.body.scroll = "yes";
        }
        if( height > screen.availHeight ){
            height = screen.availHeight - screen.availHeight/5;
            document.body.scroll = "yes";
        }
        window.innerWidth =		width;
        window.innerHeight =	height;
    }
    else {
        //window.resizeTo( 100, 100 );
        //width =		100 - ( document.body.clientWidth - document.images[0].width );
        //height =	100 - ( document.body.clientHeight - document.images[0].height );

        width =		document.images[0].width;
        height =	document.images[0].height;

        window.resizeTo( width, height );

        if ( width > screen.availWidth ){
            width = screen.availWidth - screen.availWidth / 5;
            document.body.scroll = "yes";
        }
        //alert(width + ' ' + height +' '+ document.images[0].width +' '+ document.body.clientWidth);
        if( height > screen.availHeight ){
            height = screen.availHeight - screen.availHeight / 5;
            document.body.scroll = "yes";
        }
        width = width+20;
        height = height+23;
        window.resizeTo( width, height );
    }

    moveWindowToImage( width, height );

}
function moveWindowToImage( iWindowWidth, iWindowHeight ){

    var iPosX = (( screen.availWidth - iWindowWidth ) / 2)-40;
    var iPosY = (( screen.availHeight - iWindowHeight ) / 2);

    //alert (screen.availWidth + " h: " + screen.availHeight + " d\nw: " + iWindowWidth + " h: "+iWindowHeight + " \ny: " + iPosY + " X: " + iPosX);
    //	if (iPosY > screen.availHeight
    window.moveTo( iPosX, iPosY );

} // end function moveWindowImage
function doTitle( ){
    document.title = "Argent 3:";
}

function hide_obj(name) {
    var agt=navigator.userAgent.toLowerCase();
    var is_ie5 = ((parseInt(navigator.appVersion) == 4) && (agt.indexOf("msie 5.0")!=-1) && (agt.indexOf("opera") == -1));

    if (document.getElementById && !is_ie5) {
        obj=document.getElementById(name).style.visibility = "hidden";
        document.getElementById(name).style.display = "none";
    } else if (document.layers) {
        obj=document.layers[name].visibility = "hide";
        document.layers[name].display = "none";
    } else if (document.all) {
        obj=document.all[name].style.visibility = "hidden";
        document.all[name].display = "none";
    } else {
        obj=false;
    }
}

function show_obj(name) {
    var agt=navigator.userAgent.toLowerCase();
    var is_ie5 = ((parseInt(navigator.appVersion) == 4) && (agt.indexOf("msie 5.0")!=-1) && (agt.indexOf("opera") == -1));
    if (document.getElementById && !is_ie5) {
        obj=document.getElementById(name).style.visibility = "visible";
        document.getElementById(name).style.display = "inline";
    } else if (document.layers) {
        obj=document.layers[name].visibility = "show";
        document.layers[name].display = "inline";
    } else if (document.all) {
        obj=document.all[name].style.visibility = "visible";
        document.all[name].display = "inline";
    } else {
        obj=false;
    }
}


// magazyn - ukrywa/pokazuje opcje do ustawien
function hideOrUnhide(t, id) {
    if (t.checked) {
        show_obj(id);
    } else {
        hide_obj(id);
    }
}


function unblock_submit() {
    if (lang == 'pl_PL') {
        submit_value = 'Pokaż/Zapisz broszurę';
    } else {
        submit_value = 'Show/Save Brochure';
    }
    document.forms["docBuilder"].elements["submit"].disabled=false;
    document.forms["docBuilder"].elements["submit"].value = submit_value;
    document.getElementById('plikownia').style.visibility = 'hidden';
}

//var actual_open
function showhidepliki(id) {
    if ((de("sid"+id).style.display == "") || (de("sid"+id).style.display == "none")) {
        de("sid"+id).style.display = "block";
        de("arrow"+id).src = "/_i/arrow_v.gif";
    } else {
        de("sid"+id).style.display = "none";
        de("arrow"+id).src = "/_i/arrow_h.gif";
    }
    //alert(de("sid"+id).style.display);
    // hide_obj

}
function showhideArticle(id) {
    if (cm_art == id) {
        hide_obj(id);
        cm_art = null;
        return;
    } else if (cm_art != null) {
        hide_obj(cm_art);
        cm_art = null;
    }
    show_obj(id);
    cm_art = id;
}

function kopiuj(x) {
    //var elem = "url["+ x +"]";
    with (document.urle) {
        txt = elements[x];
        txt.focus();
        txt.select();
        therange=txt.createTextRange();
        therange.execCommand("Copy")
        window.status="Skopiowane"
        setTimeout("window.status=''", 2400);
    }
}


// ________________ jquery ____________
var sh_status = false; //rozwiniety/zwiniety
var sh_elem = null; //stary element
function showhide(elem) {

    //element = elem.split("#");
    if (sh_elem != elem) {
        if (sh_elem != null) {
            sh_element = sh_elem.split("#");
            $(sh_elem).slideUp('slow');
        }
        $(elem).slideDown('slow');
        sh_elem = elem;
    } else if (sh_elem == elem) {
        $(sh_elem).slideUp('slow');
        sh_elem = null;

    }

    //    $(elem).slideDown('slow');
    //   sh_elem = elem;

    //slideDown("slow");
    //slideUp('slow')
}

var sh1_elem = null;
function fadeopis(elem) {
    if (sh1_elem != elem) {
        if (sh1_elem != null) $(sh1_elem).slideUp('slow');
        $(elem).fadeIn("slow");
        sh1_elem = elem;
    } else if (sh1_elem == elem) {
        $(elem).fadeOut("slow");
        sh1_elem = null;
    }
}


$(document).ready(function(){

    function showValues() {
        var fields = $(":input").serializeArray();
        $("#results").empty();
        jQuery.each(fields, function(i, field){
            $("#results").append(field.value + " ");
        });
    }

    $(":checkbox, :radio").click(showValues);
    $("select").change(showValues);
    showValues();

});

var old_form = null;

function showValues() {
    var str = $("#prasa_form").serialize();
    $.ajax({
        type: "POST",
        url: "/news.php",
        data: str,
        success: function(msg){
            old_form = $("#prasa_form").html();
            $("#prasa_form").html(msg);
            //alert("Data Saved: " + msg);
        }
    });
    //return(str);
    //$("#results").text(str);
}

$(":checkbox, :radio").click(showValues);
$("select").change(showValues);
//showValues();

function showNewsletterForm() {
    if (old_form != null) {
        $("#prasa_form").html(old_form);
        old_form = null;
    }
}

// ________________ menu __________________

var a_logo = new Array();
a_logo[1] = '';
a_logo[2] = 'logo2_2';
a_logo[3] = 'logo2_3';
a_logo[4] = 'logo2_4';
a_logo[5] = 'logo2_5';
a_logo[6] = 'logo2_6';
a_logo[7] = 'logo2_7';
a_logo[8] = '';

function change_on(id) {

    if (de(a_logo[id]) != undefined) {
        de(a_logo[id]).style.backgroundPosition = "0 0px";
    }
}

function change_off(id) {
    if (de(a_logo[id]) != undefined) {
        de(a_logo[id]).style.backgroundPosition = "0 -47px";
    }
}

function goto(url) {
    document.location = url;
}

