function changeSlider(ktory){
	
	if(activeSlide!=ktory){
		if(ktory<1){
		   ktory = 1;	 
		}
		if(ktory>jQuery('#auto-slider .slider-item').size()){
		   ktory = 1;	 
		}
		pom = activeSlide-1;
		if(pom<0){
			pom=1;
		}
		
		jQuery('#auto-slider .slider-item:eq('+(ktory-1)+')').fadeIn(1500);
		jQuery('#auto-slider .slider-item:eq('+pom+')').fadeOut(1500);
		jQuery('#auto-slider #slider-navi a:eq('+(ktory-1)+')').addClass('active');
		jQuery('#auto-slider #slider-navi a:eq('+pom+')').removeClass('active');
		activeSlide = ktory;
		timeout3 = setTimeout('changeSlider('+(ktory+1)+')',10000);
	}
	
}

function setTab(container, id, id2){
	jQuery('.prodmsel').attr('class', 'prodm');
	jQuery('#'+id2+'').attr('class', 'prodmsel');
	jQuery('#'+container+' .prodtext').css('display', 'none');
	jQuery('#'+id+'').css('display', 'block'); 
}

function showHide(idElement1, idElement2){
    
	jQuery('#'+idElement2+'').css('display','none');
	jQuery('#'+idElement1+'').css('display','block');
	
	return true;
	
}

function changeFoto2(idElementu, zdj1, zdj2, id){
	
	jQuery('#'+idElementu+'').html('<a href="'+zdj2+'" rel="lightbox[galeria]"><img src="'+zdj1+'" width="550" height="440" border="0" alt="" /></a>');
	jQuery('#prodmin img').css('border-width', '1px');
	jQuery('#'+id+' img').css('border-width', '2px');
	return true;
	
}

function selectTab(obj,container, class1, class2, class3){
	jQuery('.'+class2+'').attr('class',class1);
	jQuery(obj).attr('class',class2);
	poz = jQuery('#'+container+' a').index(obj);
	jQuery('.'+class3+'').css('display','none');
	jQuery('.'+class3+':eq('+poz+')').css('display','block');
	return true;
}

function changeImg(idElement1, imgsrc1, idElement2, imgsrc2){
	
	jQuery('#'+idElement2+'').attr('src',imgsrc2);
	jQuery('#'+idElement1+'').attr('src',imgsrc1);
	
	return true;
}

function changeImg2(idElement, imgsrc){
	
	jQuery('#'+idElement+'').attr('src',imgsrc);
	return true;
	
}

function zwinRozwin(id){
	
	if(jQuery('#'+id+'')){
		if(jQuery('#'+id+'').css('display')!='none'){
			jQuery('#'+id+'').slideUp('slow');
		}else{
			jQuery('#'+id+'').slideDown('slow'); 
		}
	}
	return true;
}

function changeFoto(imgId, imgName1, imgName2){
	
	src = jQuery('#'+imgId+'').attr('src');
	if(src.indexOf(imgName1)!=-1){
	  jQuery('#'+imgId+'').attr('src', src.replace(imgName1, imgName2));
	}else{
	  jQuery('#'+imgId+'').attr('src', src.replace(imgName2, imgName1));
	}
	
}

function checkValue(idElementu){
	
	val = parseInt(jQuery('#'+idElementu+'').val());
	
	if(!val){
		jQuery('#'+idElementu+'').val('1');
	}else{
		jQuery('#'+idElementu+'').val('0');
	}
	
}

function pokazUkryjFVat(id, pole_id, imgid, imgcheck, imguncheck){
	  
	  pole = document.getElementById(id);
	  pole1 = document.getElementById(pole_id);
	  if(pole){
		  wlasciwosc = pole.style.display;
		  imgsrc = jQuery('#'+imgid).attr('src');
		  if(wlasciwosc=='none'){
			  //pole.style.display = 'block';
			  jQuery('#'+id+'').slideDown(0);
			  jQuery('#'+imgid).attr('src', imgsrc.replace(imguncheck,imgcheck));
			  //$(imgid).src = imgsrc.replace(imguncheck,imgcheck);
			  if(pole1){
				  pole1.value = 1;
			  }
		  }else{
			  //pole.style.display = 'none';
			  jQuery('#'+id+'').slideUp(0);
			  jQuery('#'+imgid).attr('src', imgsrc.replace(imgcheck,imguncheck));
			   if(pole1){
				  pole1.value = 0;
			  }
		  }
	  }
  }

