var d=document;
function goTo (l) {
	location.href=l;
}
function changeBg (el) {
	el.style.backgroundColor = '#ffecec';
}
function changeBgTr (el) {
	el.style.backgroundColor = 'white';
}
function addbookmark(bookmarkurl, bookmarktitle, title, path) {
	if (document.all) {
		
		document.write('<a href="javascript:window.external.AddFavorite(\''+bookmarkurl+'\',\''+bookmarktitle+'\');');
		document.write('">'+ title +'');
		document.write('<br>');
		document.write('<img src="'+ path +'/i/ico/bookmark.png" width="24" height="18" alt="" border="0"></a>');
	
	}
		
}
function startWithUs(s_url, s_mouseo, s_text, path) {

	if (document.all) {
			document.write('<a href="javascript:void(0);" ');
			document.write('onclick="this.style.behavior=');
			document.write("'url(#default#homepage)'");
			document.write("; this.setHomePage('"+s_url+"');");
			document.write('">'+ s_text +''); 
			document.write('<br>');
			document.write('<img src="'+ path +'/i/ico/start.png" width="19" height="16" alt="" border="0"></a>');

		}
		
}

function okienkoImg(urlImg, title, width, height) {   
	var width = parseInt(width);
	var height = parseInt(height);
	var width = (isNaN(width) ? 420 : width+20);
	var height = (isNaN(height) ? 420 : height+20);
 
	var Win = window.open('',"",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no, menubar=no, left=350, top=100' );
	Win.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+title+'</title></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');
	
	Win.document.write('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align=center><table style="padding:4px;border:silver 1px solid"><tr><td><a href="javascript:self.close();"><img src="'+urlImg+'" alt="" border="0"></a></td></tr></table></td></tr></table>');
	Win.document.write('</body></html>');
	
};

function addComment (par, user, ident, identId) {
	if(!user) {
		referer = '';
		if(ident == 'OFFER')
			referer="?referer=offer.php%3FidCnt%3D"+identId;
		if(ident == 'GUESTBOOK')
			referer="?referer=guestbook.php";

		location.href="login.php" + referer;
	} else {
		//window.open(
		location.href='forumPopUp.php'+par;//,'forum','align=center,toolbar=0,status=1,location=0,directories=0,resizable=yes,scrollbars=yes,width=420,height=320,menubar=no';
		
	}
}


function printWindow(url){ 
	 w = window.open(url,'printWin','align=center,toolbar=0,status=1,location=0,directories=0,resizable=yes,scrollbars=yes,width=700,height=500,menubar=yes')
	 w.focus();
} 

function okienko_img(urlImg, title, width, height) {    
	var Win = window.open('',"displayWindow",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=no, menubar=no, left=350, top=100' );
	Win.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+title+'</title></head><body onload="window.resizeTo(document.getElementById(\'image\').width+30,document.getElementById(\'image\').height+80)">');
	
	Win.document.write('<a href="javascript:self.close();"><img id="image" src="'+urlImg+'" alt="" border="0"></a>');
	Win.document.write('</body></html>');
	Win.document.close();
};
function infowindow(infourl, title, w, h){
	var Win = window.open(infourl,title,'width=' + w + ',height=' + h + ',resizable=no,scrollbars=no, menubar=no, left=350, top=100');
}
function popupwindow(infourl, title, w, h){
		var popup = window.open(infourl,title,'width='+w+' ,height='+h+',left=' + (screen.width-w)/2 + ',top=' + (screen.height-h)/2 + '');
	return false;
}


function checkFloat (field) {
	field.value = field.value.replace(",",".");
	if(isNaN(field.value)) {
		alert('Wrong digit: ' + field.value)
		field.value = '';
	}
}

function checkSendTo (f, calert, emailalert) {
	if(
		f.RecipientName.value != ''
		&& f.FirstName.value != ''
		&& f.LastName.value != ''
		&& checkEmailAddress(f.RecipientEmail)
		&& checkEmailAddress(f.Mail)
	) {
		f.submit();
	} else {
		if(!checkEmailAddress(f.RecipientEmail) || !checkEmailAddress(f.Mail)) {
			alert(emailalert);
		} else {
			alert(calert);
		}
	}
}


function checkQuestion (f, calert, emailalert) {
	if(
		f.FirstName.value != ''
		&& f.LastName.value != ''
		&& f.Question.value != ''
		&& checkEmailAddress(f.Mail)
	) {
		f.submit();
	} else {
		if(!checkEmailAddress(f.Mail)) {
			alert(emailalert);
		} else {
			alert(calert);
		}
	}
}d

