function changePerpageList( e, href )
{
	window.location.href = href+'&perPage='+e.value;
}

function P7_HScroller(el,dr,tx,ox,spd) { //v1.6 by PVII
 var g,gg,fr,sp,pa='',slw=true,m=false,w,ww,lx,rx;tx=parseInt(tx);
 if((g=MM_findObj(el))!=null){gg=(document.layers)?g:g.style;}else{return;}
 if(dr=="Stop"){if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
 if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& !window.opera){pa="px";}
 if(navigator.userAgent.indexOf("NT")>-1 || navigator.userAgent.indexOf("Windows 2000")>-1){slw=false;}
 if(spd=="Slow"){sp=(slw)?2:1;fr=(slw)?40:30;}else if(spd=="Medium"){sp=(slw)?4:1;fr=(slw)?40:10;
 }else{sp=(slw)?8:4;fr=(slw)?40:10;}if(spd=="Warp"){sp=5000;}var xx = parseInt(gg.left);if(isNaN(xx)){
 if(g.currentStyle){xx=parseInt(g.currentStyle.left);}else if(document.defaultView){
 xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}else{xx=0;}}
 if(document.all || document.getElementById){w=parseInt(g.offsetWidth);if(!w){w=parseInt(g.style.pixelWidth);}
 if(g.hasChildNodes){for(wx=0;wx<g.childNodes.length;wx++){ww=parseInt(g.childNodes[wx].offsetWidth);
 if(ww>w){w=ww;}}}}else if(document.layers){w=parseInt(g.clip.width);}lx=tx-w+parseInt(ox);rx=tx;
 if(dr=="Right"){if(xx>lx){m=true;xx-=sp;if(xx<lx){xx=lx;}}}
 if(dr=="Left"){if(xx<rx){m=true;xx+=sp;if(xx>rx){xx=rx;}}}
 if(dr=="Reset"){gg.left=tx+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
 if(m){gg.left=xx+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=true;
  eval("g.p7Magic=setTimeout(\"P7_HScroller('"+el+"','"+dr+"',"+tx+","+ox+",'"+spd+"')\","+fr+")");
 }else{g.toMove=false;}
}

function popImage(imageURL,imageTitle){
	
defaultWidth  = 500;
defaultHeight = 500;

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight;
var optIE='scrollbars=no,width=150,height=100';
	
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isIE;')
;writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width)+20;');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');
writeln('window.innerHeight=document.images["George"].height+19;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}
}

function o(identyfikator) {
	return document.getElementById(identyfikator);
}

		
function getVisibleHeight(Width, Height) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function openPage(theUrl,W,H){
    var theWin ="'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+W+",height="+H+"'"
	littleWin = window.open(theUrl,'',theWin);
	//littleWin.resizeTo(W+10,H+29);
 	littleWin.focus();
}

function newsletterAdd(){
	
	var form = document.forms['form_newsletter'];
	var email = form.newsletter_email.value;
	
	if(validateEmail(email)){
		form.form_type.value = 'add';
		form.submit();
	}
	else{
		alert('Niepoprawny adres e-mail');
	}
}

function newsletterDel(){
	
	var form = document.forms['form_newsletter'];
	var email = form.newsletter_email.value;
	
	if(validateEmail(email)){
		form.form_type.value = 'del';
		form.submit();
	}
	else{
		alert('Niepoprawny adres e-mail');
	}
}


/*********************************************************/
/* Web Pages Menu                                        */
/*********************************************************/

function hideAllSubMenuMshop(level){

	if ( level == 0 )
	{
		var hrefObj = $$('.menu_a');
		if (hrefObj[0] == null ) return;
		hrefObj[0].className = 'menu_i';
		var selectObj = hrefObj[0].getNext();
	}
	else if ( level == 1 )
	{
		var hrefObj = $$('div .menu_sa');
		if (hrefObj[0] == null ) return;
		hrefObj[0].className = 'menu_si';
		var selectObj = hrefObj[0].getNext();
	}
	else
	{
		var hrefObj = $$('div .menu_ssa');
		if (hrefObj[0] == null ) return;
		hrefObj[0].className = 'menu_ssi';
		var selectObj = hrefObj[0].getNext();
	}

	if (selectObj == null) return;
	selectObj.style.display = "none";

}

