﻿function dosearch(root,query)
{
	window.location.href=root+"Search/"+query+".html";
}
function hitEnter(e, action)
{
	var keynum;
	
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if (keynum == 13){
		action.submit();
		return false;
	}
	return true;
}
function doSearchHitEnter(e, root, query)
{
	var keynum;
	
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if (keynum == 13){
		window.location.href=root+"Search/"+query+".html";
		return false;
	}
	return true;
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function submitform(formid)
{
    if(typeof($(formid).onsubmit) == "function")
    {
        if($(formid).onsubmit())
        {
            $(formid).submit();
        }
    }
    else
    {
        $(formid).submit();
    }
}

function changeSelect(url)
{
	document.location.href=url;
}
function messagesMarkUnread(formid)
{
    $(formid).action = "/Message/MarkUnreadMultiple.rails";
    $(formid).submit();
}

function messagesMarkRead(formid)
{
    $(formid).action = "/Message/MarkReadMultiple.rails";
    $(formid).submit();
}

function messagesDelete(formid)
{
    $(formid).action = "/Message/DeleteMultiple.rails";
    $(formid).submit();
}
function deselectMessages(msgclass)
{
    var elements = document.getElementsByClassName(msgclass);
    
    for(var i=0; i<elements.length; i++)
    {
        elements[i].checked = false;
    }
}
function selectMessages(msgclass)
{
    deselectMessages('msg_input');
    var elements = document.getElementsByClassName(msgclass);
    for(var i=0; i<elements.length; i++)
    {
        elements[i].checked = true;
    }
}
function searchMessages(type)
{
}
function rateArticle(rating, rateform)
{
    $('art_rating').value = rating;
    submitform(rateform);
}

function ShowInfo(nr)
{
	 for(var x=1;x<3;x++)
	 {
		 var ob=document.getElementById("info"+x);
		 var link=document.getElementById("linkinfo"+x);
		 if(x!=nr)
		 {
			 ob.className="infooff";
			 link.className="aoff";
		 }
		 else
		 {
			 ob.className="infoon";
			 link.className="aon";
		 }
	 }
}

function ShowInfoNel(nr)
{
	 for(var x=1;x<3;x++)
	 {
		 var ob=document.getElementById("info"+x);
		 var ob2=document.getElementById("box"+x);
		 var link=document.getElementById("linkinfo"+x);
		 if(x!=nr)
		 {
			
			 ob.className="infooff";
			  ob2.className="infooff";
			 link.className="aoff";
		 }
		 else
		 {
			 
			 ob.className="infoon";
			 ob2.className="infoon";
			 link.className="aon";
		 }
	 }
}

function ShowInfoHome(nr)
{
	 for(var x=1;x<3;x++)
	 {
		 var ob=document.getElementById("info"+x);
		 var link=document.getElementById("linkinfo"+x);
		 if(x!=nr)
		 {
			 ob.className="infooff";
			 link.className="showoff";
		 }
		 else
		 {
			 ob.className="infoon";
			 link.className="showon";
		 }
	 }
}

function ShowInforg(nr)
{
	 for(var x=1;x<4;x++)
	 {
		 var ob=document.getElementById("info"+x);
		 var link=document.getElementById("linkinfo"+x);
		 if(x!=nr)
		 {
			 ob.className="infooff";
			 link.className="aoff";
		 }
		 else
		 {
			 ob.className="infoon";
			 link.className="aon";
		 }
	 }
}

function showTab(index)
{
	var elements = document.getElementsByClassName('homemenu');
	for(i=0; i<elements.length;i++)
	{
			elements[i].style.display='none';
	}
	$(index).style.display='';
}

function showTopTab(index)
{
	var elements = document.getElementsByClassName('menuhome');
	for(i=0; i<elements.length;i++)
	{
			elements[i].style.display='none';
	}
	$(index).style.display='';
}

var formHTML = null;
function replyTo(id)
{
    var formpositions = document.getElementsByClassName("replyForm");
    for(i=0; i<formpositions.length; i++)
    {
        formpositions[i].innerHTML = '';
    }

    if(formHTML == null)
    {
        formHTML = $('formposition').innerHTML;
        $('formposition').innerHTML = '';
    }

    $('replyposition' + id).innerHTML = formHTML;
    $('replyTo').value = id;

    Effect.BlindDown('replyposition' + id);
    
}
function reloadCaptcha(id)
{
    $(id).src = '/Thumbnail/Captcha.rails?'+Math.random();
}

function openWindow() 
{
	  var arrayURL = new Array('','http://www.noricanicolai.ro','http://www.valean.eu', 'http://www.renateweber.eu', 'http://www.ramona-manescu.ro', 'http://www.cristibusoi.ro');
	  var selectId=document.getElementById('windowOpener').selectedIndex;
	  //alert(selectId);
	  if(selectId > 0)
		window.open(arrayURL[selectId],'_blank');
}

function openWindow2() 
{
	  var arrayURL = new Array('','http://www.pnl-alba.ro', 'http://www.pnlarad.ro', 'http://www.pnl-bihor.ro','http://www.urbaninfo.ro/pnlbraila/', 'http://www.pnlsector1.ro','http://www.pnl-sector2.ro','http://www.pnlsector3.ro','http://www.pnl4.ro','http://www.pnlsector5.ro/','http://www.pnl6.ro','http://www.pnlbrasov.ro','http://www.pnlbuzau.ro','http://www.pnl-campina.ro','http://www.pnlcluj.ro','http://www.pnl-constanta.ro','http://www.pnldambovita.ro','http://www.pnldorohoi.ro/','http://www.pnlgalati.ro','http://www.pnlgiurgiu.ro','http://www.pnlgorj.ro','http://www.pnliasi.ro','http://www.pnlilfov.ro','http://www.pnlmangalia.ro','http://www.pnl-maramures.ro','http://www.pnlmehedinti.ro','http://www.pnlmures.ro','http://www.pnlneamt.ro','http://pnl.ro/Public/Contact.html','http://www.pnlsatumare.ro','http://www.pnlsuceava.ro','http://www.pnlteleorman.ro','http://www.pnltimis.ro','http://www.pnltulcea.ro','http://www.pnlvaslui.ro','http://www.pnlvl.ro','http://www.pnlvrancea.ro');
	  var selectId=document.getElementById('windowOpener2').selectedIndex;
	  //alert(selectId);
	  if(selectId > 0)
		window.open(arrayURL[selectId],'_blank');
}

function changeCandidati(idx)
{
		var dropdown = document.getElementsByClassName('articol-candidat');
		var comments = document.getElementsByClassName('comentarii-candidat');
		for (i = 0;i < dropdown.length;i++)
		{
			dropdown[i].style.display = 'none';
		}
		for (i = 0;i < comments.length;i++)
		{
			comments[i].style.display = 'none';
		}
		document.getElementById('articol-candidat'+idx).style.display = 'block';
		document.getElementById('comentarii-candidat'+idx).style.display = 'block';
		document.getElementById('artid').value = idx;
}

function validFormApplication(nume,judet,localitate,adresa,mobil,email,datan,work,comunicarev,comunicarei,pc,experienta,pnlputernic)
	{
		if (document.getElementById(nume).value != ""){
				
		}
		else{
			alert("Introduceti numele si prenumele!");
			document.getElementById(nume).focus();
			return false;
		}
		
		if (document.getElementById(judet).value != ""){
				
		}
		else{
			alert("Introduceti judetul!");
			document.getElementById(judet).focus();
			return false;
		}
		
		if (document.getElementById(localitate).value != ""){
				
		}
		else{
			alert("Introduceti localitatea!");
			document.getElementById(localitate).focus();
			return false;
		}
		
		if (document.getElementById(adresa).value != ""){
				
		}
		else{
			alert("Introduceti adresa!");
			document.getElementById(adresa).focus();
			return false;
		}
		
		if (document.getElementById(mobil).value != ""){
				
		}
		else{
			alert("Introduceti mobilul!");
			document.getElementById(mobil).focus();
			return false;
		}
		
		if (document.getElementById(email).value != ""){
				
		}
		else{
			alert("Introduceti emailul!");
			document.getElementById(email).focus();
			return false;
		}
		
		if (document.getElementById(datan).value != ""){
				
		}
		else{
			alert("Introduceti datanasterii!");
			document.getElementById(datan).focus();
			return false;
		}
		
		if (document.getElementById(work).value != ""){
				
		}
		else{
			alert("Completati campul Pentru cine ai lucrat in campaniile electorale trecute si care au fost responsabilitatile tale? !");
			document.getElementById(work).focus();
			return false;
		}
		
		if (document.getElementById(comunicarev).value != ""){
				
		}
		else{
			alert("Completati campul Comunicare cu votantii!");
			document.getElementById(comunicarev).focus();
			return false;
		}
		
		if (document.getElementById(comunicarei).value != ""){
				
		}
		else{
			alert("Completati campul Comunicare interpersonala!");
			document.getElementById(comunicarei).focus();
			return false;
		}
		if (document.getElementById(pc).value != ""){
				
		}
		else{
			alert("Completati campul Cunostinte PC!");
			document.getElementById(pc).focus();
			return false;
		}
		if (document.getElementById(experienta).value != ""){
				
		}
		else{
			alert("Completati campul Alte experiente de munca relevanta!");
			document.getElementById(experienta).focus();
			return false;
		}
		if (document.getElementById(pnlputernic).value != ""){
				
		}
		else{
			alert("Completati campul Cum poate deveni PNL mai puternic?!");
			document.getElementById(pnlputernic).focus();
			return false;
		}
	}


function showBanner(index)
{
	var elements = document.getElementsByClassName('slides');
	for(i=0; i<elements.length;i++)
	{
			elements[i].style.display='none';
	}
	$(index).style.display='';
}

function changeMod()
{
	$('select1').className = 'select-widget';
	$('select2').className = 'unselect-widget';
}

function changeMod2()
{
	$('select2').className = 'select-widget';
	$('select1').className = 'unselect-widget';
}

function changeNr (id) {
	
	var sageti = document.getElementsByClassName('unselect-nr');
	for (i=0; i<sageti.length; i++) {
		sageti[i].removeClassName('select-nr');
	}
	$('num'+id).addClassName('select-nr');
}

var widget_skin = 1;
var widget_nr = 3;

function showWidget1 (id) {
	widget_skin = id;
	displayWidget();
}

function showWidget2 (id) {
	widget_nr = id;
	displayWidget();
}
function displayWidget()
{
	var code = "<style type=\"text/css\">@import url('http://pnl.ro/content/css/widget.css');</style>";
	code += "<div id=\"w0pn1Widget\"";
	if(widget_skin == 1) {
		code += " class=\"w0pn1WidgetBlue\"";
	}
	code += "><div class=\"w0pn1WidgetTop\"></div>";
	code += "<div id=\"w0pn1WidgetContent\"></div>";
	code += "<div class=\"w0pn1WidgetBottom\"></div></div>";
	$('box-widget').innerHTML = code;

	code += "<script src=\"http://pnl.ro/Content/js/widget.js\" type=\"text/javascript\" charset=\"utf-8\"></script>";
	code += "<script src=\"http://pnl.ro/widgetjson.html?callback=showWidget&amp;count=" + widget_nr + "\" type=\"text/javascript\" charset=\"utf-8\"></script>";
	$('embed_code').value = code;
	
	var head = document.getElementsByTagName('head')[0];
	var script = document.createElement('script');
	script.type= 'text/javascript';
	script.src= 'http://pnl.ro/Content/js/widget.js';
	head.appendChild(script);
	
	var script2 = document.createElement('script');
	script2.type= 'text/javascript';
	script2.src= 'http://pnl.ro/widgetjson.html?callback=showWidget&count=' + widget_nr;
	head.appendChild(script2);
}
