var classname_err_msg = "error";

N = navigator.userAgent;

N = N.toLowerCase();

var isGecko  = (navigator.product == "Gecko");

var isIE     = ((N.indexOf("msie") != -1) && (N.indexOf("opera") == -1));

var box_pos  = 0;



function putZoomify(sPath, iWidth, iHeight, sID, imgPath) {

    with (document) {

        write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+iWidth+'" height="'+iHeight+'" id="'+sID+'">');

        write('  <param name="FlashVars" value="zoomifyImagePath='+imgPath+'&zoomifyNavWindow=0&zoomifyToolbar=1" />');

        //        write('  <param name="quality" value="high" />');

        write('  <param name="wmode" value="transparent" />');

        write('  <param name="src" value="'+sPath+'" />');

        write('  <param name="menu" value="false" />');

        write('  <embed src="'+sPath+'" quality="high" FlashVars="zoomifyImagePath='+imgPath+'&zoomifyNavWindow=0&zoomifyToolbar=1" wmode="transparent" menu="false" width="'+iWidth+'" height="'+iHeight+'" swLiveConnect="true" name="'+sID+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');

        write('</object>');

    }

}



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=5,0,0,0" width="'+iWidth+'" height="'+iHeight+'" id="'+sID+'">');

        write('  <param name="movie" value="'+sPath+'" />');

        write('  <param name="quality" value="high" />');

        write('  <param name="wmode" value="transparent" />');

        write('  <param name="menu" value="false" />');

        write('  <embed src="'+sPath+'" quality="high" wmode="transparent" menu="false" width="'+iWidth+'" height="'+iHeight+'" swLiveConnect=true name="'+sID+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');

        write('</object>');

    }

}

// potwierdzenie usuwania danych

function usuwanie_conf(msg) {

    if ( (msg == "") || (msg == "undefined") ) {

        msg = "Do you want to delete this?";

    }

    msg += "\n\npress \"OK\" - if you do\n"+

    "press \"Cancel\" - if you dont want to";

    if (confirm(msg)) return true;

    else return false;



}

function imageChange(fname, imgname, spname, fsize, wmax, hmax) {

    thumbnailSize = fsize;

    imgObj = new Image();

    imgObj.onload = function() {

        w = this.width; h = this.height; t = document.getElementById(imgname);

        //sprawdzanie rozmiaru fotki

        if ( (w > wmax) || (h > hmax) ) {

            alert ("file is to big "+wmax+" px ");

            return false;

        }

        if (w > thumbnailSize || h > thumbnailSize)

        if (w > h) {

            h = Math.round(h * thumbnailSize / w);

            w = thumbnailSize;

        } else {

            w = Math.round(w * thumbnailSize / h);

            h = thumbnailSize;

        }

        with (t.style) {

            width = w+'px';

            height = h+'px';

            display = 'inline';

        }

        t.src = "file://" + document.getElementById(fname).value;

        document.getElementById(spname).innerHTML = this.width + ' x ' + this.height;

    };

    imgObj.onerror = function() {

        document.getElementById(imgname).style.display = 'none';

        document.getElementById(spname).innerHTML = 'Error';

    };

    imgObj.src = "file://" + document.getElementById(fname).value;

}



function updateObjects(fname, imgname, spname, fsize, wmax, hmax) {



    inputObj = document.getElementById(fname);

    if (document.all)

    inputObj.onchange = function() { imageChange(fname, imgname, spname, fsize, wmax, hmax) }; else

    inputObj.onclick = function() { imageChange(fname, imgname, spname, fsize, wmax, hmax) };

}





function makeVisible(Eid) {

    if (Eid == "") Eid = 1;

    var zak = "z"+Eid;

    var li = "li"+Eid;

    var ilosc_elementow = 6; //ilosc elementow do fora..

    var i;



    // oznaczenie wszystkich zakladek jako nieaktywne

    for (i=1; i <= ilosc_elementow; i++) {

        document.getElementById('z'+i).className="box-h";

        document.getElementById('li'+i).className="";

    }



    // uaktywnienie wybranej zakladki

    document.getElementById(zak).className="box-v";

    document.getElementById(li).className="on";

}



// licznik do pol