function showSubMenu(obj){

	var selectObj = document.getElementById( obj );
	if (selectObj==null)	return;

	if (selectObj.style.display != ""){
		selectObj.style.display = "";
	}
	else
		selectObj.style.display = "none";

	return;
}

var menuSlide = [];
function showSubMenu2(obj){

	var selectObj = o( obj );
	if (selectObj==null)	return;
	
	elemId = obj.replace("sub", "");
	
	catId = "catHref_" + elemId;	
	catObj = o(catId);

	linkObj = catObj.getElementsByTagName("a")[0];
//	alert(linkObj);
	
	menuSlide[elemId].toggle();

	if( linkObj.className == 'slidedown' ){
		linkObj.className = 'slideup';
	}
	else{
		linkObj.className = 'slidedown';
	}
	
	return;
} 

function showSubMenuMshop(catName, hrefName, level){

	var selectObj = $(catName);
	var hrefObj = $(hrefName);
	var elemId = catName.replace("sub", "");
	if (selectObj==null)	return;

	if (selectObj.style.display != ""){

        if ($(catName) != null)
        	hideAllSubMenuMshop(level);

		selectObj.style.display = "";
		if ( level == 0 )
			hrefObj.className = 'menu-shop-active';
		else if ( level == 1 )
			hrefObj.className = 'menu-shop-sub-active';
		else if ( level == 2 )
			hrefObj.className = 'menu-shop-sub-sub-active';
		else
			hrefObj.className = 'menu-shop-sub-sub-sub-active';
	//	menuSlide[elemId].toggle();
	}
	else {

        if ($(catName) != null)
        	hideAllSubMenuMshop(level);

        selectObj.style.display = "none";

		if ( level == 0 )
			hrefObj.className = 'menu-shop-inactive';
		else if ( level == 1 )
			hrefObj.className = 'menu-shop-sub-inactive';
		else if ( level == 2 )
			hrefObj.className = 'menu-shop-sub-sub-inactive';
		else
			hrefObj.className = 'menu-shop-sub-sub-sub-inactive';	
	//	menuSlide[elemId].toggle();
	}



	return;
}

function hideSubMenu(obj){

	if ( obj!="" ){
		var selectObj = document.getElementById( obj );

		if (selectObj != null)
			selectObj.style.display = "none";
	}
}

function highSubItem(obj){

	if ( obj!="" ){
		var selectObj = document.getElementById( obj );

		if (selectObj != null){
			if(selectObj.className=='menu_i')
				selectObj.className='menu_a';

			if(selectObj.className=='menu_si')
				selectObj.className='menu_sa';

			if(selectObj.className=='menu_top_i')
				selectObj.className='menu_top_a';
		}
	}
}

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];}
}
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 validateEmail(string) {
	
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
	return false;
}

function validateCart(type){
	var form = document.forms['cart'];
	var zatwierdz = true;

	if(type=="order") form.form_cart_order.value = 1;
	else form.form_cart_order.value = 0;

	var CartId = document.getElementsByName("cart_id[]");
	 
	if (zatwierdz){
		form.submit();
 	}
}

function otherPlaceChange()
{
	var form = document.shipment;
	
	if (form.delivery_other.checked)
		$('delivery-place').setStyle('display', '');
	else
		$('delivery-place').setStyle('display', 'none');
}

var lastSpanHref = null;
function showHideMshop( obj, id, count, divName )
{	
	var div;
	var divClass = obj.parentNode.className;

	
	for ( var i=0;i<count;i++ ) {
		div = $(divName+'_id_'+i);
		div.style.display = 'none';
	} 
	
//	div = $(divName+'_id_'+id).style.display = '';
	div = $(divName+'_id_'+id);
	new Fx.Tween($(div),{duration: 1000}).start('opacity','0','1');
	div.style.display = '';
		
	var navMenuItem = $$('#'+divName+'_perPage span');
	
	navMenuItem[id].className = "unactive";
	if ( lastSpanHref == null ) {
		lastSpanHref = navMenuItem[0];
	}
	lastSpanHref.className = "active";
	lastSpanHref = navMenuItem[id];
		
}

function ajax_opacity(){
	
	new Fx.Tween($('list-recommended-ajax'),{duration: 1000}).start('opacity','0.2','1');

}

