function togglediv(divid){
	obj=document.getElementById(divid);
	if(obj.style.display=='none'){
		obj.style.display='block';
	} else {
		obj.style.display='none';
	}
}

function changeSpan(spanId,divId){
	div  = document.getElementById(divId);
	span = document.getElementById(spanId);
	if(div.style.display=='none')
		span.innerHTML = " [ + ] ";
	else span.innerHTML = " [ - ] ";
}

function myCheckEmail(value,spanId){
	var pattern =  /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	if (value == "")
		document.getElementById(spanId).innerHTML = "<span class='error'>Please type email</span>";
	else if (value != "" && !pattern.test(value))
		document.getElementById(spanId).innerHTML = "<span class='error'>Please type a valid email</span>";
	else document.getElementById(spanId).innerHTML = "";
}

function myCheckField(value, spanId, field){
	if (value == "")
		document.getElementById(spanId).innerHTML = "<span class='error'>Please type "+field+"</span>";
	else document.getElementById(spanId).innerHTML = "";
}

function myCheck(objId,id){
	ok          = true;
	var nameid  = "checkname"+id;
	var commid  = "checkcomment"+id;
	var emailid = "checkemail"+id;
	var codeid  = "checkcode"+id
	var obj     = document.getElementById(objId);
	var name    = obj.nume;
	var email   = obj.email;
	var comment = obj.comentariu;
	var code    = obj.cod; 
	var pattern =  /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	
	if (name.value == ""){
		ok = false;
		document.getElementById(nameid).innerHTML = "<span class='error'>Please type name</span>";
	}
	
	if (email.value == ""){
		ok = false;
		document.getElementById(emailid).innerHTML = "<span class='error'>Please type email</span>";
	}
	
	if (email.value != "" && !pattern.test(email.value)){
		ok = false;
		document.getElementById(emailid).innerHTML = "<span class='error'>Please type a valid email adress</span>";
	}
	
	if (comment.value == ""){
		ok = false;
		document.getElementById(commid).innerHTML = "<span class='error'>Please type comment</span>";
	}
	
	if (code.value == ""){
		ok = false;
		document.getElementById(codeid).innerHTML = "<span class='error'>Please type code</span>";
	}
	
	return ok;
}

function displayHTML(printContent) {
var inf = printContent;
win = window.open("printVersion.html?", 'popup', 'toolbar = no, status = no, width=800, height=600, resizable = yes, scrollbars = yes');
win.document.write("<a href='javascript:;' onclick='window.print();'>Print this page</a><br /><br />");
win.document.write(inf);
win.document.close(); // new line
} 