function licznik(f, text_count, counter, ilosc) {

    var text_area = document.forms[f].elements[text_count];

    var count_inp = document.forms[f].elements[counter];

    var ta_val = text_area.value;

    var ta_len = ta_val.length;

    count_inp.value = (ilosc-ta_len);

    if (count_inp.value == -1) count_inp.value = 2;

    if(ta_len >= ilosc) {

        // alert("Przekroczono dozwolon ilo: "+ilosc);

        text_area.value = ta_val.substring(0, ilosc);

    }

}



//ustawianie ceny w zaleznosci od cechy

//uwaga funkcja jeszcze nie liczy  cen z podwojnymi cechami

// UWAGA!!!  ceny netto nie licze, bo w cechach jest podawana cena brutto

//cene netto mozna podac przy fakturze

function setPrice(price) {

    return "$"+makeGrosze(price);

}



//dodawanie 00 do danej kwoty

function makeGrosze(price) {

    strNumber = "" + price;

    kwota = strNumber.split("\.");

    zlote = kwota[0];

    if (kwota[1] != undefined) {

        grosze = kwota[1];

        last = grosze.length;

        if (last == 1) grosze = grosze+"0";

    } else {

        grosze = "00";

        //grosze = "";

    }

    price = kwota[0] + "." + grosze;

    //price = kwota[0];



    return price;

}



//obliczanie ceny koszyka na stronie z koszykkiem

/**

wykorzystane id:

cechy_selects_{$towid} - lista cech

cbrutto_{$towid}

suma_{$towid}

koszyk id form koszyka

hiddeny:

cart_form[27][c_brutto_f]

cart_form[27][c_netto_f]

cart_form[27][vat_f]

cart_form[27][tid_f]

shipment_price[1]

shipment_price[2]

*/

function setPriceKoszyk(pid, prod_c_brutto, prod_c_netto, vat, rabat, ilosc) {

    var c_brutto = 0;

    var suma = 0;

    var selects = document.getElementById('cechy_selects_'+pid).getElementsByTagName('SELECT');



    cechy_ids = '';

    for (i=0; i < selects.length; i++) {

        cechy_ids += selects[i].value+'_';

    }

    if (variation_cart[pid][cechy_ids] != undefined) {

        fname = document.forms["koszyk"];

        c_brutto_hid = fname.elements["cart_form["+pid+"][c_brutto_f]"];

        c_netto_hid = fname.elements["cart_form["+pid+"][c_netto_f]"]



        //vinf = variation_info_cart[pid][variation_cart[pid][cechy_ids]];

        vinf = variation_cart[pid][cechy_ids];



        if (vinf[2] == 'f') {

            alert("sorry this configuration is unavailable");

            prod_available = false;

        } else {

            /*

            if (vinf[1] != '') {

            de('bigfoto').src = dir_img+'/'+dir_prefix+vinf[1];

            } else {

            de('bigfoto').src = dir_img+'/'+dir_prefix+picture;

            }

            */

            if (vinf[0] != 0.00) {

                c_brutto = vinf[0];

                suma = Math.round(c_brutto*ilosc*100)/100;

            } else {

                suma = Math.round(prod_c_brutto*ilosc*100)/100;

                c_brutto = prod_c_brutto;

            }

            rabat = rabat.replace(",",".");

            if (rabat < 1) {

                rabat = 1-rabat;

                //prompt("sdsd", c_brutto*ilosc*rabat);

                suma = Math.round(c_brutto*ilosc*rabat*100)/100;

            }

            de('cbrutto_'+pid).innerHTML = setPrice(c_brutto);

            de('suma_'+pid).innerHTML = setPrice(suma);

            c_brutto_hid.value = c_brutto;

            c_netto_hid.value = Math.round(c_brutto/vat*100)/100;



            //alert(vinf[0]);

            prod_available = true;

        }

    }

}







//dostawa - do sumy dodawanie ceny dostawy

function setDostawaPrice(suma, cena) {

    cena_brutto = Math.round((suma+cena)*100)/100;

    if (isNaN(cena_brutto)) {

        cena_brutto = suma;

    }

    //document.dostawa.suma_all.value = cena_brutto;

    //formatCurrency(cena_brutto);

    document.getElementById('allsuma').innerHTML = setPrice(cena_brutto);

}



