function setVis(aId){
			var elem=document.getElementById(aId);
			if(elem.style.display=='block'){
				elem.style.display='none';
				return false;
			}else{
				elem.style.display='block';
				return false;
			}
		}
		
function createSelect(aIdBlock,aArr,aSelName,aSelVal){
	//alert(aArr[0]);
	var block=document.getElementById(aIdBlock);
	var select=document.createElement('select');
	select.name=aSelName;
	block.appendChild(select);
	for(var i=0;i<aArr.length;i++){
		var option=document.createElement('option');
		var txt=document.createTextNode(aArr[i]);
		option.appendChild(txt);
		if(aArr[i]<10){
			option.value="0"+aArr[i];
		}else
		{
		option.value=aArr[i];
		}
		option.selected=false;
		if(aSelVal==aArr[i]){
			option.selected=true;
		}
		select.appendChild(option);
	}
	return select;
}

/* need soon 
function createStatTable(aIdBlock,aArr,cols,rows){
	var block=document.getElementById(aIdBlock);
	var table=document.createElement('table');
	var tbody=document.createElement('tbody');
	table.appendChild(tbody);
	block.appendChild(table);
	for(var i=0; i<cols.length;i++){
		var tr=document.createElement('tr');
		tbody.appendChild(tr);
		for(var j=0;j<rows;j++){
			var td=document.createElement('td');
			tr.appendChild(td);	
		}
	}
	return table;
}*/


//need soon
function colorTable(aId){
	var trs=document.getElementById(aId).getElementsByTagName('tr');
	//alert(trs.length);
	var i=0;
	do{
		trs[i].style.backgroundColor='#E3ECF3';
		if(trs[i+1]){trs[i+1].style.backgroundColor='#BDE0FD'};
		i=i+2;
	}
	while(i<trs.length);
}

function mail_check(str)
{ return str.match(/^(\w|-|\d|_)+(\.(\w|-|\d|_)+)*@(\w|-|\d)+(\.(\w|-|\d)+)+$/); }


function is_valid_domain(str){
 return str.match(/^[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]$/)
}

function form_check()
{
if(document.registration.usname.value=="" || document.registration.usname.value.length<3){
	//alert('Empty user name!');
	//return false;
	ValidateValue('usname',false);
   	}
   	else{ValidateValue('usname',true);
   	}	
if(document.registration.mail.value=='' || !mail_check(document.registration.mail.value)){
   ValidateValue('mail',false);
   	}
   	else{ValidateValue('mail',true);
   	}
 if(document.registration.mail.value != document.registration.mail_c.value){
 	ValidateValue('mail_c',false);
   	}
   	else{ValidateValue('mail_c',true);
   	}
if(document.registration.passwd.value=="" || document.registration.passwd.value.length<6){
	ValidateValue('passwd',false);
   	}
   	else{ValidateValue('passwd',true);
   	}
if(document.registration.passwd.value != document.registration.passwd_c.value || document.registration.passwd_c.value.length<6){
 	ValidateValue('passwd_c',false);
   	}
   	else{ValidateValue('passwd_c',true);
	}
if(document.registration.forum_name.value.length < 3 || document.registration.forum_name.value=="www" || !is_valid_domain(document.registration.forum_name.value)){
 	ValidateValue('forum_name',false);
   	}
   	else{ValidateValue('forum_name',true);
	}
	
	document.registration.submit();
}


function ValidateValue(aIdBox,aGood){
	var input=document.getElementById(aIdBox);
	//alert(input.id);
	var div=document.getElementById(aIdBox+'_v');
	//alert(div.id);
		while(div.childNodes.length>0){div.removeChild(div.childNodes[0]);} //clear current state
		//(div.childNodes.length>0){div.removeChild(div.childNodes[0]);} //clear current state
	var img=document.createElement('img');
	div.appendChild(img);
	if(aGood){
		//div.style.display='block';
		//img.src="./images/yes.png";
	}
	else{
		//div.style.display='block';
		//img.src="./images/no.png";
		if(input.type!='checkbox'){
		input.style.border="#ff0000 1px solid ;"
		}
	}
	return false;
}


function update_img(){    	
		var img = document.getElementById('secure_img');
    	var rnd = new Date();
        var rnd = Math.floor( Math.random()*10000 );
    	img.src = './captcha/get_captcha.php?t=' + rnd;
    	return false;
    }

 