function checkElement(formId, idElementu, wartosc){
	
	if(jQuery('#'+idElementu+'').size()){
		jQuery('#'+idElementu+'').remove();
		
	}else{
		jQuery('#'+formId+'').append('<input type="hidden" name="'+idElementu+'" id="'+idElementu+'" value="'+wartosc+'" />'); 
	}
	
	//setVisibleItem(document.location.search.substring(1));
	
}

function isset(varname) {
  if(typeof( window[ varname ] ) != "undefined") return true;
  else return false;
}

function setVisibleItem(){
	
	querystring = document.location.search.substring(1);
	tabPom = new Array();
	tabPom2 = new Array();
	tabExplode = querystring.split('&');
	tabExplode = tabExplode.reverse();
	ciag = '';
	
	for(i=0;i<tabExplode.length;i++){
		tabExplode2 = tabExplode[i].split('=');
		if(tabExplode2.length==2){
			idZm = tabExplode2[0].split('_');
			if(idZm.length==3 && idZm[0]=='atr'){
				idZm = idZm[idZm.length-2];
				if(typeof(tabPom[idZm])=='undefined'){
					
					tabPom[idZm] = tabExplode2[1];	
					
				}
			}
		}
	}
	
	return tabPom;

}

function replaceElement(idElementu1, idElementu2, srch){
	
	if(jQuery('#'+idElementu2+'').size()){
		
		val1 = jQuery('.'+idElementu1+':first').attr('href');
		val2 = jQuery('#'+idElementu2+'').val();
		
			val3 = val1.replace(srch,srch.substr(0,srch.length-1)+val2);
			jQuery('.'+idElementu1+'').each(function(index, domElem){
				jQuery(domElem).attr('href', val3);										  
			});
	}
	
}

function zwinRozwin1(id){
	
	if(jQuery('#'+id+'')){
		if(jQuery('#'+id+'').css('display')=='none'){
			jQuery('#'+id+'').slideDown(10); 
		}
	}
	return true;
}


function setSize(containerId, labelId, formElemId, value, text){
	
	jQuery('#'+labelId+'').html(text);
	jQuery('#'+formElemId+'').val(value);
	jQuery('#'+containerId+'').slideUp('fast'); 
	
	return true;
	
}


function pokazUkryjPole(nazwaPola, poleCheckbox){
	
	tabPom = poleCheckbox.split('_');
	tabPom2 = nazwaPola.split('_');
	ciag2 = tabPom2[0]+'_'+tabPom2[1];
	
	if(tabPom.length==5){
		pp = document.getElementById(poleCheckbox);
		zz = document.getElementById(nazwaPola);
		if(pp.checked){
	       zz.className = 'pokaz';
		}else{
		   zz.className = 'ukryj';
		}
		ciag = tabPom[0]+'_'+tabPom[1]+'_'+tabPom[2]+'_'+tabPom[3];
		tabCheckbox = document.getElementsByTagName('input');
		for(i=0;i<tabCheckbox.length;i++){
			tabPom1 = tabCheckbox[i].id.split('_');
			ciag1 = tabPom1[0]+'_'+tabPom1[1]+'_'+tabPom1[2]+'_'+tabPom1[3];
			if((tabPom1.length==5) && (tabCheckbox[i].type=='checkbox') && (ciag1==ciag) && (poleCheckbox!=tabCheckbox[i].id)){
				pm = document.getElementById(ciag2+'_'+tabPom1[4]);
				if(pp.checked){
					tabCheckbox[i].checked = false;
					pm.className = 'ukryj';
				}
			}
		}
	}
	
	return true;
}