function formatCurrency(num) {

    num = num.toString().replace(/\$|\,/g,'');

    if(isNaN(num))

    num = "0";

    sign = (num == (num = Math.abs(num)));

    num = Math.floor(num*100+0.50000000001);

    cents = num%100;

    num = Math.floor(num/100).toString();

    if(cents<10)

    cents = "0" + cents;

    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

    num = num.substring(0,num.length-(4*i+3))+','+

    num.substring(num.length-(4*i+3));

    //return (((sign)?'':'-') + '$' + num + '.' + cents);

    //return '$'+ (((sign)?'':'-') + num + '.' + cents);

    return '$'+ (((sign)?'':'-') + num + '.' + cents);

}







function lupka_foto(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();

}



function winres() {

    var el=document.getElementById('obrazek');

    var ow=el.offsetWidth;

    var oh=el.offsetHeight;

    if (ow<100) ow=100;

    if (oh<100) oh=100;

    var mp=false;

    var mp1,mp2;

    var w,h,i;







    mp1=1;mp2=1;

    if (ow>screen.availWidth-30) {

        mp1=(screen.availWidth-30)/ow;

        mp=true;

    }

    if (oh>screen.availHeight-50) {

        mp2=(screen.availHeight-50)/oh;

        mp=true;

    }



    if (mp) {

        if (mp1>mp2) mp1=mp2;

        ow=Math.floor(mp1*ow);

        oh=Math.floor(mp1*oh);

        el.width=ow;

        el.height=oh;

    }

    for (i=0;i<3;i++) {

        if (window.innerWidth) {

            w=window.innerWidth;

            h=window.innerHeight;

        }

        else {

            w=document.body.clientWidth;

            h=document.body.clientHeight;

        }

        if (i <2) h-=20;

        window.resizeBy(ow-w,oh-h);

    }

    window.resizeTo(w+15, h+30);

    w=(screen.availWidth-ow)/2;

    h=(screen.availHeight-oh)/2;

    if (w<0) w=0;

    if (h<0) h=0;

    window.moveTo(w,h);

}



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 = "block";

    } else if (document.layers) {

        obj=document.layers[name].visibility = "show";

        document.layers[name].display = "block";

    } else if (document.all) {

        obj=document.all[name].style.visibility = "visible";

        document.all[name].display = "block";
    } else {
        obj=false;
	}

	if (name == 'divpop') {
		var scroll_pos = document.body.scrollTop;
		if (scroll_pos == 0) {
			if (window.pageYOffset) {
				scroll_pos = window.pageYOffset;
			} else {
				scroll_pos = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
			}
		}
		document.getElementById(name).style.marginTop = 100 + parseInt(scroll_pos) + 'px';
	}

}



// 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 );



        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.resizeTo( width+12, height );

    }



    moveWindowToImage( width, height );



}

function moveWindowToImage( iWindowWidth, iWindowHeight ){



    var iPosX = ( screen.availWidth - iWindowWidth ) / 2;

    var iPosY = ( screen.availHeight - iWindowHeight ) / 2;



    window.moveTo( iPosX, iPosY );



} // end function moveWindowImage

function doTitle( ){

    document.title = "Argent 3:";

}



// funkcja do ustawiania pozycji

function centerLayer() {

    var objDiv = document.getElementById("divPics"); //div - parent tabelki

    var objTable = document.getElementById("tablePics"); //table ze zdjeciami



    var widthTable = objTable.offsetWidth;

    var widthObjDiv = objDiv.offsetWidth;



    //ustawienie zdjec centralnie na stronie

    if (widthTable < widthObjDiv) {

        midVal = (Math.round(widthObjDiv/2))-(Math.round(widthTable/2));

        objDiv.style.left = midVal +"px";

        //alert ((Math.round(widthObjDiv/2)) +":"+ (Math.round(widthTable/2)) +":"+ midVal);

    }



}



var timer;

