﻿var selected_menu=1;

var current_id=1;
var what_s = new Array();
what_s[1]="dl";
what_s[2]="dl";
what_s[3]="tut";


var cur_action="";

function del_select(id){
     if (id==0){return;}
             document.getElementById('tr_'+id+'_').style.backgroundImage="url(images/pixel.gif)";
             document.getElementById('tr_d_'+id+'_').style.backgroundImage="url(images/pixel.gif)";
             document.getElementById('tr_'+id+'_').style.backgroundImage="url(images/pixel.gif)";
             document.getElementById('b_l_'+id+'_').src='images/pixel.gif';
             document.getElementById('b_d_l_'+id+'_').src='images/pixel.gif';
             document.getElementById('b_d_r_'+id+'_').src='images/pixel.gif';
             document.getElementById('b_r_'+id+'_').src='images/pixel.gif';
             document.getElementById('b_d_'+id+'_').src='images/pixel.gif';
     return;
}
function set_select(id){
  //   if (document.findform.query){
   //          document.findform.query.focus();
  //   }
     if (current_id==id){return;}


     if (id==0){return;}

     if (id==2 || id==3){window.location = 'http://localhost/dlelb';}


             del_select(current_id);
             document.getElementById('tr_d_'+id+'_').style.backgroundImage="url(images/b_d_bg.gif)";
             document.getElementById('tr_'+id+'_').style.backgroundImage="url(images/b_bg.gif)";
             document.getElementById('b_l_'+id+'_').src='images/b_l.gif';
             document.getElementById('b_r_'+id+'_').src='images/b_r.gif';
             document.getElementById('b_d_'+id+'_').src='images/b_d.gif';
             document.getElementById('b_d_l_'+id+'_').src='images/b_d_l.gif';
             document.getElementById('b_d_r_'+id+'_').src='images/b_d_r.gif';
             current_id=id;
             document.findform.type.value=what_s[id];
     return;
}
function submit_form(){
     if (document.findform.query.value!=''){
           //  document.location.href=document.findform.action.value+document.findform.findtext.value;
     }
}

set_select(selected_menu);


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}



////
function initfadeIn(id, speed)
{
        var image = document.getElementById(id);
        setOpacity(image, 0);
        //image.style.visibility = "visible";
        fadeIn(id, 0, speed);
}

function initfadeOut(id, speed)
{
        var image = document.getElementById(id);
        setOpacity(image, 100);
        fadeOut(id, 100, speed);
}

function setOpacity(obj, opacity)
{
        obj.style.filter = "alpha(opacity:"+opacity+")";
        obj.style.KHTMLOpacity = opacity/100;
        obj.style.MozOpacity = opacity/100;
        obj.style.opacity = opacity/100;
}

function fadeIn(objId, opacity, speed)
{
        if (document.getElementById)
        {
                obj = document.getElementById(objId);
                if (opacity <= 100)
                {
                        setOpacity(obj, opacity);
                        opacity += 20;
                        window.setTimeout("fadeIn(\""+objId+"\", "+opacity+", "+speed+")", speed);
                }
        }
}

