function setFrame(){

if($('img_img')){
  offt=$('img_img').cumulativeOffset().top;
  offl=$('img_img').cumulativeOffset().left;
  $('frame').style.top=offt+'px';
  $('frame').style.left=offl+'px';
  $('frame').style.display='';
}

}
function zmienColor(co,jaki)
{
co.style.backgroundColor=jaki;
}

function przeskocz(gdzies)
{
parent.location.replace(gdzies);
}

function potwierdz(tresc,cel)
{
if (confirm(tresc))
 {
 parent.location.replace(cel);
 }
}



//added
var sliderw,sliderh,bg,thumb,valuearea,textfield,blockSlide=false;



    // The slider can move 200 pixels down

    
    
    
function sliderInitW(priceSet) {
    var Event = YAHOO.util.Event,
        Dom   = YAHOO.util.Dom,
        lang  = YAHOO.lang,
        bg="slider-bgw", thumb="slider-thumbw", 
        valuearea="slider-valuew", textfield="slider-converted-valuew"

    // The slider can move 0 pixels up
    var topConstraint = 0;



    // Custom scale factor for converting the pixel offset into a real value
    var scaleFactor = ratioW;

    // The amount the slider moves when the value is changed with the arrow
    // keys


    Event.onDOMReady(function() {

        sliderw = YAHOO.widget.Slider.getHorizSlider(bg, 
                         thumb, topConstraint, bottomConstraint, tickSize);

        // Sliders with ticks can be animated without YAHOO.util.Anim
        sliderw.animate = true;

        sliderw.getRealValue = function() {
            return Math.round(minSizeW+(this.getValue() * scaleFactor));
        }
        sliderw.getPrice = function() {
        var pricetemp=Math.round((priceMin+((this.getValue()) * ratioPrice))*10);
        //alert(pricetemp);
        pricetemp=pricetemp/10;
        pricetemp=pricetemp+"";
        temp=pricetemp.split('.');
        //alert(pricetemp+':'+(temp[1]));
        
        if(temp[1])while(temp[1].length<2)temp[1]=temp[1]+'0';
        else temp[1]='00';
        pricetemp=temp.join('.');
            return pricetemp;
        }
        sliderw.setPrice = function() {
        sliderw.setValue(priceSet, false);
        }
        
Dom.get('slider-converted-valuew').value=sliderw.getRealValue();
sliderw.setPrice();        
        
        sliderw.subscribe("change", function(offsetFromStart) {

            //var valnode = Dom.get(valuearea);
            var fld = Dom.get(textfield);
            

            // Display the pixel value of the control
            //valnode.innerHTML = offsetFromStart;
            // use the scale factor to convert the pixel offset into a real
            // value
            var actualValue = sliderw.getRealValue();

            // update the text box with the actual value
            fld.value = actualValue;

            // Update the title attribute on the background.  This helps assistive
            // technology to communicate the state change
            Dom.get(bg).title = "sliderw value = " + actualValue;
            

        });

        sliderw.subscribe("slideStart", function() {
                YAHOO.log("slideStart fired", "warn");
                
            });

        sliderw.subscribe("slideEnd", function() {
        var price = Dom.get(priceVal);
        var cartPrice = Dom.get('cartPriceHidden');
        var cartPriceP = Dom.get('cartPriceHiddenP');
        var prodW = Dom.get('prodW');
        var prodWP = Dom.get('prodWP');
                
                YAHOO.log("slideEnd fired", "warn");
                if(!blockSlide)blockSlide=true;
                else blockSlide=false;
                  if(blockSlide)sliderh.setValue(sliderw.getValue(), false);
            
            // Display price
            
            var actualPrice = sliderw.getPrice();
            
            price.innerHTML = actualPrice+'&nbsp;zł';
            cartPrice.value = actualPrice;
            cartPriceP.value = actualPrice;
            prodW.value = sliderw.getRealValue();
            prodWP.value = sliderw.getRealValue();
            });

        // Listen for keystrokes on the form field that displays the
        // control's value.  While not provided by default, having a
        // form field with the slider is a good way to help keep your
        // application accessible.
        Event.on(textfield, "keydown", function(e) {

            // set the value when the 'return' key is detected
            if (Event.getCharCode(e) === 13) {
                var v = parseFloat(this.value, 10);
                v = (lang.isNumber(v)) ? v : 0;

                // convert the real value into a pixel offset
                sliderw.setValue(Math.round(v/scaleFactor));
            }
        });
        
        // Use setValue to reset the value to white:
        Event.on("putval", "click", function(e) {
            sliderw.setValue(100, false); //false here means to animate if possible
        });
        
        // Use the "get" method to get the current offset from the slider's start
        // position in pixels.  By applying the scale factor, we can translate this
        // into a "real value
        Event.on("getval", "click", function(e) {
            YAHOO.log("Current value: "   + sliderw.getValue() + "\n" + 
                      "Converted value: " + sliderw.getRealValue(), "info", "example"); 
        });
    });
};