function moveLayer(direction) {



    var obj = document.getElementById("pics"); //ogolny div

    var objDiv = document.getElementById("divPics"); //div - parent tabelki

    var objTable = document.getElementById("tablePics"); //table ze zdjeciami



    // dlugosci danych elementow

    var widthTable = objTable.offsetHeight;

    var widthObj = obj.offsetHeight;

    var widthObjDiv = objDiv.offsetHeight;



    var iloscPx = 10; //iloe px przesuwac w lewo/prawo



    //cntPics ilosc zdjec w tabeli * margin



    //alert(widthTable +" df "+ objDiv.style.left + " : " + objDiv.offsetWidth + " : " + obj.offsetWidth);



    //dalej nie przewijam...

    var maxLeft = (widthTable-widthObjDiv)*-1;

    var maxRight = -1;



    //alert(maxLeft);



    if (direction == 'leftside') {

        if (parseInt(objDiv.style.top) <= maxLeft) {

            stopScroller();

        } else {

            objDiv.style.top = parseInt(objDiv.style.top)-iloscPx +"px";

        }

        if (objDiv.style.top > maxLeft) {

            stopScroller();

        }

    } else {

        if (parseInt(objDiv.style.top) < maxRight) {

            objDiv.style.top=parseInt(objDiv.style.top)+iloscPx +"px";

        } else {

            stopScroller();

        }

    }



    //ustawienie zdjec centralnie na stronie

    //if (widthTable < widthObjDiv) objDiv.style.left = (Math.round(widthObj/2))-(Math.round(widthTable/2)) ;



    //timer = setTimeout("moveLayer('"+direct+"', '"+cntPics+"');", 20);

    timer = setTimeout("moveLayer('"+direction+"');", 30);



}

function stopScroller() {

    clearTimeout(timer)

}

function showHeight(obj) {

    //alert("w: "+ obj.offsetWidth +" h: "+ obj.offsetHeight);

}





//funkcja do disebledowania selectu state'ow w momencie wyboru innego kraju niz usa

function disableState(t) {

    var disbl = true;

    if (t.value == 221) {

        disbl = false;

    } else {

        disbl = true;

    }

    document.forms['rejestracja'].elements["woj_id"].disabled = disbl;

}



function hideSelects() {

    var selecty = document.getElementsByTagName("select");

    var ilosc_selectow = selecty.length;



    for (var i=0; i < ilosc_selectow; i++) {

        selecty[i].style.visibility = "hidden";

    }

}



function showSelects() {

    var selecty = document.getElementsByTagName("select");

    var ilosc_selectow = selecty.length;



    for (var i=0; i < ilosc_selectow; i++) {

        selecty[i].style.visibility = "visible";

    }

}



// ----------- kategorie header ----------------- //





//Set tab to intially be selected when page loads:

//[which tab (1=first tab), ID of tab content to display]:

var initialtab=[1, "sc1"]



//Turn menu into single level image tabs (completely hides 2nd level)?

var turntosingle=0 //0 for no (default), 1 for yes



//Disable hyperlinks in 1st level tab images?

var disabletablinks=0 //0 for no (default), 1 for yes



////////Stop editting////////////////



var previoustab ="";



if (turntosingle==1)

document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>')



function expandcontent(cid, aobject) {

    if (disabletablinks==1)

    aobject.onclick=new Function("return false")

    if (document.getElementById){

        if (aobject != "undefined") highlighttab(aobject)

        if (turntosingle==0) {

            if (previoustab != "") {

                de(previoustab).style.display="none";

            }

            de(cid).style.display="block";

            //ukrywanie obecnej (tylko dla onclick!)

            if (previoustab == cid) {

                de(previoustab).style.display="none";

                previoustab="";

            } else {

                previoustab=cid;

            }

        }

    }

}



function highlighttab(aobject){

    if (typeof tabobjlinks=="undefined")

    collecttablinks()

    for (i=0; i<tabobjlinks.length; i++)

    tabobjlinks[i].className=""

    aobject.className="current"

}



function collecttablinks(){

    var tabobj=document.getElementById("tablist")

    tabobjlinks=tabobj.getElementsByTagName("A")

}



function do_onload(){



    var currenttab = '';

    collecttablinks()

    //expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])

    //rk:

    for (i=0; i<tabobjlinks.length; i++) {

        if (tabobjlinks[i].className == "current") {

            currenttab = tabobjlinks[i].id.replace('-', '');

            break;

        }

    }

    if (currenttab != '') expandcontent(currenttab, "undefined");

}



