function Buttons(){
	inputs = document.getElementsByTagName('input');
	for(i = 0; i < inputs.length; i++){
		if(inputs[i].type != 'image')
		inputs[i].className='input';
		if(inputs[i].type == 'submit')
		inputs[i].className='button';
	}
}

function SendFoot(){
heigh=document.getElementById('content').offsetHeight;
heigh2=document.getElementById('contRight').offsetHeight;

if (heigh<heigh2){
document.getElementById('contLeft').style.height=(heigh2-147)+"px";
}



}

function Init(){
	Buttons();
	SendFoot();
	var baskHeight=90;

	var p=document.getElementById('prodChange');
	if (p) p.remove(0);
	var p1=document.getElementById('prodChange1');
	if (p1) {
		p1.remove(0);
		baskHeight+=24;
	}
	var p2=document.getElementById('prodChange2');
	if (p2) {
		p2.remove(0);
		baskHeight+=24;

	}
	var p3=document.getElementById('prodChange3');
	if (p3) {
		p3.remove(0);
		baskHeight+=24;

	}
	var q=document.getElementById('advBask');
	if (q) q.style.visibility="visible";
	var r=document.getElementById('advWish');
	if (r) r.style.visibility="visible";
	
	var bask=document.getElementById('attrib');
	var baskCont=document.getElementById('prodBasketCont');
	var advBask=document.getElementById('advBask');
 	var advWish=document.getElementById('advWish');
 	var infoLinks=document.getElementById('infoOtherLinks');
	var infoAvail=document.getElementById('infoAvail');
	if (baskHeight!=90&&bask&&baskCont&&advBask&&advWish&&infoAvail){
		bask.style.height=baskHeight+"px";
/*		baskCont.style.height=(baskHeight+24-90)+"px";*/
		advBask.style.top=(baskHeight+24-90)+"px";
		advWish.style.top=(baskHeight-10)+"px";
		//alert(advWish.style.top);
/*		if (window.XMLHttpRequest&&window.ActiveXObject){
		alert(	advWish.style.marginTop);
			advWish.style.marginTop="60px";
		alert(	advWish.style.marginTop);
		alert(	advWish.style.top);
			advWish.style.top="";
		alert(	advWish.style.top);
		}		*/
		infoAvail.style.marginTop=(baskHeight-24-90)+"px";
/*		infoLinks.style.top=(baskHeight+24-90)+"px";*/
		infoLinks.style.top=(baskHeight-24-90)+"px";
	 //	alert(infoLinks.marginTop);
	  	}
	
	/**
	* wyłączamy autocomplete zeby nie kolidowac z hintami ajaxowymi
	* _i_ zachowac zgodnosc z xhtml
	*/
	var s = document.getElementById('search_query_words');
	s.setAttribute("autocomplete", "off");
	 
}

function imageScale(sender, max_size) {
	p=0;
	if (sender.width > max_size) {
		p = (max_size / sender.width);
	}
	else {
		if (sender.height > max_size) {
			p = (max_size / sender.height);
		}
	}
	if(p > 0) {
		sender.width = p * sender.width;
	}
}


function searchOver (what) {
	document.getElementById(what).className = 'HintHighlight';
	showHints();
}
function searchOut (what) {
	document.getElementById(what).className = 'HintUnHighlight';
}
function searchDown (str) {
	document.getElementById('search_query_words').value = str;
}
var timeout=1000;
var oldQuery='';
function hintMe() {
	query=document.getElementById('search_query_words').value;
	/*hint.className='searchDivHidden';*/
	document.getElementById('searchHint').style.visibility='visible';
	if (query != oldQuery) {
		oldQuery=query;
		if (query && query.length>3) {
			window.setTimeout('xajax_searchHints(query);',timeout);
		} else {
			hideHints();
		}
	}
}
function showHints() {
	query=document.getElementById('search_query_words').value;
	if (query && query.length>3) {
		hint=document.getElementById('searchHint');
		if (hint.style.visibility!='visible') hint.style.visibility='visible';
	}
}
function hideHints() {
	hint=document.getElementById('searchHint');
	hint.style.visibility='hidden';
}
function auto_off() {

	alert(s.toString);
}

