

function fromGallery(url, size) {
	if(size==50) {
		byId('av50').value=url.substr(30);
		byId('av50_img').src=url;
	} else {
		byId('av100').value=url.substr(31);
		byId('av100_img').src=url;
	}
}

function setTemplate( name, imgUrl ) {
		byId('template').value   = name;
		byId('template_img').src = imgUrl;
}


function openGallery(size) {
	if(!size) return;
	if(size=='50') {
		height='140';

		width='325';
		if(document.all) {
			width='331';
		}
	} else {
		height='240';
		width='575';
		if(document.all) {
			width='585';
		}
	}
	window.open('/register/avatar'+size, 'galeria', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width='+width+', height='+height);
}

function openTemplate() {
	height='240';
	width='575';
	if(document.all) {
	    width='585';
	}
	window.open('/register/template', 'galeria', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width='+width+', height='+height);
}


function setAction() {
	var oForm1 = byId('wiz_form');
	
	oForm1.action='http://------.pl/newblog.php';
	oForm1.onsubmit=null;
}
function resetSteps(step) {
	var d1 = byId('wiz_1').getElementsByTagName('div');
	var i=0;

	if(step==1) {
		byId('wiz_prev').disabled=true;
	} else {
		byId('wiz_prev').disabled=false;
	}

	if(step==4) {
		byId('wiz_next').style.display='none';
		byId('wiz_fin').style.display='';
	} else {
		byId('wiz_next').style.display='';
		byId('wiz_fin').style.display='none';
	}
	var c=0;
	for(i=0; i<d1.length; i++) {
		
		if(d1[i].className=='wizardStep') {
			if( (c+1)!=step ) {
				d1[i].style.display='none';
			}
			else {
				d1[i].style.display='block';
			}
			c++;
		}
		
	}
}
function smsCode(oInput){
	var oMsg=byId('pointsWarn');
	if(oInput.value == '3') {
		byId('smscode_div').style.display='';
		if(oMsg) {
			oMsg.style.display='';
		}
	} else {
		byId('smscode_div').style.display='none';
		if(oMsg) {
			oMsg.style.display='none';
		}
	}
}
function checkTags(oInput) {
	var reg=/\s{1,}/g;
	var v=oInput.value;
	v=v.replace(reg,' ');
	oInput.value=v;
}

function setMaxLength() {
    var x = document.getElementsByTagName('textarea');
    var counter = document.createElement('div');
    counter.className = 'counter';
    for (var i=0;i<x.length;i++) {
	if (x[i].getAttribute('maxlength')) {
	    var counterClone = counter.cloneNode(true);
    	    counterClone.relatedElement = x[i];
	    counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
	    x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
	    x[i].relatedElement = counterClone.getElementsByTagName('span')[0];
	    x[i].onkeyup = x[i].onchange = checkMaxLength;
	    x[i].onkeyup();
	}
    }
}
															
function checkMaxLength() {
    var maxLength = this.getAttribute('maxlength');
    var currentLength = this.value.length;
    if (currentLength > maxLength) {
        this.relatedElement.style.color = 'red';
        this.relatedElement.style.fontWeight = 'bold';
    } else {
        this.relatedElement.style.fontWeight = '';
	this.relatedElement.style.color = '';
    }
    this.relatedElement.firstChild.nodeValue = currentLength;
    // not innerHTML
}