//funkcja do pobierania wartosci cech

/*

dostepne id:

bigfoto - zdjecie

cenaKoncowa - cena brutto

cenaKoncowaStrike - cena rabatowa

*/

var bruttoPrice=0; //main price if price == 0.00

var bruttoPriceNoRabat=0; //main price if price == 0.00

var c_netto=0;

var vat=1.00;

var picture='';

var rabat=0;

var dir_img = '';

var dir_prefix = '';

var prod_available = false;

var variation = new Array();

var variation_info = new Array();





/**

formid - id formularza z koszykiem

info {0,1} 1-pokazuje alert(w przypadku, gdy fn jest wywolana przez select)

0 - gdy ma nie byc alertow

*/

function getCechyValues(formid, info) {

    var c_brutto = 0;

    var selects = document.getElementById(formid).getElementsByTagName('SELECT');



    cechy_ids = '';

    for (i=0; i < selects.length; i++) {

        cechy_ids += selects[i].value+'_';

    }



    if (variation[cechy_ids] != undefined) {

        c_brutto_hid = document.forms["add2koszyk"].elements["cena_brutto"];

        vinf = variation_info[variation[cechy_ids]];

        if (vinf[2] == 'f') {

            if (info == 1) alert("sorry this configuration is unavailable");

            prod_available = false;

        } else {

            if (vinf[1] != '') {

                //de('bigfoto').src = dir_img+'/'+dir_prefix+vinf[1];

                de('bigfoto').src = images[variation[cechy_ids]];

            } else {

                de('bigfoto').src = dir_img+'/'+dir_prefix+picture;

            }

            rabat = rabat.replace(",",".");

            if (vinf[0] != 0.00) {

                c_brutto = vinf[0];

                c_brutto_hid.value = c_brutto;

                if (rabat < 1) {

                    c_no_rabat = c_brutto;

                    c_brutto = Math.round(c_no_rabat*rabat*100)/100;

                    de('cenaKoncowaStrike').innerHTML = setPrice(c_no_rabat);

                    c_brutto_hid.value = c_no_rabat;

                }

            } else {

                c_brutto = bruttoPrice;

                c_no_rabat = bruttoPriceNoRabat;

                if (rabat < 1) {

                    de('cenaKoncowaStrike').innerHTML = setPrice(c_no_rabat);

                }

                c_brutto_hid.value = c_no_rabat;

            }

            de('cenaKoncowa').innerHTML = setPrice(c_brutto);



            //alert(vinf[0]);

            prod_available = true;

        }

    } else {

        prod_available = true;

    }

}



// ____________________ funkcje do koszyka _____________________

//w zaleznosci od buttony (update, google) ustawiam action danego forma

//703503722364427 | 832113847156808

function changeFormAction(o_Form, opt, merchant_id) {

    //alert(o_Form.action);

    if (opt == 1) {

        o_Form.action = '/cart.php';

    } else {

        o_Form.action = 'https://checkout.google.com/cws/v2/Merchant/'+merchant_id+'/checkoutForm';

    }

}



function saveCechyKoszyk(id) {

    //alert()



}





var price_w = 30;

var price_m = 30;

var shipping_1 = 7.50;

var shipping_2 = 15.00;



function stickOrder(fname) {

    var amount_w = 0;

    var title_w = '';

    var amount_m = 0;

    var title_m = '';

    var quantity = 0;



    form = document.forms[fname].elements;



    if (form["women"].checked == true) {

        amount_w = form["q_ty_w"].value*price_w;

        title_w = "Women\'s T-Shirt,";

        title_w += " size: "+ form["size_w"].value +" - ("+form["q_ty_w"].value +"pcs)";

        quantity += form["q_ty_w"].value*1;

    }

    if (form["men"].checked == true) {

        amount_m = form["q_ty_m"].value*price_m;

        title_m = "Men\'s T-Shirt,";

        title_m += " size: "+ form["size_m"].value +" - ("+form["q_ty_m"].value +"pcs)";

        quantity += form["q_ty_m"].value*1;

    }



    if ( (form["men"].checked == false) && (form["women"].checked == false) ) {

        alert("Please choose T-shirt");

        return false;

    }



    /*    if (form["shipping"][0].checked == true) {

    ship = 'shipping: UPS Ground';

    ship_price = shipping_1;

    } else {

    ship = 'shipping: 2-Day UPS';

    ship_price = shipping_2;

    }*/



    form["item_name_1"].value = "Peacenik t-shirts";

    form["item_description_1"].value = title_w+" &amp; "+title_m;

    amount_x = (amount_w+amount_m);

    form["item_price_1"].value = makeGrosze(amount_x);

    //tax = Math.round(((form["amount"].value*1.07625)-form["amount"].value)*100)/100;

    //form["tax"].value = makeGrosze(tax);

    //alert(form["tax"].value);

    return true;

}



