/**
 * package: js
 * project: babyinzercia.sk
 * created: 090626, Igor Fararik, www.pcart.sk
 */
 
function waitingBar(ref) {
	var elem = getElem('waitBar');
	if (!ref || ref.indexOf('javascript')<0) {
		clickfirst = false;
		document.body.style.cursor = 'wait';
		var ie6 = (document.all && !window.opera && !window.XMLHttpRequest) ? true : false;
		elem.style.zIndex='999';
		var height = 0;
		var width = 0;
		if (ie6) {
			var elements = document.body.getElementsByTagName('select');
			for (var i = 0; i < elements.length; i++) {
				elements[i].disabled='disabled';
			}
		} 
		if (!window.opera) {
			height = document.body.clientHeight;
		} else {
			height = document.documentElement.clientHeight;
		}
		elem.style.margin='0';
		elem.style.height=height+'px';
		elem.style.visibility='visible';
	}
} 
					function waitingBarForm(ref) {
						var elem = getElem('waitBarForm');
						if (!ref || ref.indexOf('javascript')<0) {
							clickfirst = false;
							document.body.style.cursor = 'wait';
							var ie6 = (document.all && !window.opera && !window.XMLHttpRequest) ? true : false;
							elem.style.zIndex='999';
							var height = 0;
							var width = 0;
							if (ie6) {
								var elements = document.body.getElementsByTagName('select');
								for (var i = 0; i < elements.length; i++) {
									elements[i].disabled='disabled';
								}
							} 
							if (!window.opera) {
								height = document.body.clientHeight;
							} else {
								height = document.documentElement.clientHeight;
							}
							elem.style.margin='0';
							elem.style.height=height+'px';
							elem.style.visibility='visible';
						}
					} 
					
					
function getElem(ename) {
	if (document.all) return document.all[ename];
	if (document.getElementById) return document.getElementById(ename);
}

var first = false;
	
					
/** 
 * inerText
 *
 * @param
 */
function inerText(compName,text){
	if(document.getElementById(compName).innerHTML=='') {
		document.getElementById(compName).innerHTML=text;
	} else {
		document.getElementById(compName).innerHTML='';
	}
}
/**
 * checkInput
 *
 * @param
 */
function checkInput(comp,numb){
	compId='check_'+comp.id;
	compVal=comp.value;
	if(compVal.length>=numb){
		checked=compVal.substring(0,numb);
		comp.value=checked;
		document.getElementById(compId).className="tr";
	} else {
		checked=compVal;
		document.getElementById(compId).className="";
	}
	document.getElementById(compId).innerHTML=(numb-checked.length);
}
/**
 * setError
 *
 * @param
 */
function setError(comp) {
	comp.className="cbe te";
} 
/**
 * setOK
 *
 * @param
 */
function setOK(comp) {
	comp.className="cb p1p";
}
/**
 * isEmpty
 *
 * @param
 */
function isEmpty(s) {
   return ((s == null) || (s.length == 0))
}
/**
 * isDigit
 *
 * @param
 */
function isDigit(c) {
	return ((c >= '0') && (c <= '9'))
}
/**
 * isInteger
 *
 * @param
 */
function isInteger(s) {
	var i;
    for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
        if (!isDigit(c)) return false;
	}
	return true;
}
/**
 * isPrice
 *
 * @param
 */
function isPrice(s) {
	var i;
    for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (!isDigit(c)) {
			if (s.charAt(i) != ',') return false;
		}
	}
	return true;
}
/**
 * isEmail
 *
 * @param
 */
 function isEmail(s) {
    if (isWhitespace(s)) return false;
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != '@')) { 
    	i++
    }
    if ((i >= sLength) || (s.charAt(i) != '@')) return false;
    else i += 2;
    while ((i < sLength) && (s.charAt(i) != '.')) { 
    	i++
    }
    if ((i >= sLength - 1) || (s.charAt(i) != '.')) return false;
    else return true;
}
/**
 * isPhone
 *
 * @param
 */
 function isPhone(s) {
	var i;

	if (!isDigit(s.charAt(0)) && s.charAt(0)!='+'){
		return false;
	}
    if(s.length < 8) {
    	return false;
    } else {
    	for (i = 1; i < s.length; i++) {
    		var c = s.charAt(i);
        	if (!isDigit(c)) return false;
    	}
       	return true;
    }
    return false;
}
var whitespace = " \t\n\r";
/**
 * isWhitespace
 *
 * @param
 */
function isWhitespace(s) {
	var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++) {
    	var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}
/**
 * submitForm
 *
 * @param
 */
function submitForm(pressbutton){
	document.form.task.value=pressbutton;
	try {
		document.form.onsubmit();
		}
	catch(e){}
	document.form.submit();
}
/**
 * getWidth
 *
 */
function getWidth() {
	var brW = 0, ifW = 0, rP = 0;
	if(document.documentElement && document.documentElement.clientWidth) {
		 brW  = document.documentElement.clientWidth;
	} else if(document.body && document.body.clientWidth) {
		 brW  = document.body.clientWidth;
	} else {
		brW  = 1024;
	}
	rP = 300+Math.round(0.05*brW);
	//if(brW <= 1100) {rP = 300+Math.round(0.05*brW)+60};
	ifW = brW - rP;
	return ifW;
}
var width = getWidth();


/**
 * 
 */
function changeStyle(where, what) {
    if (document.getElementById) {
         document.getElementById(where).className = what;
    } 
	else if (document.all) {
         document.all[where].className = what;
    }
}


