﻿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 P7_colH2(){
 var clear = 0;	
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
 
}
function P7_eqA2(el,p,pt){
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

var arrayMenu = ["program", "actori", "festival","istoric","muzeu","contact"];
function togleMenu(menuId) {
	for (var i = 0; i < arrayMenu.length; i++) {
		if (arrayMenu[i] == menuId) {
			document.getElementById(arrayMenu[i]).style.display = '';
			
		}
		else { 
			document.getElementById(arrayMenu[i]).style.display = 'none';
						
		}
	}
}

function showInfo1() { 
	$('info').style.display= 'block';
	$('info').style.marginLeft= '4px';
}

function showInfo2() { 
	$('info').style.display= 'block';
	$('info').style.marginLeft= '128px';
}

function showInfo3() { 
	$('info').style.display= 'block';
	$('info').style.marginLeft= '215px';
}

function showInfo4() { 
	$('info').style.display= 'block';
	$('info').style.marginLeft= '340px';
}

function hideInfo() { 
	$('info').style.display= 'none';
}

function isEmail(string)
{
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	return false;
}

function Nume()
{
	var sw = 0;
	if (((document.getElementById('nume').value == null) || (document.getElementById('nume').value == "") || (document.getElementById('nume').value == "Nume"))&&(sw==0))
	{
		alert('Introduceti numele! \n');
		sw=1;
		return false;
	}
	
	if (((document.getElementById('prenume').value == null) || (document.getElementById('prenume').value == "") || (document.getElementById('prenume').value == "Prenume"))&&(sw==0))
	{
		alert('Introduceti prenumele! \n');
		sw=1;
		return false;
	}
	
	if ( (document.getElementById('email').value == null) || (document.getElementById('email').value == "") || (isEmail(document.getElementById('email').value) == false)&&(sw==0))
	{
		alert('Introduceti o adresa de email valida! \n');
		sw=1;
		return false;
	}
	
	if(sw == 0)
	{
		return true;
	}
	return false;
}

function Nume2()
{
	var sw = 0;
	if (((document.getElementById('nume').value == null) || (document.getElementById('nume').value == "") || (document.getElementById('nume').value == "Nume"))&&(sw==0))
	{
		alert('Introduceti numele! \n');
		sw=1;
		return false;
	}
	
	if (((document.getElementById('prenume').value == null) || (document.getElementById('prenume').value == "") || (document.getElementById('prenume').value == "Prenume"))&&(sw==0))
	{
		alert('Introduceti prenumele! \n');
		sw=1;
		return false;
	}
	
	if ( (document.getElementById('email').value == null) || (document.getElementById('email').value == "") || (isEmail(document.getElementById('email').value) == false)&&(sw==0))
	{
		alert('Introduceti o adresa de email valida! \n');
		sw=1;
		return false;
	}
	
	if (((document.getElementById('mesaj'+id).value == null) || (document.getElementById('mesaj'+id).value == "") || (document.getElementById('mesaj'+id).value == "send your own personal message to Sergei"))&&(sw==0))
	{
		alert('Introduceti mesajul! \n');
		sw=1;
		
	}
	
	if(sw == 0)
	{
		return true;
	}
	return false;
}

function Nume3()
{
	var sw = 0;
	if (((document.getElementById('nume').value == null) || (document.getElementById('nume').value == "") || (document.getElementById('nume').value == "Nume"))&&(sw==0))
	{
		alert('Introduceti numele! \n');
		sw=1;
		return false;
	}
	
	if ( (document.getElementById('email').value == null) || (document.getElementById('email').value == "") || (isEmail(document.getElementById('email').value) == false)&&(sw==0))
	{
		alert('Introduceti o adresa de email valida! \n');
		sw=1;
		return false;
	}
	
	if (((document.getElementById('mesaj'+id).value == null) || (document.getElementById('mesaj'+id).value == "") || (document.getElementById('mesaj'+id).value == "send your own personal message to Sergei"))&&(sw==0))
	{
		alert('Introduceti mesajul! \n');
		sw=1;
		
	}
	
	if(sw == 0)
	{
		return true;
	}
	return false;
}
	