function checkCheckbox(ename) {

    if (document.forms["paypal"].elements[ename].checked == false) {

        document.forms["paypal"].elements[ename].checked = true;

    }

}



function changeAmount() {

    var amount_w = 0;

    var amount_m = 0;

    var amount = 0;



    form = document.forms["paypal"].elements;

    if (form["women"].checked == true) {

        amount_w = form["q_ty_w"].value*price_w;

    }

    if (form["men"].checked == true) {

        amount_m = form["q_ty_m"].value*price_m;

    }



    /*if (form["shipping"][0].checked == true) {

    ship_price = shipping_1;

    } else {

    ship_price = shipping_2;

    }*/



    amount = (amount_m+amount_w);



    document.getElementById('amount').innerHTML = makeGrosze(amount);

}





var pattern = '';

var replacement = '';



function showImage(sender) {

    lImg = document.getElementById("largeimage");

    if (!(!lImg)) {

        lImg.src = sender.childNodes[0].src.replace(pattern, replacement);

        lImg.alt = sender.childNodes[0].alt;

        //lImg.title = sender.childNodes[0].title

    }

}



var ind = 1;

function prev() {

    if (ind==1)

    ind = ln;

    else

    ind--;

    tImg = document.getElementById("pic"+ind);

    if (!(!tImg))

    showImage(tImg.parentNode);

}

function next() {

    if (ind==ln)

    ind = 1;

    else

    ind++;

    tImg = document.getElementById("pic"+ind);

    if (!(!tImg))

    showImage(tImg.parentNode);

}



function popupImg(sender) {

    obj = document.getElementById("divPop");

    if (!(!obj))

    obj.parentNode.removeChild(obj);



    divPop = document.createElement('div');

    divPop.id = 'divPop';

    divPop.style.diplay = 'block';

    divPop.style.backgroundColor = '#ffffff';

    divPop.style.position = 'absolute';

    divPop.style.left = '50px';

    divPop.style.top = '50px';

    divPop.style.padding = '5px';

    divPop.onclick = function () {

        this.parentNode.removeChild(this);

    }

    document.body.appendChild(divPop);

    getScrolling('divPop');

    new_src = sender.src.replace('web', 'web_large');

    /*//tworzenie obrazka

    tImg = document.createElement('img');

    tImg.src = sender.src.replace('web', 'web_large');

    tImg.style.width = tImg.width+'px';

    tImg.style.height = tImg.height+'px';

    tImg.style.cursor = 'pointer';

    tImg.alt = tImg.src;

    divPop.appendChild(tImg);*/

    divPop.innerHTML = '<img src="'+new_src+'" onclick="hide_obj(\'popupImg\')" />';

}

/*function popupImg(sender) {

//lImg = document.getElementById("largeimage");

//show_obj('popupImg');

getScrolling('popupImg');

divPop = document.getElementById('popupImg');

//divPop.style.diplay = 'block';

divPop.style.width = (sender.width+10)+'px';

divPop.style.height = (sender.height+20)+'px';



new_src = sender.src.replace('web', 'web_large');



//tworzenie obrazka

//    tImg = document.createElement('img');

//    tImg.alt = 'close';

//    tImg.src = sender.src.replace('web', 'web_large');

//    tImg.width = sender.width+'px';

//    tImg.height = sender.height+'px';

//    alert(tImg);

//    divPop.appendChild(tImg);

divPop.innerHTML = '<img src="'+new_src+'" onclick="hide_obj(\'popupImg\')" />';



}*/