function sliderInitH() {
    var Event = YAHOO.util.Event,
        Dom   = YAHOO.util.Dom,
        lang  = YAHOO.lang,
        bg="slider-bgh", thumb="slider-thumbh", 
        valuearea="slider-valueh", textfield="slider-converted-valueh"

    // The slider can move 0 pixels up
    var topConstraint = 0;

    // Custom scale factor for converting the pixel offset into a real value
    var scaleFactor = ratioH;

    // The amount the slider moves when the value is changed with the arrow
    // keys


    Event.onDOMReady(function() {

        sliderh = YAHOO.widget.Slider.getHorizSlider(bg, 
                         thumb, topConstraint, bottomConstraint, tickSize);

        // Sliders with ticks can be animated without YAHOO.util.Anim
        sliderh.animate = true;

        sliderh.getRealValue = function() {
            return Math.round(minSizeH+(this.getValue() * scaleFactor));
        }

Dom.get('slider-converted-valueh').value=sliderh.getRealValue();

        sliderh.subscribe("change", function(offsetFromStart) {

            //var valnode = Dom.get(valuearea);
            var fld = Dom.get(textfield);

            // Display the pixel value of the control
            //valnode.innerHTML = offsetFromStart;

            // use the scale factor to convert the pixel offset into a real
            // value
            var actualValue = sliderh.getRealValue();

            // update the text box with the actual value
            fld.value = actualValue;

            // Update the title attribute on the background.  This helps assistive
            // technology to communicate the state change
            Dom.get(bg).title = "sliderh value = " + actualValue;
            
        });

        sliderh.subscribe("slideStart", function() {
                YAHOO.log("slideStart fired", "warn");
            });

        sliderh.subscribe("slideEnd", function() {
                YAHOO.log("slideEnd fired", "warn");
                if(!blockSlide)blockSlide=true;
                else blockSlide=false;
                  if(blockSlide)sliderw.setValue(sliderh.getValue(), false);
                var prodHP = Dom.get('prodHP');
                var prodH = Dom.get('prodH');
                prodH.value = sliderh.getRealValue();
                prodHP.value = sliderh.getRealValue();
            });

        // Listen for keystrokes on the form field that displays the
        // control's value.  While not provided by default, having a
        // form field with the slider is a good way to help keep your
        // application accessible.
        Event.on(textfield, "keydown", function(e) {

            // set the value when the 'return' key is detected
            if (Event.getCharCode(e) === 13) {
                var v = parseFloat(this.value, 10);
                v = (lang.isNumber(v)) ? v : 0;

                // convert the real value into a pixel offset
                sliderh.setValue(Math.round(v/scaleFactor));
            }
        });
        
        // Use setValue to reset the value to white:
        Event.on("putval", "click", function(e) {
            sliderh.setValue(100, false); //false here means to animate if possible
        });
        
        // Use the "get" method to get the current offset from the slider's start
        // position in pixels.  By applying the scale factor, we can translate this
        // into a "real value
        Event.on("getval", "click", function(e) {
            YAHOO.log("Current value: "   + sliderh.getValue() + "\n" + 
                      "Converted value: " + sliderh.getRealValue(), "info", "example"); 
        });
    });
};

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function changeTemplateColor(id,prod){

    var url='ajax.php';
    var pars='ajax=changeColor&id='+id+'&prod='+prod;
    
    var myAjax=new Ajax.Request(url,{ method: 'get', parameters: pars,onSuccess: function(t)
    {
      eval(t.responseText);
    }
    });

}
function flipTemplate(mode){
    
    var url='ajax.php';
    var pars='ajax=flip&img='+$('img_m').src+'&mode='+mode;
    $('imgcont').innerHTML='<img src="ajax-loader.gif" id="img_m">';
    var myAjax=new Ajax.Request(url,{ method: 'get', parameters: pars,onSuccess: function(t)
    {
      eval(t.responseText);
    }
    });

}