function pokazUkryjPola(id, znacznik, ukryjClass, pokazClass){
	elts = document.getElementsByTagName(znacznik);
	check = document.getElementById(id);
	for(i=0;i<elts.length;i++){
		if(check.checked){
			if(elts[i].className==ukryjClass){
			   elts[i].className=pokazClass;
			}
		}else{
			if(elts[i].className==pokazClass){
			     elts[i].className=ukryjClass;
			}
		}
	}
	return true;
}

function ajaxSuwak(idElementu1, idElementu2, idElementu3){
	//$(idElementu1).innerHTML = '<div style="text-align: center; padding: 80px 0 0 0;"><img src="'+site_host+'img/loading.gif" width="16" height="16" alt="" border="0" /></div>';
	//$(idElementu2).innerHTML = '<div style="text-align: center; padding: 80px 0 0 0;"><img src="'+site_host+'img/loading.gif" width="16" height="16" alt="" border="0" /></div>';
	//$(idElementu3).innerHTML = '<div style="text-align: center; padding: 80px 0 0 0;"><img src="'+site_host+'img/loading.gif" width="16" height="16" alt="" border="0" /></div>';
	jQuery('#'+idElementu1+' a').fadeTo(1000, 0.3);
	jQuery('#'+idElementu2+' a').fadeTo(1000, 0.3);
	jQuery('#'+idElementu3+' a').fadeTo(1000, 0.3);
	
	new Ajax.Request(site_host + 'ajax_suwak.php', {
		method: 'get', 
		onComplete:function(request){
			var xmlResponse = request.responseXML.documentElement;
			html1 = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : '';
			html2 = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(1).firstChild.data : '';
			html3 = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(2).firstChild.data : '';
			$(idElementu1).innerHTML = html1;
			$(idElementu2).innerHTML = html2;
			$(idElementu3).innerHTML = html3;
			jQuery('#'+idElementu1+' a').fadeTo(1500, 1.0);
	        jQuery('#'+idElementu2+' a').fadeTo(1500, 1.0);
	        jQuery('#'+idElementu3+' a').fadeTo(1500, 1.0);
		}
	});
	
	return true;
}

function ajaxKoszty(siteHost, form, poleDostawa, polePlatnosci){
	idDostawy = 0;
	idPlatnosci = 0;
	for(i=0; i < $(form).elements.length; i++){
		if($(form).elements[i].type == 'radio'){
			if($(form).elements[i].name == poleDostawa && $(form).elements[i].checked){
				idDostawy = $(form).elements[i].value;
			}else if($(form).elements[i].name == polePlatnosci && $(form).elements[i].checked){
				idPlatnosci = $(form).elements[i].value;
			}
		}
	}

	new Ajax.Request(siteHost + 'ajax_koszty.php', {
		method: 'get', 
		parameters:'id_dostawy='+escape(idDostawy)+'&id_platnosci='+escape(idPlatnosci), 
		onComplete:function(request){
			var xmlResponse = request.responseXML.documentElement;
			$('koszty-info').innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 034';
		}
	});
	
	return true;
}

function sendForm(formId, komId, plik){
	 
	 new Ajax.Request(site_host + plik, {
		method: 'post', 
		parameters: jQuery('#'+formId+'').serialize(), 
		onComplete:function(request){
			var xmlResponse = request.responseXML.documentElement;
			$(komId).innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 034';
			ok = parseInt(xmlResponse.childNodes.item(1).firstChild.data);
			if(ok){
			   jQuery('#'+formId+' input[type="text"]').val('');
			   jQuery('#'+formId+' textarea').val('');
			}
		}
	});
	
	return true;
	 
}

function kopiujAdres(){
	kopiujWartosc('firma', 'firma_koresp');
	kopiujWartosc('telefon', 'telefon_koresp');
	kopiujWartosc('imie', 'imie_koresp');
	kopiujWartosc('nazwisko', 'nazwisko_koresp');
	kopiujWartosc('ulica_glowny', 'ulica_koresp');
	kopiujWartosc('nr_domu_glowny', 'nr_domu_koresp');
	kopiujWartosc('nr_mieszkania_glowny', 'nr_mieszkania_koresp');
	kopiujWartosc('kod_pocztowy_glowny', 'kod_pocztowy_koresp');
	kopiujWartosc('miejscowosc_glowny', 'miejscowosc_koresp');
	return true;
}

