

/*******************
* Browser checking *
********************/
var NS4 = (document.layers)? true:false;
var IE4 = (document.all)? true:false;
var IE5 = false;
var GECKO = false;
if (IE4) {	
	if (navigator.userAgent.indexOf('MSIE 5')>0) {	
		IE5 = true;	
	}
}

if(navigator.userAgent.indexOf("Gecko") != -1)
{
	GECKO = true;
}


function saicoSwapImg(idzdj,zdj, swapFile){


  newImg = new Image();
	newImg.src= swapFile;
 
	
	newImg.onload = function () { 
								document.getElementById(zdj).src = newImg.src;  
								document.getElementById(zdj).style.height = newImg.height+'px'; 
								document.getElementById(zdj).style.width  = newImg.width+'px';				
	}

	
  if (newImg.complete) {
	   document.getElementById(zdj).src = newImg.src; 
		 document.getElementById(zdj).style.height = newImg.height+'px'; 
		 document.getElementById(zdj).style.width  = newImg.width+'px';	 
	} 
	

 zmienna = idzdj;	
 //alert(zmienna);
	 
	//zdjecie = document.getElementById(zdj);
	//zdjecie.src = swapFile;
	//zdjecie.refresh();
	
	//zdjecie.style.height = '299px'; 
	//zdjecie.style.width  = '200px';
	

	//alert(zdjecie.style.width);
	//zdjecie.style.width =   '200px';
	//zdjecie.style.height =  newImg.height+'px';
	//var width = newImg.height;
	//alert(swapFile );
	//document.getElementById(zdj).style.width  = newImg.width+'px';
	//document.getElementById(zdj).style.height = newImg.height+'px';
  
	//newImg.src = swapFile;



	
  //zdjecie = document.getElementById(zdj);
	//zdjecie.src = swapFile;
	//zdjecie.refresh();
}




function moveElement(id, x, y)
{
    if (document.getElementById)
    {
        document.getElementById(id).style.left = x + 'px';
        document.getElementById(id).style.top = y + 'px';
    }
}
function showElement(id)
{
    if (document.getElementById)
    {
        if (document.getElementById(id))
        {
            document.getElementById(id).style.visibility = 'visible';
        }
    }
}
function hideElement(id)
{
    if (document.getElementById)
    {
        if (document.getElementById(id))
        {
            document.getElementById(id).style.visibility = 'hidden';
        }
    }
}

function swapHtml(id, html)
{
    if (document.getElementById)
    {
        if (document.getElementById(id))
        {
            document.getElementById(id).innerHTML = html;
        }
    }
}



function moveSwatch(index, swatchDiv, colorDesc, img, isSaico, lang){

	sCont=document.getElementById("swatchColor" + index);
	sBCont=document.getElementById("bodycontainer");
	sContTop = sCont.offsetTop + sBCont.offsetTop;
	sContLeft = sCont.offsetLeft + sBCont.offsetLeft;
	sContWidth = sCont.offsetWidth;
	sContRight = sContLeft+sContWidth;
	
	sBox=document.getElementById("SwatchBox");
	sBoxTop = sBox.offsetTop;
	sBoxLeft = sBox.offsetLeft;
	sBoxWidth = sBox.offsetWidth;
	sBoxHeight = sBox.offsetHeight;
	
	sBoxNewLeft = sContLeft + (swatchDiv.offsetLeft + (swatchDiv.offsetWidth / 2) ) - (sBoxWidth/2)
	sBoxNewRight = sBoxNewLeft + (sBoxWidth)

	if ((sBoxNewLeft) < (sContLeft)) {
		sbPosLeft=sContLeft;
	} else if ((sBoxNewRight) > (sContRight )){
		sbPosLeft=sContRight - sBoxWidth -4;
	} else {
		sbPosLeft=sBoxNewLeft;
	}

	imgTag='<img src="' +img+ '">';
	imgURL= img;
	showSwatch(index);

	var IfrRef = document.getElementById('DivShim');
	IfrRef.style.width = sBox.offsetWidth;
    IfrRef.style.height = sBox.offsetHeight;
    IfrRef.style.top = sBox.style.top;
    IfrRef.style.left = sBox.style.left;
    IfrRef.style.zIndex = 999;

	moveElement('DivShim', sbPosLeft, sContTop-sBoxHeight-1);
	moveElement('SwatchBox', sbPosLeft, sContTop-sBoxHeight-1);
	swapHtml('SwatchBoxColorDesc', colorDesc);
	if (isSaico){
		if (lang =='eng') swapHtml('SwatchBoxAction', "click to change color in photo.");
		if (lang =='pl')  swapHtml('SwatchBoxAction', "kliknij aby zmienić zdjęcie");
		//swapHtml('SwatchBoxAction', "");// puki znie dziala zmienianie
		
	} else {
		swapHtml('SwatchBoxAction', "");
	}
	//document.images["SwatchBoxImg"].src = imageURL
	
	swapHtml('SwatchBoxImg', imgTag);
}

dispSwatch=false;
function hideSwatch(index){
	dispSwatch=false;
	setTimeout('doHideSwatch()',100);
}
function doHideSwatch(index){
	if(!dispSwatch){
		var IfrRef = document.getElementById('DivShim');
		IfrRef.style.display = "none";
		hideElement('SwatchBox');
	}
}
function showSwatch(index){
	dispSwatch=true;
	var IfrRef = document.getElementById('DivShim');
	IfrRef.style.display = "block";
	showElement('SwatchBox');
}

{
	document.write("<div class=\"SwatchBox\" id=\"SwatchBox\">");
	document.write(	"<div class=\"SwatchBoxImg\" id=\"SwatchBoxImg\"></div>");
	document.write(	"<div class=\"SwatchBoxText\">");
	document.write(		"<div class=\"SwatchBoxColorDesc\" id=\"SwatchBoxColorDesc\"></div>");
	document.write(		"<div class=\"SwatchBoxAction\" id=\"SwatchBoxAction\"></div>");
	document.write(	"</div>");
	document.write("</div>");
	document.write("<iframe class=\"DivShim\" id=\"DivShim\" src=\"javascript:false;\" scrolling=\"no\" frameborder=\"0\" style=\"position:absolute; top:0px; left:0px; display:none;\"></iframe>");

}


function sprawdzKosz()
{
	
	//return confirm('sdfsdf');
	//alert('dsfs');
	return true;
}


