DOLAR= function(id) {
	if(!id) return null;
		
	var e = (typeof id == "string") ? document.getElementById(id) : id;
	
	if(!e) return null;
	
	return e;
}
function refreshCaptcha(){
  $("imgCaptcha").src="captcha.php5?sid="+new Date().getTime();
  DOLAR("captcha").value="";
}
function myTrim(tresc){
  return tresc.replace(new RegExp("[<br /> \n\r\t]+", "g"), "");
}
function myEmail(tresc){
  var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
  if(tresc.search(emailRegEx) == -1){
    return false;
  }else{
    return true;
  }
}
function dodatki(){
  var tabButt = document.getElementsByTagName("button");
  for(i=0;i<tabButt.length;i++){
    if(tabButt[i].className==""){
      tabButt[i].className="butMenu";
      tabButt[i].onmouseover = function(){this.className="butMenuHover"};
      tabButt[i].onmouseout = function(){this.className="butMenu"};
    }
  }
}
function rozmiarDiv(iObj){
    var obj={};
    obj.width=DOLAR(iObj).offsetWidth;
    obj.height=DOLAR(iObj).offsetHeight;
    return obj;
}
function confirmation() {
	var answer = confirm("Czy jesteś pewien?");
	if (answer){
		return true;
	}
	else{
		return false;
	}
}
function ocen(ocena,id){
  var req = mint.Request();
  req.method="POST";
  req.AddParam("id",id);
  req.AddParam("ocena",ocena);
  req.OnSuccess = function() {
     DOLAR("tuSaButoony").style.display="none";
  }
  req.Send("ocena.php5","tuTrafiSrednia");
  //req.Send("ocena.php5");
}
function ustawMojSite(){
   if(DOLAR('czemuNie')){
     var tmpSize = rozmiarDiv(DOLAR("divMain"));
     var tmpSizeLeft = rozmiarDiv(DOLAR("divLeft"));
     //alert(tmpSizeLeft.height+" | "+tmpSize.height);
     if(tmpSizeLeft.height>tmpSize.height){
        DOLAR("divMain").style.height=tmpSizeLeft.height+"px";
        //alert("dostosuj main");
     }else{
        DOLAR("divLeft").style.height=tmpSize.height+"px";
        DOLAR("divRight").style.height=tmpSize.height+"px";
        //alert("dostosuj left & right");
     }
     //alert(tmpSize.height);
   }
}
$(document).ready(function() {
  //$('.myCssClass')   pobiera elementy o danej klasie css
  var myHrR = $(".linkMenuMain");
  for(var i=0;i<myHrR.length;i++){
    //alert(DOLAR(myHrR[i]).innerHTML);
    $(DOLAR(myHrR[i])).corner();//uncorner
    DOLAR(myHrR[i]).onmouseover = function(){
      $(DOLAR(this)).uncorner();
      DOLAR(this).className="linkMenuMainHover";
      $(DOLAR(this)).corner();
    }
    DOLAR(myHrR[i]).onmouseout = function(){
      $(DOLAR(this)).uncorner();
      DOLAR(this).className="linkMenuMain";
      $(DOLAR(this)).corner();
    }
  }
  if(DOLAR("TuMojaGra")){
      var so = new SWFObject(DOLAR("TuMojaGra").getAttribute("rel"), "game", DOLAR("TuMojaGra").style.width, DOLAR("TuMojaGra").style.height, "9", "#062224");
      so.addParam('salign', 'tl');
      so.addParam('align', 'middle');
      so.write("TuMojaGra");
   }
});
function kontakt(){
  if(!myEmail(DOLAR("email").value)){
    alert("podaj prawidłowy format email");
    return false;
  }
  if(myTrim(DOLAR("tresc").value)==""){
    alert("wypelnij treść");
    return false;
  }
  if(myTrim(DOLAR("captcha").value)==""){
    alert("przepisz 6 znaków z obrazka");
    return false;
  }
  var req = mint.Request();
  req.OnSuccess = function() {
    if(this.responseText==DOLAR("captcha").value){
      addKontakt();
      refreshCaptcha();
    }
  }
  req.Send("sesja.php5");
}
function addKontakt(){
  var req = mint.Request();
  req.method='POST';
  req.AddParam('email',DOLAR("email").value);
  req.AddParam('tresc',DOLAR("tresc").value);
  req.OnSuccess = function() {
    DOLAR("email").value="";
    DOLAR("tresc").value="";
   refreshCaptcha();
    alert(this.responseText);
  }
  req.Send("kontakt.php5");
}