function getScrolling(divName) {

    var x = 0; var y = 0;

    if( typeof( window.pageYOffset ) == 'number' ) {

        //Netscape compliant

        y = window.pageYOffset;

        x = window.pageXOffset;

    } else if( document.body && ( document.body.scrollLeft ||

    document.body.scrollTop ) ) {

        //DOM compliant

        y = document.body.scrollTop;

        x = document.body.scrollLeft;

    } else if( document.documentElement &&

    ( document.documentElement.scrollLeft ||

    document.documentElement.scrollTop ) ) {

        //IE6 standards compliant mode

        y = document.documentElement.scrollTop;

        x = document.documentElement.scrollLeft;

    }

    //alert(x+","+y);

    showMyDiv(divName, y);

    //return x+","+y;

    return y;

}



function showMyDiv(name, y) {

    //show_obj(name);

    //centrowanie wzledem poziomu

    var main = de("main");

    leftVal = (Math.round(main.offsetWidth/2))-(Math.round(de(name).offsetWidth/2));



    de(name).style.top = (y+20) +"px";

    de(name).style.left = leftVal +"px";

}



// ________________ jquery ____________

var sh_status = false; //rozwiniety/zwiniety

var sh_elem = null; //stary element



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;

    }

}





function showhide(elem) {

    if (sh_elem != elem) {

        if (sh_elem != null) $(sh_elem).slideUp('slow');

        $(elem).slideDown('slow');

        sh_elem = elem;

    } else if (sh_elem == elem) {

        $(sh_elem).slideUp('slow');

        sh_elem = null;

    }

    document.getElementById('artpics').scrollTop = 0;

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

    //   sh_elem = elem;



    //slideDown("slow");

    //slideUp('slow')

}



function fadeopis(elem) {

    $(elem).fadeIn("slow");

}



// ____________________



var ourInterval;

var origColor = '#b7b7b7';

var overColor = '#b7b7b7';

var scrollSpeed = 50;

var scrollHeight = 5;



function scrollStart(direction, divID, elementID){

    //CHANGE THE BACKGROUND COLOR OF THE TD THE MOUSE IS OVER

    document.getElementById(elementID).style.backgroundColor = overColor;

    // REPEATED CALL EITHER scrollUp OR scrollDown

    ourInterval = setInterval("scroll"+direction+"('"+divID+"')", scrollSpeed);

}

function scrollEnd(which){

    // OUR MOUSE IS OUT, SO RETURN TD TO ORIGINAL COLOR

    document.getElementById(which).style.backgroundColor = origColor;

    // STOP CALLING THE SCROLL FUNCTION

    clearInterval(ourInterval);

}



function scrollUp(which){

    // SET THE SCROLL TOP

    document.getElementById(which).scrollTop = document.getElementById(which).scrollTop - scrollHeight;

}

function scrollDown(which){

    // SET THE SCROLL TOP

    document.getElementById(which).scrollTop = document.getElementById(which).scrollTop + scrollHeight;

}



function ShowSlideshow(option) {
    show_obj('divpop');
    var so = new SWFObject(option+".swf", "mymovie", "516", "375", "8", "#000000");
    so.write("xmass");
}



function add2Fav() {

    if (document.all)

    window.external.AddFavorite(document.location, document.title);

    else

    window.sidebar.addPanel(document.title, document.location, "");

}

function orgFav() {

    window.external.ShowBrowserUI("OrganizeFavorites", null);

}





//wysuwanie/wsuwanie menu

var menu_show_flag = false;

function showSubMenu() {



    if (menu_show_flag == false) {

        $('ul#submenu').slideDown('slow');

        menu_show_flag = true;

        var flowers = document.getElementById('flowers');

        flowers.style.backgroundPosition = '0 -25px';

    }

}

function hideSubMenu() {

    if (menu_show_flag == true) {

        $('ul#submenu').slideUp('slow');

        menu_show_flag = false;



        var flowers = document.getElementById('flowers');

        flowers.style.backgroundPosition = '0 0';

    }

}



// ______________________ jquery _________________________

function test_link() {

    $('#external_links a').click(function() {

        return confirm('You are going to visit: ' + this.href);

    });

}



