// lib js
var W3CDOM = (document.createElement && document.getElementsByTagName);

function bgForm() {
	if (this.name=='name' ||
		this.name=='email' ||
		this.name=='phone' ||
		this.name=='adres' ||
		this.name=='standata' ||
		this.name=='stanlicznika' ||
		this.name=='przeplywcalkowity' ||
		this.name=='czaspracy' ||
		this.name=='uwagi' ||
		this.name=='_q' ||
		this.name=='V' ||
		this.name=='F' ||
		this.name=='content_text') {
			this.style.background='#FFF0BB';
	}
}

function bgFormDefault() {
	if (this.name=='name' ||
		this.name=='email' ||
		this.name=='phone' ||
		this.name=='adres' ||
		this.name=='standata' ||
		this.name=='stanlicznika' ||
		this.name=='przeplywcalkowity' ||
		this.name=='czaspracy' ||
		this.name=='uwagi' ||
		this.name=='_q' ||
		this.name=='V' ||
		this.name=='F' ||
		this.name=='content_text') {
			this.style.background='#EFEFEF';
	}
	return;
}

function viewDef (el,objset) {
	if (ot=eval("document.getElementById('"+el+"')")) {
		if(objset) { setPos(objset,el); }
		if (ot.style.display=='none'||ot.style.display=='') {
			ot.style.display='block';
		} else {
			ot.style.display='none';
		}
	}
	return;
}

function getObj(name) {
	 if (document.getElementById) {
	 	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}
function setPos(obj,oName) {
	var newX = getPosX(obj);
	var newY = getPosY(obj);
	if (oName == 'sufler') newY -= 102;
	if (oName == 'FotoWarstwa') newX = 300;
//	if (oName == 'sufler') newX += 5;
	var x = new getObj(oName);
	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
}
function getPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function getPosY(obj) {
	var curtop = obj.offsetHeight;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y)
		curtop += obj.y;
	return curtop;
}

activateMenu = function(nav) {
    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}


function init() {
	if (!W3CDOM) return;
	var el = document.getElementById('mainBox');
	var tmpobj = el.getElementsByTagName('input');
	for (var i=0;i<tmpobj.length;i++) {
		tmpobj[i].onfocus = bgForm;
		tmpobj[i].onblur = bgFormDefault
		tmpobj[i].number = i;
	}
	var tmpobj = el.getElementsByTagName('textarea');
	for (var i=0;i<tmpobj.length;i++) {
		tmpobj[i].onfocus = bgForm;
		tmpobj[i].onblur = bgFormDefault
		tmpobj[i].number = i;
	}
	
}

window.onload= function(){
//    activateMenu('nav'); 
//    activateMenu('menuBox'); 
	init();
}