function kopiujAdres2(){
	
	kopiujWartosc('firma_koresp', 'firma_faktura');
	kopiujWartosc('imie_koresp', 'imie_faktura');
	kopiujWartosc('nazwisko_koresp', 'nazwisko_faktura');
	kopiujWartosc('ulica_koresp', 'ulica_faktura');
	kopiujWartosc('nr_domu_koresp', 'nr_domu_faktura');
	kopiujWartosc('nr_mieszkania_koresp', 'nr_mieszkania_faktura');
	kopiujWartosc('kod_pocztowy_koresp', 'kod_pocztowy_faktura');
	kopiujWartosc('miejscowosc_koresp', 'miejscowosc_faktura');
	return true;
	
}

function kopiujAdres3(){
	
	kopiujWartosc('firma', 'firma_faktura');
	kopiujWartosc('nip', 'nip_faktura');
	kopiujWartosc('imie', 'imie_faktura');
	kopiujWartosc('nazwisko', 'nazwisko_faktura');
	kopiujWartosc('ulica_glowny', 'ulica_faktura');
	kopiujWartosc('nr_domu_glowny', 'nr_domu_faktura');
	kopiujWartosc('nr_mieszkania_glowny', 'nr_mieszkania_faktura');
	kopiujWartosc('kod_pocztowy_glowny', 'kod_pocztowy_faktura');
	kopiujWartosc('miejscowosc_glowny', 'miejscowosc_faktura');
	return true;
	
}

function kopiujAdres4(){
	
	kopiujWartosc('firma_koresp', 'firma_zamawiajacy');
	kopiujWartosc('imie_koresp', 'imie_zamawiajacy');
	kopiujWartosc('nazwisko_koresp', 'nazwisko_zamawiajacy');
	kopiujWartosc('ulica_koresp', 'ulica_zamawiajacy');
	kopiujWartosc('nr_domu_koresp', 'nr_domu_zamawiajacy');
	kopiujWartosc('nr_mieszkania_koresp', 'nr_mieszkania_zamawiajacy');
	kopiujWartosc('kod_pocztowy_koresp', 'kod_pocztowy_zamawiajacy');
	kopiujWartosc('miejscowosc_koresp', 'miejscowosc_zamawiajacy');
	kopiujWartosc('telefon_koresp', 'telefon_zamawiajacy');
	return true;
	
}


function kopiujWartosc(objIdBaza, objIdCel){
	$(objIdCel).value = $(objIdBaza).value;
	return true;
}

function czLoadForm(siteHost, sklepOutlet){
	$('zone1').innerHTML = '<form name="logform" method="post" action="'+siteHost+'login.html" onsubmit="return false;">'
	+ 'login: <input type="text" name="log_login" id="log_login" class="inp" size="14" maxlength="32" /> &nbsp; '
	+ 'hasło: <input type="password" name="log_pass" id="log_pass" class="inp" size="14" maxlength="32" /> &nbsp; '
	+ '<input name="submit_log" type="image" src="'+siteHost+'/img/bt_zaloguj_'+sklepOutlet+'.gif" align="top" onclick="ajaxLogin($(log_login).value,$(log_pass).value,\''+siteHost+'\')" />'
	+ '</form>';

}

function ajaxLogin(login, pass, siteHost){
	new Ajax.Request(siteHost + 'login2.html', {
		method: 'post', 
		parameters:'login='+escape(login)+'&pass='+escape(pass), 
		onComplete:function(request){
			var xmlResponse = request.responseXML.documentElement;
			$('zone1').innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 034';
			ifReload = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(1).firstChild.data : 0;
			if(ifReload != 0){
				document.location.href = document.location.href;
			}
		}
	});
	
	return true;
}


