function changebg(id){document.getElementById("menu_"+id).style.background="#666666";document.getElementById("menu_"+id).style.cursor="pointer";}
function removebg(id){document.getElementById("menu_"+id).style.background="#262626";}
function aboneazaComm(){
  var formularul = document.getElementById('abonareComentariiWrapper');
  if (formularul.style.display == 'none') {
	  formularul.style.display = 'block';
	  return false;
	}
	else { formularul.style.display = 'none'; }
}
function bookmark(title, url){
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if( window.opera && window.print ){
	    var mbm = document.createElement('a');
	    mbm.setAttribute('rel','sidebar');
	    mbm.setAttribute('href',url);
	    mbm.setAttribute('title',title);
	    mbm.click();
    }
    else if( document.all ) window.external.AddFavorite( url, title);
}
function showBullets( no ){
	//alert( no );
		for ( var i = 1; i<=no; i++ ){
			var id = 'vote_nota_' + i;
			var div = document.getElementById( id );
			var newImage = 'fileadmin/images/video/vote3.png';
			if ( div ){
				div.src = newImage;
			}
		}
}
function hideBullets( nota ){
    var oldImage1 = 'fileadmin/images/video/vote1.png';
	var oldImage2 = 'fileadmin/images/video/vote2.png';
    for ( var i = 1; i<11; i++ ){
        var id = 'vote_nota_' + i;
        var div = document.getElementById( id );
        if ( div ){
            if( i > nota ) div.src = oldImage1;
			else div.src = oldImage2;
        }
    }
}
function get_contents(http_request) {        
	try {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				manage_response( http_request.responseXML );							
			} else {
				alert('There was a problem with the request.');
			}
		}
	}
	catch( e ) {
		//alert('Caught Exception: ' + e.description);
	}
}

function reset_vote( nota_noua,pic ){
	var oldImage1 = 'fileadmin/images/video/vote1.png';
	var oldImage2 = 'fileadmin/images/video/vote2.png';
	var div;
	var id;
	for ( var j=1; j<=10; j++ ){
		id = 'vote_nota_' + j;
		id2 = 'vote_nota_poza'+pic+'_'+j;
		div = document.getElementById( id );
		aaa = document.getElementById( 'vote_nota_poza'+pic+'_'+j );
		
		if ( div ){
			if( j > nota_noua ){
				div.src = oldImage1;
			}
			else{
				div.src = oldImage2;
			}
		}
		if ( aaa ){
			if( j > nota_noua ){
				aaa.src = oldImage1;
			}
			else{
				aaa.src = oldImage2;
			}
		}
	}
}

function resetPicture( nota_noua,pic ){
	var oldImage1 = 'fileadmin/images/video/vote1.png';
	var oldImage2 = 'fileadmin/images/video/vote2.png';
	var div;
	var id;
	for ( var j=1; j<=5; j++ ){
		id2 = 'vote_nota_poza'+pic+'_'+j;
		aaa = document.getElementById( 'vote_nota_poza'+pic+'_'+j );
		
		if ( aaa ){
			if( j > nota_noua ){
				aaa.src = oldImage1;
			}
			else{
				aaa.src = oldImage2;
			}
		}
	}
	
}

function manage_response( xmldoc ){
	nota_vot = xmldoc.getElementsByTagName('nota')[0].firstChild.nodeValue;
	numar = xmldoc.getElementsByTagName('numar')[0].firstChild.nodeValue;
	pic = xmldoc.getElementsByTagName('pic')[0].firstChild.nodeValue;
	document.getElementById('numar_voturi'+pic).innerHTML = numar+'&nbsp;&nbsp; voturi';						
	reset_vote( nota_vot,pic );
	resetPicture( nota_vot,pic );
}

function selectEmbed(){
	var text_val=eval("document.getElementById('selectEmbed')");
	text_val.focus();
	text_val.select();
}

function NewWindow(mypage, myname, w, h, isscroll, pos) {
		if (screen.width && screen.height){ 
		//alert(w+" "+h+" "+screen.width+" "+screen.height);
			if (screen.width<w) {LeftPosition=20;w=screen.width-50;test_scroll='yes';}
			else {LeftPosition=(screen.width-w)/2;}
			if ((screen.height-50)<=h) {TopPosition=20;h=screen.height-170;test_scroll='yes';}
			else {TopPosition=(screen.height-h)/2;}
		}
		else {LeftPosition=20;TopPosition=20;test_scroll='yes';}
		//alert(LeftPosition+" "+TopPosition+" "+w+" "+h+" "+screen.width+" "+screen.height);
	settings='width='+w+',height='+h+',top='+(TopPosition-50)+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
	win=window.open(mypage,myname,settings);
	return win;
}

function taLimit(taObj) {
	var maxL=28;
	
	if (taObj.value.length >= maxL) {taObj.value=taObj.value.substring(0, maxL);}
	return true;
}

function taCount(taObj,Cnt) { 
	var maxL=28;
	var bName = navigator.appName;
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=maxL-objVal.length;}
		else{objCnt.innerText=maxL-objVal.length;}
	}
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}


//DropDown Menu

function activateA(cur) {
	var t = cur;
	if (t) {
		t=t.firstChild;
		if (t) {
			var pos = t.className.indexOf('firstlevellink');
			if (pos>=0) {
				t.className += ' hoveratag';
			}
		}
	}
}

function deActivateA(cur) {
	var t = cur;
	if (t) {
		t=t.firstChild;
		if (t) {
			var pos = t.className.indexOf('firstlevellink');
			if (pos>=0) {
				t.className=t.className.replace(" hoveratag", "");
			}
		}
	}
}

// IE only makes :hover work on LI tags
activateMenu = function(nav) {
	/* Get all the list items within the menu */
	var navroot = document.getElementById(nav);
	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";
				activateA(this);
			}
			lis[i].onmouseout=function() {                       
				this.lastChild.style.display="none";
				deActivateA(this);
			}
		}
	}
}

window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
	activateMenu('yacbddm'); 
}


//END DROP DOWN


//Validare Intrebare Expertul Petocuri

function Validate_formEP(scode)
{
	var regForm_valid = 0;
	var regForm_tmpArray=new Array();
	var illegalChars = /\W/;

	document.getElementById('expertulPetocuri_intrebareErr').innerHTML = '';
	document.getElementById('expertulPetocuri_emailErr').innerHTML = '';
	document.getElementById('expertulPetocuri_numeErr').innerHTML = '';
	document.getElementById('expertulPetocuri_codeErr').innerHTML = '';


    if (document.regForm_ep.ep_intrebare.value == '') 
    {
       document.getElementById('expertulPetocuri_intrebareErr').innerHTML = 'Completeaza Intrebare!';
       regForm_valid = 1
    }
    if (document.regForm_ep.ep_email.value == '') 
    {
       document.getElementById('expertulPetocuri_emailErr').innerHTML = 'Completeaza Email!';
       regForm_valid = 1
    }
    if (document.regForm_ep.ep_nume.value == '') 
    {
       document.getElementById('expertulPetocuri_numeErr').innerHTML = 'Completeaza Nume!';
        regForm_valid = 1
    }
   if (document.regForm_ep.ep_scode.value != scode){
	   
       document.getElementById('expertulPetocuri_codeErr').innerHTML = 'Cod de securitate invalid!';
       regForm_valid = 1
   }

	
	if ( (regForm_valid == 0) && (regFormUsername_valid == 0) && (regFormEmail_valid == 0)){ 
	return true;
	}else return false;
}