function hide_list(list)
{
	list.style.display='none';
}

function show_list(list)
{
	list.style.display='block';
}

function visible(list)
{
	if ((list.style.display=='block') || list.style.display=='')
	return true;

	return false;
}

function _$(id)
{
	return document.getElementById(id);
}

function ShowBox(id, ms, timer) {
	var timer=(timer==null) ? 0 : timer;
	var objref=document.getElementById(id);

	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape 
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	//  wysrodkowanie w pionie 
	var topBoxOffset=scrOfY+(screen.availHeight/3)-(objref.offsetHeight/2);
	//	wysrodkowanie w poziomie
	var leftBoxOffset=scrOfX+(screen.availWidth/2)-(objref.offsetWidth/2);

	objref.style.top=topBoxOffset+"px";
	objref.style.left=leftBoxOffset+"px";
	if (timer < ms) {
		objref.style.display="block";
		timer+=10;
		setTimeout("ShowBox('"+id+"',"+ms+","+timer+")",1);
	} else {

		objref.style.display="none";

	}
}

function changePrice(value1){
	var pMin=document.getElementById('priceMin');
	var pMax=document.getElementById('priceMax');
	var val1,val2;
	if (pMax&&pMin){
		trick=value1.indexOf('-');
		if (trick!=-1 ){
			pMin.value=value1.substring(0,trick);
			pMax.value=value1.substring(trick+1);
			if (pMax.value=="9999") pMax.value="";
		}
		else{
			pMin.value="";
			pMax.value="";
		
		}
 }
}
function tab(nr){

	for (i=0;i<mx;i++){
		var d=document.getElementById(tab_id[i]);
		if (d) d.style.display="none";
	}
	var d1=document.getElementById('infoTabs');
	if (d1) d1s=d1.getElementsByTagName('span');
	for (q=0;q<d1s.length;q++)
	d1s[q].className='';

	d1s[nr-1].className='tabSel';

	var d=document.getElementById(tab_id[nr-1]);
	if (d) d.style.display="block";
}
function validateEmail(elementValue){
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return emailPattern.test(elementValue); } 

function testForm(name1){
	var frm=document.getElementById(name1);
	if (frm){
		if (frm.elements['item1[description]'].value==''){
			alert("Wypełnij treść recenzji");
			return false;
		}
		else if (frm.elements['item1[author]'].value==''){
			alert("Pole 'Autor' jest puste");
			return false;
		}
	  /*	else if (frm.elements['item1[mail]'].value==''){
			alert("Pole 'e-mail' jest puste");
			return false;
		}
		else if (!validateEmail(frm.elements['item1[mail]'].value)){
			alert("Adres e-mail jest niewłaściwy!");
			return false;			
		}*/
		else {
			window.open("","window","width=500,height=300");
			frm.elements['sbl1'].value=frm.elements['item1[description]'].value;
			frm.elements['sbl2'].value=frm.elements['item1[author]'].value;
		  /*	frm.elements['sbl3'].value=frm.elements['item1[mail]'].value;*/
			return true;
			}
	}
	else return false;
}

function closeCat(cat){
	closeThis=document.getElementById(cat);
	closeLink=document.getElementById("catOpenLink"+cat);
	if (closeThis&&closeLink){
		closeThis.style.display="none";
		closeLink.href=closeLink.rel;
	}
}

function zagielCheckOrderValue(value, message) {
    if (value < 100) {
        window.alert(message);
        return false;
    } else {
        return true;
    }
}

function zagielProductCalcLink(shopNo, value, message) {

    if (zagielCheckOrderValue(value, message)) {
        window.open('https://www.zagiel.com.pl/kalkulator/index_smart.php?action=getklientdet_si_rata&shopNo='+shopNo+'&goodsValue='+value,'Policz_rate','width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
    }
}