/*********************************************************/
/* Web Pages Scroller                                    */
/*********************************************************/

var scroll = new Array();
var scrollCounter = new Array();
var scrollCount = new Array();
var scrollConfig = new Array();

function initscroll(id, config)
{		
    if ( $('scroll-'+id) == null ) return;    
    if ( $('scroll-content-'+id) == null ) return;

    scrollCount[id] = $$('div.scroll-item-'+id).length;
    scrollCounter[id] = 0;    
    scrollConfig[id] = config;
    
    if (scrollCount[id] <= config.items)
    {
    	$('scroll-'+id+'-prev').destroy();
    	$('scroll-'+id+'-next').destroy();   
    	 
    	return;
    }
    
    if (config.size == undefined)
    {
    	config.size = $('scroll-item-'+id+'-0').getSize();    	
    	if (config.align == 'width')
    		config.size = config.size.x;
    	else
    		config.size = config.size.y;
    }
    $('scroll-content-'+id).setStyle(config.align, (config.size * (scrollCount[id]+2))+'px');

    scroll[id] = new Fx.Scroll('scroll-'+id);
    
    if (config.auto != undefined)
    {
    	(function(){ scrollAuto(id); }).periodical(config.auto);
    }
    
    if (config.set)
    {
    	scrollSet(id, config.set);
    }
}

function scrollPrev(id)
{
	scrollCounter[id]--;
    
	if (scrollCounter[id] < 0)
		scrollCounter[id] = scrollCount[id] - scrollConfig[id].items;

	scroll[id].toElement('scroll-item-' + id + '-' + scrollCounter[id]);
}

function scrollNext(id)
{
	scrollCounter[id]++;
    
	if (scrollCounter[id] > scrollCount[id] - scrollConfig[id].items)
		scrollCounter[id] = 0;

	scroll[id].toElement('scroll-item-' + id + '-' + scrollCounter[id]);
}

function scrollSet(id, idPic)
{
	if (idPic < 0 || idPic > scrollCount[id]-1) return;
	
	scroll[id].toElement('scroll-item-' + id + '-' + idPic);
}

function scrollAuto(id)
{
	scrollCounter[id]++;
    
	if (scrollCounter[id] > scrollCount[id] - scrollConfig[id].items)
		scrollCounter[id] = 0;

	scroll[id].toElement('scroll-item-' + id + '-' + scrollCounter[id]);
}

function scrollToBig(id,nr)
{
	scrollCounter[id]=nr;
	scroll[id].toElement('scroll-item-' + id + '-' + nr);
}

function squareIn(id,side)
{
//	if (!Browser.ie6 && !Browser.ie7)
//	{
		var visibleCon = 'hidden_' + id;
		var Prorow = 'prorow_' + id;
		$$('div.list-recommended-hidden set-left set-abs').setStyle('display', 'none');
		$$('div.list-recommended-entry').setStyle('border', '#FFFFFF 1px solid');
		
		var myEffect = new Fx.Morph(visibleCon, {duration: '500', transition: Fx.Transitions.Quad.easeOut});
		 
		$(visibleCon).setStyle('display','');
		
		if (side == 'left')
		{
			$(visibleCon).setStyle('border-right','#777777 1px solid');
			$(visibleCon).setStyle('border-top','#777777 1px solid');
			$(visibleCon).setStyle('border-bottom','#777777 1px solid');
			
			$(Prorow).setStyle('border-left','#777777 1px solid');
			$(Prorow).setStyle('border-top','#777777 1px solid');
			$(Prorow).setStyle('border-bottom','#777777 1px solid');
		}
		else if (side == 'right')
		{		
			$(visibleCon).setStyle('border-left','#777777 1px solid');
			$(visibleCon).setStyle('border-top','#777777 1px solid');
			$(visibleCon).setStyle('border-bottom','#777777 1px solid');
			
			$(Prorow).setStyle('border-right','#777777 1px solid');
			$(Prorow).setStyle('border-top','#777777 1px solid');
			$(Prorow).setStyle('border-bottom','#777777 1px solid');
		}
			
		//myEffect.start({
		//    'width': [120, 197]
		//});	
//	}

}

