var lang = 'pl_PL';
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>');
    }
}


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;
    }
}


//funkcja do pokazywana/ukrywania modulow
function show_moduly(name) {
    divy = de('modulyreklamowe').getElementsByTagName("div");
    //alert();

    //ukrycie wszystkich divow
    for (i=0; i < divy.length; i++) {
        divy[i].style.display = "none";
    }

    show_obj(name);
}
function hide_moduly(name) {
    //setTimeout("hide_obj('"+name+"')", 1000);
}
// magazyn - ukrywa/pokazuje opcje do ustawien
function hideOrUnhide(t, id) {
    if (t.checked) {
        show_obj(id);
    } else {
        hide_obj(id);
    }
}

/*
// magazyn - ukrywa/pokazuje opcje do ustawien
function hideAndUnhide(t, id) {
with (document.forms["contact_form"]) {
if (elements["mag_ustawienia"].checked) {
show_obj('tableToSend');
} else {
hide_obj('tableToSend');
}
}
}
*/


var ns6=document.getElementById&&!document.all;
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;

function checkAll(theForm, e) {
    cur = ns6? e.target : event.srcElement;
    //fstDig = Number(cur.className.charAt(4));
    fstDig = cur.className.substr(3, cur.className.length)

    for (i=cur.tabIndex+1,n=theForm.elements.length;i<n;i++) {
        if ((theForm.elements[i].className.indexOf("top")!=-1) && (Number(theForm.elements[i].className.charAt(3)) == fstDig)) {
            sameLevel = Number(theForm.elements[i].tabIndex);
            break;
        } else {
            sameLevel = n;
        }
    }

    for (j=cur.tabIndex,k=sameLevel;j<k;j++) {

        if ((Number(theForm.elements[j].className.charAt(0)) > fstDig) || (cur.className.substr(3) == theForm.elements[j].className) || ((theForm.elements[j].className.indexOf("top")!=-1) && (Number(theForm.elements[j].className.charAt(3)) > fstDig))) {
            if (cur.checked) {
                theForm.elements[j].checked = true;
            } else {
                theForm.elements[j].checked = false;
            }
        }
    }
}

function checkAllSid(t, id) {
	var inputs = de("sid"+id).getElementsByTagName('INPUT');
	var flag = true;
	//jesli id jest zwiniety - rozwijam go... ale nie zwijam
	if ((de("sid"+id).style.display == "") || (de("sid"+id).style.display == "none")) {
		showhidepliki(id);
	}
	
	//zaznaczanie odpowiedniej flagi
	if (t.checked == true) flag = true;
	else flag = false;
	
	for(i=0;i < inputs.length; i++) {
	    void(inputs[i].checked = flag);
	}
	//alert(inputs.length);	
}

function checkAllMid(t, id) {
	var inputs = de("mid"+id).getElementsByTagName('INPUT');
	var flag = true;
	
	//zaznaczanie odpowiedniej flagi
	if (t.checked == true) flag = true;
	else flag = false;
	
	for(i=0;i < inputs.length; i++) {
	    void(inputs[i].checked = flag);
	}
	//alert(inputs.length);	
}
function returnCheck(msg) {
	var inputs = de("sidmid").getElementsByTagName('INPUT');
    var check = false;
		
	for(i=0;i < inputs.length; i++) {
	    if (inputs[i].checked == true) {
            check = true
        }
	}
	//alert(inputs.length);
    if (check == false) {
        alert(msg);
    } else {
        if (lang == 'pl_PL') {
            submit_value = 'Proszę czekać...';
        } else {
            submit_value = 'Please wait...';
        }
        
        document.forms["docBuilder"].elements["submit"].disabled=true;
        document.forms["docBuilder"].elements["submit"].value = submit_value;
		document.getElementById('plikownia').style.visibility = 'visible';
        setTimeout("unblock_submit()", 30000);
        
    }
    return check;
}

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';
}

function checkThis(id) {
    var isChck = document.getElementById("mag"+id);
    
    if (isChck.checked == false) isChck.checked = true;
    else isChck.checked = false;
}

//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);
	}
}