function checkBrochure(f, calert, emailalert) {
	if(
		f.txtLast.value != ''
		&& f.txtFirst.value != ''
		&& f.txtCompany.value != ''
		&& checkEmailAddress(f.txtEmail)
	) {
		f.submit();
	} else {
		if(!checkEmailAddress(f.txtEmail)) {
			alert(emailalert);
		} else {
			alert(calert);
		}
	}
}

function checkNewslleter_old(f, calert, emailalert) {
	if(
		f.adtFirst.value != ''
		&& f.adtLast.value != ''
		&& f.adtCompany.value != ''
		&& checkEmailAddress(f.email)
	) {
		f.submit();
	} else {
		if(!checkEmailAddress(f.email)) {
			alert(emailalert);
		} else {
			alert(calert);
		}
	}
}

function checkNewslleter(f, calert, emailalert) {
	if(
		f.adtFirst.value != ''
		&& f.adtLast.value != ''
		&& checkEmailAddress(f.email)
	) {
		f.submit();
	} else {
		if(!checkEmailAddress(f.email)) {
			alert(emailalert);
		} else {
			alert(calert);
		}
	}
}

function checkJoinUsForm(f, calert, emailalert) {
	if(
		f.nazwa.value != ''
		&& f.imie.value != ''
		&& f.addr.value != ''
		&& f.kodm.value != ''
		&& checkEmailAddress(f.email)
	) {
		f.submit();
	} else {
		if(!checkEmailAddress(f.email)) {
			alert(emailalert);
		} else {
			alert(calert);
		}
	}
}

function checkEmailAddress(field) {
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	
	if (goodEmail){
	  return true
	} else {
    field.focus()
    field.select()
    return false
  }
}
function OverButton(obj,img){
	obj.childNodes[0].src='data/l/'+img;
}
function OutButton(obj,img){
	obj.childNodes[0].src='data/l/'+img;
}
function ClickButton(objimg){
	obj.childNodes[0].src='data/l/'+img;
}





function hideElement(id) {
	var o = document.getElementById(id);
	if(o.style) {
		o.style.display = 'none';
	}
}
function showElement(id) {
	var o = document.getElementById(id);
	if(o.style) {
		o.style.display = '';
	}
}









function selectCountry (idC) {
	var f = document.searchForm;
	if(f) {
		var box = f.ctgRootId;
		for(i=0;i<box.options.length;i++) {
			if(box.options[i].value == idC) {
				box.selectedIndex = i;
			}
		}
	} else {
		location.href='index.php?ctgRootId='+idC + '&ustaw_mape='+idC;
	}
}


function javascript_to_flash(id, xx, yy) {
	var id = (id == null) ? document.searchForm.ctgRootId.value : id;
	var xx = (xx == null) ? false : xx;
    var yy = (yy == null) ? false : yy;
//if(navigator.appName.toLowerCase() == "microsoft internet explorer") alert("Microsoft Internet Explorer");
	//var id = document.searchForm.ctgRootId.value;
	//alert(thisMovie("logo"));
	if(xx & yy){
		thisMovie("logo").asFunc(id,xx,yy);
	} else {
		thisMovie("logo").asFunc(id);
	}
	//
	flash=document.logo;
	flash.SetVariable("region_id", id);
	//alert(id);
}

// ajax basket
	var ObiektXMLHttp = false;
	if (window.XMLHttpRequest) {
		ObiektXMLHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		ObiektXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	function getMsg(src, content)
		{
		if(ObiektXMLHttp) {
		ObiektXMLHttp.open("GET", src);
		ObiektXMLHttp.onreadystatechange = function()
		{
		if (ObiektXMLHttp.readyState == 4) {

		document.getElementById(content).innerHTML = ObiektXMLHttp.responseText;
		document.getElementById('total2').innerHTML = ObiektXMLHttp.responseText;
		document.getElementById('total1').innerHTML = ObiektXMLHttp.responseText;
		}
		}
		ObiektXMLHttp.send(null);
		}
		}



function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	//alert(isIE);
	return (isIE) ? window[movieName] : document[movieName];
}

function trim(str) { 
    if (str != null) {
        var i; 
        for (i=0; i<str.length; i++) {
            if (str.charAt(i)!=" ") {
                str=str.substring(i,str.length); 
                break;
            } 
        } 
    
        for (i=str.length-1; i>=0; i--) {
            if (str.charAt(i)!=" ") {
                str=str.substring(0,i+1); 
                break;
            } 
        } 
        
        if (str.charAt(0)==" ") {
            return ""; 
        } else {
            return str; 
        }
    }
}