var IE = (document.all && document.getElementById && !window.opera );
var FF = (!document.all && document.getElementById && !window.opera);
var OP = (document.all && document.getElementById && window.opera);

function zmienFoto(ktory){
	$('mFoto').src = pomImgLoad.src;

	var pomImg2 = new Image();
	pomImg2.src = mSiteHost + 'foto/' + tabFoto[ktory][0];
	pomImg2.onload = function(){
		$('mFoto').src = pomImg2.src;
	}
	if(pomImg2.complete == true){
		$('mFoto').src = pomImg2.src;
	}

	setCssBackgroundImage(mBoxId, mSiteHost + '/img/loading.gif', '50%', '50%');
	mBoxBgImage = mSiteHost + 'foto/' + tabFoto[ktory][1];
	mBoxBgImageIsLoaded = false;
	mBoxBgImageWidth = tabFoto[ktory][2];
	mBoxBgImageHeight = tabFoto[ktory][3];
	mBoxShow();
	mBoxHide();

	ileZdjec = tabFoto.length;
	for(i=0; i < ileZdjec; i++){
		$('mp'+i+'').className = '';	
	}
	$('mp'+ktory).className = 'cur';
}

function mMoveXY(event){
	if(mBoxBgImageIsLoaded){
		mouseX = 0;
		mouseY = 0;
		if(!event){
			var event = window.event;
		}
		if(IE){
			mouseX = event.clientX + document.documentElement.scrollLeft;
			mouseY = event.clientY + document.documentElement.scrollTop;
		}else{ 
			mouseX = event.pageX;
			mouseY = event.pageY;
		}
		mouseX -= $(mContainerId).offsetLeft;
		mouseY -= $(mContainerId).offsetTop;
	
		mFrameOffsetX = parseFloat(mFrameWidth / 2);
		mFrameOffsetY = parseFloat(mFrameHeight / 2);
	
		mBoxBgX = parseInt((-imagesWidthRatio * mouseX) + parseFloat(mBoxWidth / 2));
		mBoxBgY = parseInt((-imagesHeightRatio * mouseY) + parseFloat(mBoxHeight / 2));
	
		if(mBoxBgX > 0){
			mBoxBgX = 0;
		}else if(mBoxBgX < -(mBoxBgImageWidth - mBoxWidth)){
			mBoxBgX = -(mBoxBgImageWidth - mBoxWidth); 
		}
		if(mBoxBgY > 0){
			mBoxBgY = 0;
		}else if(mBoxBgY < -(mBoxBgImageHeight - mBoxHeight)){
			mBoxBgY = -(mBoxBgImageHeight - mBoxHeight); 
		}
		
		setCssBackgroundPosition(mBoxId, mBoxBgX, mBoxBgY);
		
		mFrameY = mouseY - mFrameOffsetY;
		mFrameX = mouseX - mFrameOffsetX;
	
		if(mouseX + mFrameOffsetX > mBaseWidth){
			mFrameX = mBaseWidth - (2 * mFrameOffsetX);
		}else if(mFrameX < 0){
			mFrameX = 0;
		}
			
		if(mouseY + mFrameOffsetY > mBaseHeight){
			mFrameY = mBaseHeight - (2 * mFrameOffsetY);
		}else if(mFrameY < 0){
			mFrameY = 0;
		}
	
		setCssPosition(mFrameId, mFrameY, mFrameX);
		//setCssBackgroundImage(mFrameId, mBoxBgImage, mFrameY, mFrameX);
		//setCssBackgroundImage(mFrameId, '/img/loading.gif', '50%', '50%');
	}
	return true;
}

function calculatemFrameSize(objId, width1, height1, width2, height2){
	width = Math.floor(parseInt(width2) / parseInt(width1));
	height = Math.floor(parseInt(height2) / parseInt(height1));
	setCssSize(objId, height * mFrameRatio, width * mFrameRatio);
	return true;
}

function setCssBackgroundPosition(objId, x, y){
	$(objId).style.backgroundPosition = ''+x+'px '+y+'px';
}