function newsletter() {

    email = $('#newsletter_form').val();

    var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;



    if (email != '' && !regex.test(email)) {

        alert ("Proper email is required!");

        return false;

    } else {

        var type = 'newsletter';

        $.ajax({

            type: "POST",

            url: '/response.php?id='+escape(email)+'&type='+type,

            dataType: "html",

            success: function(xml) {

                $('#newsletter_holder').html(xml);

            },

            error: function(){ alert("Ajax error"); }

        });

    }

}



function setCookie(name, value, expire) {

    document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))

}



function playMusic(play, number) {

    var today = new Date();

    var expires = new Date();

    expires.setTime(today.getTime() + 1000*60*60*24*31);

    setCookie("music", play, expires)

    setCookie("number", number, expires)

}



function getCookie(Name) {

    var search = Name + "=";

    if (document.cookie.length > 0) {

        // if there are any cookies

        offset = document.cookie.indexOf(search);

        if (offset != -1) {

            // if cookie exists

            offset += search.length;

            // set index of beginning of value

            end = document.cookie.indexOf(";", offset);

            // set index of end of cookie value

            if (end == -1) end = document.cookie.length;



            return unescape(document.cookie.substring(offset, end))

        }

    }

}





///////////////////////////////////////////////////







var selectedMenuItem = false;



function showSubMenu(sender, ident, offset)

{

    if (sender != selectedMenuItem)

       hideSubMenus();

    else

       hideSubMenu2();

       

    _sub_menu = document.getElementById('submenu');  

    if ((_sub_menu)&&(ident.length > 0))

    {

       _sub_list = document.getElementById('submenu_'+ident);

       if (_sub_menu && _sub_list)

       {

          selectedMenuItem = sender;

          _sub_menu.innerHTML = _sub_list.innerHTML;

          _sub_menu.style.backgroundPosition = (sender.offsetLeft - _sub_menu.offsetLeft)+'px 0px';

          _sub_menu.style.display = 'block';

          bsc = sender;

          x = sender.offsetLeft;

          y = sender.offsetTop;

          while (bsc = bsc.offsetParent)

          {

             x += bsc.offsetLeft;

             y += bsc.offsetTop;

          }          

          _sub_menu.style.left  = x + offset + 'px';    

          _sub_menu.style.top   = y + 30 + 'px';   

          _sub_menu.onmouseover =  function (evt)

                                   {

                                       evt = (evt) ? evt : window.event;

                                       evt.cancelBubble = true;

                                   }

       }

    }

    else

       hideSubMenu();

}



function showSubMenu2(sender, ident)

{

    _sub_menu2 = document.getElementById('submenu2');

    if ((_sub_menu2)&&(ident.length > 0))

    {

       _sub_list2 = document.getElementById('submenu_'+ident);

       if (_sub_menu2 && _sub_list2)

       {

          _sub_menu2.innerHTML     = _sub_list2.innerHTML;

          _sub_menu2.style.display = 'block';

          _sub_menu2.style.left    = (sender.offsetLeft+

                                      sender.parentNode.parentNode.offsetLeft+

                                      sender.offsetWidth)+9+'px';

          _sub_menu2.style.top     = (sender.parentNode.offsetTop)+

                                     (sender.parentNode.parentNode.offsetTop)+'px';

          _sub_menu2.onmouseover   =  function (evt)

                                      {

                                          evt = (evt) ? evt : window.event;

                                          evt.cancelBubble = true;

                                      }

       }

    }

    else

       hideSubMenu();

}



function hideSubMenu()

{

    _sub_menu = document.getElementById('submenu');

    if (_sub_menu)

    {

        _sub_menu.innerHTML = '';

        _sub_menu.style.backgroundPosition = '-100px 0px';

        _sub_menu.style.display = 'none';

    }

}

function hideSubMenu2()

{

    _sub_menu2 = document.getElementById('submenu2');

    if (_sub_menu2)

    {

        _sub_menu2.innerHTML = '';

        _sub_menu2.style.backgroundPosition = '-100px 0px';

        _sub_menu2.style.display = 'none';

    }

}

function hideSubMenus()

{

    hideSubMenu2();

    hideSubMenu();

}



//$(window).load(function() {

//    test_link();

//});