function squareOut(id)
{
	//var Prorow = 'prorow_' + id;
	//var visibleCon = 'hidden_' + id;
	//$(visibleCon).setStyle('display','none');
	//$(Prorow).setStyle('border','#FFFFFF 1px solid');
	$$('div.list-recommended-hidden').setStyle('display', 'none');
	$$('div.list-recommended-entry').setStyle('border', '#FFFFFF 1px solid');
}

function squareInAll(id,side)
{
	var visibleCon = 'hidden_' + id;
	var Prorow = 'prorow_' + id;
	$$('div.list-recommended-hidden-all set-left set-abs').setStyle('display', 'none');
	$$('div.list-recommended-entry-all').setStyle('border', '#FFFFFF 1px solid');
	
	var myEffect = new Fx.Morph(visibleCon, {duration: '500', transition: Fx.Transitions.Quad.easeOut});
	 
	$(visibleCon).setStyle('display','');
	
	if (side == 'left')
	{
		$(visibleCon).setStyle('border-right','#777777 1px solid');
		$(visibleCon).setStyle('border-top','#777777 1px solid');
		$(visibleCon).setStyle('border-bottom','#777777 1px solid');
		
		$(Prorow).setStyle('border-left','#777777 1px solid');
		$(Prorow).setStyle('border-top','#777777 1px solid');
		$(Prorow).setStyle('border-bottom','#777777 1px solid');
	}
	else if (side == 'right')
	{		
		$(visibleCon).setStyle('border-left','#777777 1px solid');
		$(visibleCon).setStyle('border-top','#777777 1px solid');
		$(visibleCon).setStyle('border-bottom','#777777 1px solid');
		
		$(Prorow).setStyle('border-right','#777777 1px solid');
		$(Prorow).setStyle('border-top','#777777 1px solid');
		$(Prorow).setStyle('border-bottom','#777777 1px solid');
	}
		
	//myEffect.start({
	//    'width': [120, 197]
	//});		
	
}

function squareOutAll()
{
	$$('div.list-recommended-hidden-all').setStyle('display', 'none');
	$$('div.list-recommended-entry-all').setStyle('border', '#FFFFFF 1px solid');
}

var man_fast;

function searchInit(global, session)
{			
	searchInitMan();
}

function searchInitMan()
{
	if (man_fast == undefined)
	{
		man_fast = new MavSelectBox({ elem: $('sort'), onSelect: function()
		{					
			document.sort.submit();
		}});	
	}
}

function setDesc(type)
{
    var div = $('div_'+type);
    var span = $('span_'+type);
    div.setStyle('display', 'block');
    span.setStyle('color', '#6A3184');

    if (type == 'desc')
    {
        div = $('div_style');
        span = $('span_style');
        if ($defined(div)) div.setStyle('display', 'none');
        if ($defined(span)) span.setStyle('color', '#777777');

        div = $('div_comp');
        span = $('span_comp');
        if ($defined(div)) div.setStyle('display', 'none');
        if ($defined(span)) span.setStyle('color', '#777777');
    }
    else if (type == 'comp')
    {
        div = $('div_style');
        span = $('span_style');
        if ($defined(div)) div.setStyle('display', 'none');
        if ($defined(span)) span.setStyle('color', '#777777');

        div = $('div_desc');
        span = $('span_desc');
        if ($defined(div)) div.setStyle('display', 'none');
        if ($defined(span)) span.setStyle('color', '#777777');
    }
    else
    {
        div = $('div_desc');
        span = $('span_desc');
        if ($defined(div)) div.setStyle('display', 'none');
        if ($defined(span)) span.setStyle('color', '#777777');

        div = $('div_comp');
        span = $('span_comp');
        if ($defined(div)) div.setStyle('display', 'none');
        if ($defined(span)) span.setStyle('color', '#777777');
    }
}

function setPresent()
{
    var div = $('div_present');
    var a = $('button_present');
    
    if (div.getStyle('display') == 'none')
    	{
    		div.setStyle('display', 'block');
    		a.setStyle('color', '#6A3184');
    	}
    else 
    	{
    		div.setStyle('display', 'none');
    		a.setStyle('color', '#7D7D7D');
    	}
}

function paymentSubmit()
{
	var form = document.forms['payform'];

	form.submit().delay(3000);

}