function setCssPosition(objId, top, left){
	$(objId).style.top = parseInt(top)+'px';
	$(objId).style.left = parseInt(left)+'px';
}

function setCssSize(objId, width, height){
	$(objId).style.width = parseInt(width)+'px';
	$(objId).style.height = parseInt(height)+'px';
}

function setCssBackgroundImage(objId, img, left, top){
	$(objId).style.backgroundImage = 'url('+img+')';
	$(objId).style.backgroundPosition = left+' '+top;
}

function mBoxHide(){
	$(mBaseId).className ='';
	$(mFrameId).style.display = 'none';
	//$(mBoxId).style.display = 'none';
	$(mBaseId).style.cursor = 'default';
	return true;
}
function mBoxShow(){
	$(mBaseId).style.cursor = 'crosshair';
	$(mFrameId).style.display = 'block';
	//calculatemFrameSize(mFrameId, mBaseWidth, mBaseHeight, mBoxBgImageWidth, mBoxBgImageHeight);
	mFrameWidth = parseInt(getCssStyleProperties($(mFrameId), 'width'));
	mFrameHeight = parseInt(getCssStyleProperties($(mFrameId), 'height'));
	$(mBaseId).className = 'trans';	
	$(mBoxId).style.display = 'block';
	setCssBackgroundImage(mBoxId, mSiteHost + '/img/loading.gif', '50%', '50%');
	if(mBoxBgImageIsLoaded){
		setCssBackgroundImage(mBoxId, mBoxBgImage, '50%', '50%');
	}else{
		var pomImg = new Image();
		pomImg.src = mBoxBgImage;
		pomImg.onload = function(){
			mBoxBgImageIsLoaded = true;
			setCssBackgroundImage(mBoxId, mBoxBgImage, '50%', '50%');
		}
		if(pomImg.complete == true){
			mBoxBgImageIsLoaded = true;
			setCssBackgroundImage(mBoxId, mBoxBgImage, '50%', '50%');
		}
	}
	return true;
}

function getCssStyleProperties(objId,styleProperties){
	if ($(objId).currentStyle){
		return $(objId).currentStyle[styleProperties];
	}else if (window.getComputedStyle){
		return document.defaultView.getComputedStyle($(objId),null).getPropertyValue(styleProperties);
	}
}

function trim(txt){
    return txt.replace(/(^\s+)|(\s+$)/g, '');
}

function ukryjObiektOId(elId){
	elObject = document.getElementById(elId);
	elObject.style.display = 'none';
}

function wyswietlObiektOId(elId){
	elObject = document.getElementById(elId);
	elObject.style.display = 'block';
}

function przeladuj(loc){
		document.location.href = loc;
}

function limit_dla_pola(limit, pole, span_pole){
	if (document.getElementById(pole).value.length > limit){
		document.getElementById(pole).value = document.getElementById(pole).value.substring(0, limit);
	}
	if(span_pole.length > 0){
		txt = '';
		ile_pozostalo = limit - document.getElementById(pole).value.length;
		txt = '<br />Pozostało ' + ile_pozostalo + ' z ' + limit + ' znaków.';
		document.getElementById(span_pole).innerHTML = txt;
	}
}

function wklej(nazwa_pola){
	document.getElementById(nazwa_pola).value = window.clipboardData.getData('Text');
	return true;
}

function kopiuj(nazwa_pola){
	window.clipboardData.setData('Text', document.getElementById(nazwa_pola).value);
	return true;
}

function limit_dla_pola(limit, pole, span_pole){
	if (document.getElementById(pole).value.length > limit){
		document.getElementById(pole).value = document.getElementById(pole).value.substring(0, limit);
	}
	if(span_pole.length > 0){
		txt = '';
		ile_pozostalo = limit - document.getElementById(pole).value.length;
		txt = '<br />Pozostało ' + ile_pozostalo + ' z ' + limit + ' znaków.';
		document.getElementById(span_pole).innerHTML = txt;
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore(){ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages(){ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d){ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage(){ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
