<!--
function Open(file,title,width,height)
{
	var left=(screen.availWidth-width)/2;
	var top=(screen.availHeight-height)/2;
	window.open(file,title,'toolbar=no,menubar=no,location=no,personalbar=no,status=no,resizable=yes,scrollbars=yes,width='+width+',height='+height+',top='+top+',left='+left+'');
}

function Validate()
{
	this.arrItems = new Array();
	this.message = "";
	
	this.Add = function(idControl,validateType,caption)
	{
		this.arrItems.push(new Array(idControl,validateType,caption));
	}
	
	this.IsValid = function()
	{
		for(var i=0; i < this.arrItems.length; i++)
		{
			var obj = document.getElementById(this.arrItems[i][0]);
			
			if(this.arrItems[i][1] == "float")
			{
				var t = obj.value.replace(/,/g,".");
				
				if (t.length > 0 && t.match(/^-?\d+(\.\d+)?$/) == null)
				{
					this.message = 'Liczba w polu "' + this.arrItems[i][2] + '" została błędnie wpisana.\nPoprawna wartość to np. 100 lub 100.50';
					return false;
				}
			}
		}
				
		return true;
	}
}

function SubmitSearch(idControl,page)
{
	var s = document.getElementById(idControl);	
	if(s.value.length == 0)
	{
		return false;
	}
	else
	{
		SubmitForm(page);
	}
}

function SubmitSearchExt(objValidate,page)
{
	var onsub = true;
	
	if(objValidate!=null)
	{
		if(!objValidate.IsValid())
		{
			onsub = false;
			alert(objValidate.message);			
		}
	}
	if(onsub)
	{
		SubmitForm(page);
	}
}

function Reminder(email,page)
{
	if(document.getElementById(email)==null || document.getElementById(email).value=="") 
	{
		alert("Wypełnij pole 'Login (Twój e-mail)'");
	}
	else
	{	
		SubmitForm(page);
	}
}

function GetPayment(pagedest,optID,demoVersion)
{
	var obj = document.getElementsByName(optID);

	for(var i = 0; i < obj.length; i++)
	{
		if(obj[i].checked)
		{
			if(obj[i].value == 3) //platnosci.pl
			{
				if(demoVersion==1)
				{
					alert("Uwaga!\nTo jest wersja demonstracyjna sklepu.\nZamówienia nie są realizowane.");
					return false;
				}
				else
				{
					return SubmitForm("https://www.platnosci.pl/paygw/ISO/NewPayment");
				}
			}
			else
			{
				return SubmitForm(pagedest);			
			}
		}
	}

	alert('Wybierz formę płatności.');
}

function ChangeUrl(obj, newUrl)
{
	if(obj.href != null)
	{
		obj.href = newUrl;
	}
}

function DeleteProduct(id,page)
{
	document.forms.form.hdnDel.value=id; 
	SubmitForm(page);
}

function SubmitForm(page)
{
	document.forms.form.method = "post";
	document.forms.form.action = page;
	document.forms.form.submit(); 	
}

function ChangeImg(uniqueName)
{	
	try
	{
		var parent = document.getElementById("spanImgBig");	
		var tmp = imgprd.GetImage(uniqueName);
		
		if(tmp != null && tmp != undefined)
		{
			parent.innerHTML = "<img id='"+tmp.id+"' src='"+tmp.src+"' alt='' width='"+tmp.width+"' height='"+tmp.height+"'>"; //width='"+tmp.width+"' height='"+tmp.height+"'
		}
	}catch(e){}
}

function GetImgID(idobj)
{
		var img= document.getElementById(idobj).getElementsByTagName("IMG");
		return img[0].id;

}

function Img()
{
	this.uniqueName = "";
	this.img = null;	
}