function fadeOut(objId, opacity, speed)
{
        if (document.getElementById)
        {
                obj = document.getElementById(objId);
                if (opacity >= 0)
                {
                        setOpacity(obj, opacity);
                        opacity -= 20;
                        window.setTimeout("fadeOut(\""+objId+"\", "+opacity+", "+speed+")", speed);
                }
        }
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function show_hide(id,other)
{
       var myelid = document.getElementById(id);
       var otherid = document.getElementById(other);

       active_menu = id;
       unactive_menu = other;

       if ( myelid.style.display == 'block' )
       {
       initfadeOut(id, 10);
       myelid.style.display = 'none';
       initfadeIn(other, 10);
       otherid.style.display = 'block';
       }
       else
       {

       initfadeOut(other, 10);
       myelid.style.display = 'block';
       initfadeIn(id, 10);
       otherid.style.display = 'none';

       }

}


function imagepreview(id)
{
         window.open(my_base + 'image.php?action=imagepreview&id='+id, '', 'resizable=1,HEIGHT=50,WIDTH=50, scrollbars=yes');
}

if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;


var tooltip = null
var tooltipHide = null;

// przesunięcie tooltipa
var LEFT_OFFSET = 57;
var TOP_OFFSET = 13;

/**
 * lazy pobranie boxa z tooltipem
 */
function getTooltip()
{
        if (tooltip==null) {
                tooltip = $('tooltipdiv');
                addListener(tooltip, 'mousemove', function(){
                                clearTimeout(tooltipHide);
                        }
                );
                addListener(tooltip, 'mouseout', function(obj){
                                tooltipHide = setTimeout("hideToolTip()",500);
                });
        }
        return tooltip;
}

/**
 * Ukrywa tooltipa
 */
function hideToolTip()
{
        setClass(getTooltip(), 'hidden', true);
}

var tmp;
/**
 * Wyświetla tooltipa
 * @param {Object} element obrazke nad którym ma być wyświetlony tooltip.
 */
function showToolTip(obj)
{
        var left = 0;
        var top = 0;
        var myobj = false;
        if(obj.originalTarget){
                myobj = obj.originalTarget;
        }
        else if(obj.srcElement) {
                myobj = obj.srcElement;
        }
        left = getAbsoluteLeft(myobj);
        top = getAbsoluteTop(myobj);

        tooltip = getTooltip();

        elements = tooltip.getElementsByTagName('a');
        for(i=0;i<elements.length;i++){
                if(elements[i].className=='username'){
                        my_a = elements[i];
                        my_a.href=myobj.attributes.getNamedItem('games:href').value;
                        my_a.innerHTML=myobj.attributes.getNamedItem('games:name').value;
                }
        }

        $('imgid').src = myobj.attributes.getNamedItem('games:pic').value;
        $('rateimg').src  = 'rate/'+myobj.attributes.getNamedItem('games:rate').value+'.gif';
        elements = tooltip.getElementsByTagName('div');
        for (i = 0; i < elements.length; i++) {
                if(elements[i].className=='city'){
                     //   my_div = elements[i];
                     //   while(my_div.childNodes.length) my_div.removeChild(my_div.childNodes[0]);
                     //   my_div.appendChild(document.createTextNode(myobj.attributes.getNamedItem('games:miasto').value));
                }else if(elements[i].className=='rate'){
                        //my_div = elements[i];
                        //while(my_div.childNodes.length) my_div.removeChild(my_div.childNodes[0]);
                       // my_div.appendChild(document.createTextNode(myobj.attributes.getNamedItem('games:rate').value));
                }else if(elements[i].className=='state'){
                    //    my_div = elements[i];
                    //    while(my_div.childNodes.length) my_div.removeChild(my_div.childNodes[0]);
                    //    my_div.appendChild(document.createTextNode(myobj.attributes.getNamedItem('games:wojewodztwo').value));
                }
        }


        setStyle(getTooltip(), 'left', left+LEFT_OFFSET, 'px');
        setStyle(getTooltip(), 'top', top+TOP_OFFSET, 'px');
        unsetClass(getTooltip(),'hidden');
}

/**
 * Inicjacja tooltipów obrazkowych
 *
 * obrazki, które mają tooltipa powinny mieć klase tip_image.
 */
function init_img_tip()
{

        elements = document.getElementsByTagName('img');
        count = elements.length;
        for (i = 0; i < count; i++)
                if (obtainClass(elements[i], 'tip_image')) {
                        addListener(elements[i], 'mouseout', function(obj){
                                tooltipHide = setTimeout("hideToolTip()",500);
                        });
                        addListener(elements[i], 'mouseover', function(obj){
                                showToolTip(obj);
                                clearTimeout(tooltipHide);
                        });
                }
}

        function $(id)
        {
                return document.getElementById(id);
        }

        /**
         * Dodaje funkcję f do wykonywania w windows.onload
         * @param {Object} f funkcja dodawana do wykonania po załadowaniu
         */
        function addOnLoad(f){
                try {
                        var old_f = windows.onload
                        window.onload = function(){
                                old_f();
                                f();
                        }
                } catch( e){
                        window.onload = f
                }
        }

        function getRealHeight(obj)
        {
                paddingTop = getStyle(obj,'paddingTop','int');
                paddingBottom = getStyle(obj,'paddingBottom','int');

                if(navigator.userAgent.indexOf('MSIE') != -1){
                        realHeight = obj.offsetHeight;

                        //specjalnie dla IE trzeba odjac jeszcze szerokosc borderow..
                        realHeight -= getStyle(obj,'borderTopWidth','int');
                        realHeight -= getStyle(obj,'borderBottomWidth','int');
                }
                else if(navigator.userAgent.indexOf('Firefox') != -1) {
                        realHeight = obj.offsetHeight;
                }
                else
                        realHeight = obj.clientHeight;

                return (realHeight-paddingTop-paddingBottom);
        }


        function getRealWidth(obj)
        {
                paddingLeft = getStyle(obj,'paddingLeft','int');
                paddingRight = getStyle(obj,'paddingRight','int');

                if(navigator.userAgent.indexOf('MSIE') != -1){
                        realWidth = obj.offsetWidth;

                        //specjalnie dla IE trzeba odjac jeszcze szerokosc borderow..
                        realWidth -= getStyle(obj,'borderLeftWidth','int');
                        realWidth -= getStyle(obj,'borderRightWidth','int');
                }
                else
                        realWidth = obj.clientWidth;

                return (realWidth-paddingLeft-paddingRight);
        }

        function getStyle(obj,s,type)
        {
                if(!not(obj.style[s]))
                        r = obj.style[s];
                else
                        r = false;

                if(!not(type)){
                        if(type = 'int'){
                                r = parseInt(r);
                                if(isNaN(r)) {
                                        r = 0
                                };

                                return r;
                        }
                }
                return r;
        }

        function not(v)
        {
                if(typeof v == 'undefined'){
                        return true;
                }

                if(typeof v == 'null'){
                        return true;
                }

                if(typeof v == null){
                        return true;
                }

                return false;
        }

        function setStyle(obj,s,v,fix,debug)
        {
                if(not(debug)){
                        var debug = false;
                }

                if(!not(fix)){
                        v += fix;
                }

                if(navigator.userAgent.indexOf('MSIE') != -1){
                        switch(s){
                                case 'opacity' :
                                        v = 'alpha(opacity='+(v * 100)+')';
                                        s = 'filter';
                                        break;

                                case 'cssFloat' :
                                        s = 'styleFloat';
                                        break;

                                case 'minHeight' :
                                        //s = 'height';
                                        break;
                        }
                }

                if(debug){
                        alert(obj+" / "+s+" = "+v);
                }

                obj.style[s] = v;
                return obj.style[s];
        }

        function setClass(obj,tempClassName,add)
        {
                if(not(tempClassName)){
                        return false;
                }

                //trim
                tempClassName = trim(tempClassName);

                if(not(obj.className)){
                        return false;
                }

                if(not(add)){
                        var add = false;
                }

                if(not(obj)){
                        return false;
                }

                if(obtainClass(obj,tempClassName))
                        return obj.className;

                if(add){
                        obj.className += ' '+tempClassName;
                }
                else {
                        obj.className = tempClassName;
                }

                return obj.className;
        }

        function unsetClass(obj,tempClassName)
        {
                if(not(tempClassName)){
                        return false;
                }

                //trim
                tempClassName = trim(tempClassName);

                if(not(obj.className)){
                        return false;
                }
                eval('var regs = /(^|\\s)'+tempClassName+'($|\\s)/i');
                obj.className = obj.className.replace(regs,'$1$2');
                obj.className = obj.className.replace(/\s\s/,' ')
        }

        function obtainClass(obj,tempClassName)
        {
                if(not(obj)){
                        return false;
                }

                if(not(tempClassName)){
                        var temp = new Array();
                        temp = obj.className.split(' ');
                        return temp;
                }
                else {
                        eval('var regs = /(^|\\s)'+tempClassName+'($|\\s)/i');
                        return regs.test(obj.className);
                }
        }

        function getAbsoluteTop (obiekt,zeroClass)
        {
                // zerujemy zmienne
                var pos = 0;
                var oParent = obiekt;
                var rel = '';

                // nie ma
                if (!oParent)
                        return pos;
                // petla
                do
                {
                        // ustawiamy pozycje
                        pos += oParent.offsetTop;
                        // pobieramy parentka
                        oParent = oParent.offsetParent;

                        if(!not(zeroClass) && obtainClass(oParent,zeroClass)){
                                return pos;
                        }
                }
                while (oParent.tagName.toLowerCase() != 'body' && oParent.tagName.toLowerCase() != 'html');

                pos += oParent.offsetTop;

                // zwracamy pos
                return pos;
        }

        function getAbsoluteLeft (obiekt,zeroClass)
        {
                // zerujemy zmienne
                var pos = 0;
                var oParent = obiekt;

                // nie ma
                if (!oParent)
                        return pos;
                // petla
                do
                {
                        // ustawiamy pozycje
                        pos += oParent.offsetLeft;
                        // pobieramy parentka
                        oParent = oParent.offsetParent;

                        if(!not(zeroClass) && obtainClass(oParent,zeroClass)){
                                return pos;
                        }
                }
                while (oParent.tagName.toLowerCase() != 'body' && oParent.tagName.toLowerCase() != 'html');

                pos += oParent.offsetLeft;
                // zwracamy pos
                return pos;
        }

        function objectDebug(obj,field)
        {
                for(var i in obj){
                        if(not(field)){
                                if(!confirm(i+": "+obj[i])){
                                        return false;
                                }
                        }
                        else {
                                if(!confirm(i+": "+obj[i][field])){
                                        return false;
                                }
                        }
                }
        }

        function addListener(element, event, listener, bubble)
        {
                if(element.addEventListener) {
                        if(not(bubble)) {
                                var bubble = false;
                        }
                        element.addEventListener(event, listener, bubble);
                }
                else if(this.attachEvent) {
                        element.attachEvent("on" + event, listener);
                }
        }

        function removeListener(element, event)
        {
                eval('element.on'+event+' = null;');
                if(element.removeEventListener) {
                        element.removeEventListener(event,function() {},false);
                }
                else if(element.detachEvent) {
                        element.detachEvent("on"+event);
                }
        }

        function getCssRule(obj, rule)
        {
                alert('css1');
                var nodeName = obj.nodeName;
                var classes = obtainClass(obj);
                var ret = '';
                if(typeof classes == 'string'){
                        var temp = new Array();
                        temp[0] = classes;
                        classes = temp;
                }
                alert('css2');
                if (document.styleSheets[0].cssRules){
                        alert('css2.1');
                        for(var i = 0; i < document.styleSheets.length; i++){
                                theRules = document.styleSheets[i].cssRules;
                        }
                }
                else if (document.styleSheets[0].rules){
                        alert('css2.2');
                        for(var i = 0; i < document.styleSheets.length; i++){
                                theRules = document.styleSheets[i].rules;
                        }
                }
                alert('css3');
                for(var i = 0; i < theRules.length; i++){
                        eval('var regs = /'+nodeName+'($|,)/');
                        if(regs.test(theRules[i].selectorText)){
                                if(theRules[i].style[rule]){
                                        ret = theRules[i].style[rule];
                                }
                        }

                        for(var j =0; j<classes.length; j++){
                                eval('var regs = /\.'+classes[j]+'($|,)/');
                                if(regs.test(theRules[i].selectorText)){
                                        if(theRules[i].style[rule]){
                                                ret = theRules[i].style[rule];
                                                alert(theRules[i].selectorText+" => "+theRules[i].style[rule]);
                                        }
                                }
                        }
                }

                return ret;
        }

        function cancelBubble(e)
        {
                if(!e){
                        window.event.cancelBubble = true;
                }
                else {
                        e.stopPropagation();
                }
        }

        function getParentElement(obj,element,className)
        {
                var temp = obj;

                if(not(className)){
                        var className = '';
                }

                while(temp = temp.parentNode){
                        if(temp.nodeName.toUpperCase() == element.toUpperCase()){
                                if(!className){
                                        return temp;
                                }

                                if(temp.className.toUpperCase() == className.toUpperCase()){
                                        return temp;
                                }
                        }
                }
                return false;
        }

        /**
         * usuwa wszystkich podomków
         *
         * @param {Object} obj node dla którego należy usunąć potomków
         */
        function removeChildren(obj){
                while(obj.childNodes.length) obj.removeChild(obj.childNodes[0]);
        }

        // skopiowane beszczelnie z django-admin
        // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
        function quickElement() {
    var obj = document.createElement(arguments[0]);
    if (arguments[2] != '' && arguments[2] != null) {
        var textNode = document.createTextNode(arguments[2]);
        obj.appendChild(textNode);
    }
    var len = arguments.length;
    for (var i = 3; i < len; i += 2) {
                if(arguments[i]=='class'){
                        obj.className = arguments[i+1];
                }else
        obj.setAttribute(arguments[i], arguments[i+1]);
                //obj[arguments[i]] =  arguments[i+1];
    }
    arguments[1].appendChild(obj);
    return obj;
}

function trim(str)
{
        return str.replace(/^\s+|\s+$/g, '');
}

/**
 * Pobiera target eventa niezależnie od przeglądarki
 * @param {Event} e
 */
function getTarget(e){
        if(e.target)
                return e.target;
        else
                return e.srcElement;
}

/*
        javascript nie potrafi sam skopiowac obiektu, zawsze przekazuje go jako referencje, wiec dodaje do prototypu obiektu mozliwosc klonowania
*/
Object.prototype.clone = function() {
        var n = {};
        for (p in this) {
                n[p] = this[p];
        }
        return n;
}