mkPopup=function(mypage,myname,w,h,scroll){
 var winl=(screen.width-w)/2;
 var wint=(screen.height-h)/2;
 var settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
 win=window.open(mypage,myname,settings);
}
resBody=function(o){
	return true;
	var w=o.width;
	var h=o.height;
	if (w>0&&h>0) {
		var resWidth = w + 0;
		var resHeight = h + 40;
		var ua = navigator.userAgent.toLowerCase();
		var isOp=(ua.indexOf("opera")!=-1?true:false);
		var isIe=(ua.indexOf("msie")!=-1&&!isOp?true:false);
		if (isIe) {
			resWidth = w + 35;
			resHeight = h + 65;
		}
	
		if (window.screen.width < resWidth)resWidth=window.screen.width-20;
		if (window.screen.height < resHeight)resHeight=window.screen.height-20;
		
		window.resizeTo(resWidth, resHeight);
		
		var wx=(screen.width-w)/2, wy=(screen.height-h)/2;
 		window.moveTo(wx,wy);
		//self.focus();
	}
}
function preloadImg(src) {
	new Image().src=src;
}

function tabs(tabsconfig)
{
	this.tabsconfig = tabsconfig;
	
	this.ch = function(tab_active)
	{
		for(i=0; i<this.tabsconfig.length; i++)
		{
			if (this.tabsconfig[i] == tab_active)
			{
				$('t'+this.tabsconfig[i]).className = this.tabsconfig[i]+'_a';
				$('c'+this.tabsconfig[i]).className = 'txt'+this.tabsconfig[i]+'_a';
			}
			else
			{
				$('t'+this.tabsconfig[i]).className = this.tabsconfig[i];
				$('c'+this.tabsconfig[i]).className = 'txt'+this.tabsconfig[i];
			}
		}
	}
}

function gourl(u)
{
	document.location.replace(u);
	return false;
}

function cart()
{
	this.addProduct = function(prodId, colorObj, sizeObj)
	{
		//alert('Obsługa dodania do koszyka produktu o ident. '+prodId)
		var _size = '';
		if (colorObj)
		{
			if (colorObj.selectedIndex==0)
			{
				alert('Wybierz kolor.');
				return false;
			}
			else
			{
				if (sizeObj.selectedIndex==0)
				{
					alert('Wybierz rozmiar.');
					return false;
				}
				else
				{
					//M:Różowy:3
					var _colorId = colorObj.getValue()
					var _colorName = colorObj[colorObj.selectedIndex].text
					var _sizeId = sizeObj.getValue()
					_size = _sizeId + ':' + _colorName + ':' + _colorId;
				}
			}
		}
		document.location.replace(SERVOFFSET+'/koszyk.html?a=prod_add&p='+prodId+'&s='+_size);
	}
} 

function chmimg(imgid) {
	if (imgs[imgid]) {
		$('phone_mimg').src = imgs[imgid].S;
		$('phone_mimg').parentNode.href=imgs[imgid].D;
		new Image().src=imgs[imgid].D;
	}
}

cart = new cart();
function checkOrderFrm(fobj)
{
	var paytype_checked = false;
	for(var i=0; i<fobj.paytype.length; i++)
	{
		if (fobj.paytype[i].checked)
		{
			paytype_checked = true;
			throw $break;
		}
	}
	if (!paytype_checked)
	{
		alert('Wybierz sposób płatności.');
		return false;
	}
}

teltabs = new tabs(['ogolne', 'dane', 'dod_funkcje', 'oprogramowanie']);

var prodSizes_sizes = {}
function prodSizes_onColorChange(o)
{
	$('CA_ROZMIAR_').options.length=1;
	if (o.selectedIndex>0)
	{
		var idx = o.getValue();
		
		if (prodSizes_sizes[idx].length)
		{
			prodSizes_sizes[idx].each(function(e){
				$('CA_ROZMIAR_').options[$('CA_ROZMIAR_').options.length] = new Option(e[0] + (e[1] =='T' ? ' (24 h)' : ' (14 dni)'), e[0])
			})
		}
		else
		{
			$('CA_ROZMIAR_').options.length=1;
		}
	}
}

/* newsletter */
function newsletter_change(obj){input_change(obj,'Wpisz swój adres e-mail')}
function input_change(obj,txt){if(obj.value==txt)obj.value=''};
function newsletter_send(o){
	if (typeof o == 'undefined') {
		o = '';
	}
	var err=false;
	var eObj=$('newsletter_email'+o);
	if (eObj.value==null||eObj.value==''||eObj.value=='Wpisz swój adres e-mail'||!isEmail(eObj.value))
	{
		err=true;
		alert('Wpisz poprawny adres e-mail.');
		eObj.focus();
		return false;
	}
	
	advAJAX.get({
		url: "/index.php?m=newsletter&a=addemail&email="+eObj.value,
		onLoading : function(obj){ /* Wy?wietlenie obrazka wskazuj?cego na ?adowanie */ },
		onComplete : function(obj) { /* Ukrycie obrazka... */ },
		onSuccess : function(obj) {
			eval('ret = obj.responseText');
			if (ret == '-1') {
				alert('Podany adres email już został dopisany do naszej bazy.');
				eObj.value='';
				eObj.focus();
			} else if (ret == '1') {
				alert('Dziękujemy. Twój email został dopisany do naszego newslettera.');
				eObj.value='';
			} else {
				alert('Wpisz poprawny adres e-mail.');
			}
		}
	})
	return false;
}

function search_change(obj){input_change(obj,'szukaj...')}

/** email validation stuff. Based on: SmartWebby.com (http://www.smartwebby.com/dhtml/) */
isEmail=function(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}
	
	if (str.indexOf(" ")!=-1){
		return false
	}

	return true					
}

function checkHeight(d) {
	if (!d) return false;
	var divHeight=0;
	//d=$(arguments[0]);
	if(d.offsetHeight)
		divHeight=d.offsetHeight;
	else if(d.style.pixelHeight)
		divHeight=d.style.pixelHeight;
	return divHeight;
}
function max(a,b) {return (a>b)?a:b}
function bim(){try{window.event.returnValue=false}catch(e){};return false}

function addToFavorite()
{
	try {
		window.external.AddFavorite(document.location, document.title);
	} catch(e) {
		alert('Jeżeli chcesz dodać tę stronę do ulubionych, naciśnij OK a następnie CTRL+D');
	}
}