function ImagePrd(http_host, img_type)
{
	this.arrImages = new Array();
	this.host = http_host;
	this.imgType = img_type;
			
	this.Add = function(id, uniqueName, fileName2Disc,width,height)
	{
		var im = new Img();
		im.uniqueName = uniqueName;
		var img = new Image();
		img.src = this.GetUrl(fileName2Disc);
		img.alt = "Zdjęcie";
		img.id = id;
		img.width = width;
		img.height = height;
		im.img = img;
		this.arrImages.push(im);
	}
	
	this.GetUrl = function(fileName2Disc)
	{
		return "../images/upload/"+fileName2Disc;
	}
	
	this.GetImage = function(uniqueName)
	{
		for(var i=0; i< this.arrImages.length;i++)
		{
			if((this.arrImages[i]).uniqueName == uniqueName)
			{
				return this.arrImages[i].img;
			}
		}
	}	
}

function SetPrice(src,dest)
{
	var src = document.getElementById(src);
	var dest = document.getElementById(dest);
	dest.innerHTML = src.value+" zł";
}

function CheckPrice(price,dest)
{
	var dest = document.getElementById(dest);
	if(dest.innerHTML == "")
	{
		dest.innerHTML = price +" zł";	
	}
}

function SetLogin(val)
{
	if(val.length == 0)
	{
		var email = document.getElementById("Email");
		val = email.value;
	}

	try
	{
		var login = document.getElementById("PassEmail");
		login.value = val;
	}
	catch(e){};
}

window.document.onkeypress = CheckEnter;

function CheckEnter(e)
{
	if (!e) {var e = window.event;}
		
	if(IsMSIE())
	{
		if(e.srcElement.type == "textarea")
		{
			return true;
		}
	}
	else
	{
		var node = e.target;
		if(node.type == "textarea")
		{
			return true;
		}
	}
	
	if(e.keyCode == 13)
	{
		return false;
	}
	
	return true;
}

function ChangeOrder(obj,url,mode)
{
	if(mode==1)//url friendly
	{
		var arr = Array();
		arr = url.split(",");
		arr[7] = obj[obj.selectedIndex].value;
		url = arr.join(",");
		window.location = url;
	}
	else
	{
		var m = obj[obj.selectedIndex].value;
		url = url.replace(/order=([0-9]+)/,"order="+m);
		window.location = url;
	}
}

function AddToBag(id,prdexist,obj)
{
	if(prdexist == 0)
	{
		alert("Produkt chwilowo niedostępny.");
		try{
			obj.href = "#a"+id;
		}catch(e){}
		return false;
	}
	
	var el = document.getElementsByName("bagAccount"+id);	
	
	for(var i = 0; i < el.length; i++)
	{		
		if(el[i].tagName == "INPUT")
		{
			if(el[i].checked == true)
			{
				SetCookie("bagAccount["+i+"]", el[i].value);
			}			
		}
		else if(el[i].tagName == "SELECT")
		{			
			SetCookie("bagAccount["+i+"]", el[i].value);
		}		
	}
	
}

function GetWindowWidth()
{
    if(window.document.documentElement && ( window.document.documentElement.clientWidth || window.document.documentElement.clientHeight ))
    {
        return window.document.documentElement.clientWidth;
    } 
    else if(window.document.body && ( window.document.body.clientWidth || window.document.body.clientHeight ))
    {
        return window.document.body.clientWidth;
    }
    else
    {
        return 0;
    }
}

function GetWindowHeight()
{
    if( window.document.documentElement && ( window.document.documentElement.clientWidth || window.document.documentElement.clientHeight ))
    {
        return window.document.documentElement.clientHeight;
    } 
    else if( window.document.body && ( window.document.body.clientWidth || window.document.body.clientHeight ))
    {
        return window.document.body.clientHeight;
    }
    else
    {
        return 0;
    }
}

function IsMSIE()
{
	var userAgent = window.navigator.userAgent;
	//var appName=window.navigator.appName;
	if(userAgent.indexOf("MSIE")>=1)
	{
		return true;
	}
	else
	{
		return false;
	}	
}

function GoTo(idprd)
{
	location.href = "#a"+idprd;
}

function GetScrollXY() 
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function SetScrollXY(scrOfX,scrOfY) 
{
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    window.pageYOffset = scrOfY;
    window.pageXOffset = scrOfX;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    document.body.scrollTop = scrOfY;
    document.body.scrollLeft = scrOfX;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    document.documentElement.scrollTop = scrOfY;
    document.documentElement.scrollLeft = scrOfX;
  }
}
//document.oncontextmenu = function(){return false;}
-->
