﻿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 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 mouseOverEveniment(id)
{
		document.getElementById(id).style.display = 'block';
}

function mouseOutEveniment(id)
{
		document.getElementById(id).style.display = 'none';
}

function hideSelect()
{
		document.getElementById('sel-calendar').style.display = 'none';
		document.getElementById('img-select').style.display = 'block';
}

function showSelect()
{
		document.getElementById('sel-calendar').style.display = 'block';
		document.getElementById('img-select').style.display = 'none';
}

function  verifyCheckedBox(checkid){
  return document.getElementById(checkid).checked;
  }


function validareNewsletter()
{  
	var sw=0;
	if (((document.getElementById('nume').value == null) || (document.getElementById('nume').value == "") || (document.getElementById('nume').value == "nume"))&&(sw==0))
		{
			alert('Please enter your name \n');
			sw=1;
			return false;
		}
	if ( (document.getElementById('email').value == null) || (document.getElementById('email').value == "") || (document.getElementById('email').value == "email") || (isEmail(document.getElementById('email').value) == false&&sw==0))
		{
			alert('You need to specify a valid email address! \n');
			sw=1;
			return false;
		}
	else
		return true;	
}

function validareEmail()
{  
	var sw=0;
	if ( (document.getElementById('target1').value == null) || (document.getElementById('target1').value == "") || (document.getElementById('target1').value == "email") || (isEmail(document.getElementById('target1').value) == false&&sw==0))
		{
			alert('Please enter a valid email address! \n');
			sw=1;
			return false;
		}
	else
		alert("Thank you for recommending our site My Life Coach ");
		return true;
		
}

function validareFormular()
{  
	var sw=0;
	
	if (((document.getElementById('profil.username').value == null) || (document.getElementById('profil.username').value == ""))&&(sw==0))
		{
			alert('Please enter your user name! \n');
			sw=1;
			return false;
		}
	if ( (document.getElementById('profil.email').value == null) || (document.getElementById('profil.email').value == "") || (isEmail(document.getElementById('profil.email').value) == false&&sw==0))
		{
			alert('Please enter a valid email address! \n');
			sw=1;
			return false;
		}
		
	if (((document.getElementById('profil.parola').value == null) || (document.getElementById('profil.parola').value == ""))&&(sw==0))
		{
			alert('Please enter your password! \n');
			sw=1;
			return false;
		}
	if (((document.getElementById('nume').value == null) || (document.getElementById('nume').value == ""))&&(sw==0))
		{
			alert('Please enter your last name! \n');
			sw=1;
			return false;
		}
	if (((document.getElementById('prenume').value == null) || (document.getElementById('prenume').value == ""))&&(sw==0))
		{
			alert('Please enter your first name! \n');
			sw=1;
			return false;
		}	
	if (((document.getElementById('profil.confirmare').value == null) || (document.getElementById('profil.confirmare').value == ""))&&(sw==0))
		{
			alert('Please re-enter your password! \n');
			sw=1;
			return false;
		}	
	
	if ( (verifyCheckedBox('conditii2') == false) && sw==0)
	{
	alert('You must agree to the terms and conditions of the site!');
	sw=1;
	return false;
	}
	else
		return true;
}


/* adaugat nicu */


function $FR(formElement, radioName) {
	var el = formElement.getInputs('radio', radioName).find(function(radio) { return radio.checked; });
	return el;
}

function checkradio(start,end) {
	status=0;
	var theform = $("wheel");
	$('error').innerHTML = "";
	for(i=start; i<=end; i++) {
		if ($FR(theform, "radio"+i)==undefined) {
		//$('error').innerHTML = "Va rugam sa raspundeti la toate intrebarile";
		alert('Please answer all the questions');
		status = 0;
		return "";	
		}
		else {
		status=1
		}
	}	
	if (status=1) {
		my_glider.next();
		return false;
	}
	
}

function $RF(el, radioGroup) {
    if($(el).type && $(el).type.toLowerCase() == 'radio') {
        var radioGroup = $(el).name;
        var el = $(el).form;
    } else if ($(el).tagName.toLowerCase() != 'form') {
        return false;
    }

    var res = $(el).getInputs('radio', radioGroup).find(function(re) {return re.checked;});
	if(res != null) {
	return $F(res);
	} else {
	return ""
	}
}

function rezultate() {
	var checks = checkradio(13,18);
	if (checks == false) {
	var value1 =parseInt($RF('wheel','radio1'));
	var value2 =parseInt($RF('wheel','radio2'));
	var value3 =parseInt($RF('wheel','radio3'));
	var value4 =parseInt($RF('wheel','radio4'));
	var value5 =parseInt($RF('wheel','radio5'));
	var value6 =parseInt($RF('wheel','radio6'));
	var value7 =parseInt($RF('wheel','radio7'));
	var value8 =parseInt($RF('wheel','radio8'));
	var value9 =parseInt($RF('wheel','radio9'));
	var value10 =parseInt($RF('wheel','radio10'));
	var value11 =parseInt($RF('wheel','radio11'));
	var value12 =parseInt($RF('wheel','radio12'));
	var value13 =parseInt($RF('wheel','radio13'));
	var value14 =parseInt($RF('wheel','radio14'));
	var value15 =parseInt($RF('wheel','radio15'));
	var value16 =parseInt($RF('wheel','radio16'));
	var value17 =parseInt($RF('wheel','radio17'));
	var value18 =parseInt($RF('wheel','radio18'));

	var Cariera_Procent= parseInt((value4 + value12 + value17)/3)
	var Finante_Procent= parseInt((value2 + value6 + value15)/3)
	var Sanatate_Procent= parseInt((value8 + value11 + value16)/3)
	var Casa_Procent= parseInt((value5 + value9)/2)
	var Relatiile_Procent= parseInt((value3 + value14 + value18)/3)
	var Spiritualitate_Procent= parseInt((value7 + value10 + value13)/3)
	
	$('cariera').innerHTML = Cariera_Procent;
	$('finante').innerHTML = Finante_Procent;
	$('sanatate').innerHTML = Sanatate_Procent;
	$('casa').innerHTML = Casa_Procent;
	$('relatiile').innerHTML = Relatiile_Procent;
	$('spiritualitate').innerHTML = Spiritualitate_Procent;
	$('finish_text').innerHTML = 'Congratulations! You have made a very important step toward having a great life. Now it’s time to focus on the real work of moving your life to the next level. Imagine the "wheel of life" as a wheel of a bicycle. Are all the spokes at their places? How well are you going on this bike? Use this tool to see in which areas you need more balance, and start working in this direction!';
	
	//embed
	var flashvars = {};
	flashvars.CarieraProcent = Cariera_Procent;
	flashvars.FinanteProcent = Finante_Procent;
	flashvars.SanatateProcent = Sanatate_Procent;
	flashvars.CasaProcent = Casa_Procent;
	flashvars.RelatiileProcent = Relatiile_Procent;
	flashvars.SpiritualitateProcent = Spiritualitate_Procent;
	var paramshswf = {};
	paramshswf.play = "true";
	paramshswf.loop = "true";
	paramshswf.menu = "false";
	paramshswf.quality = "high";
	paramshswf.scale = "showall";
	paramshswf.wmode = "transparent";
	paramshswf.devicefont = "false";
	paramshswf.allowfullscreen = "true";
	paramshswf.allowscriptaccess = "always";
	var attributeshswf = {};
	attributeshswf.id = "hswf";
	attributeshswf.align = "middle";
	swfobject.embedSWF("content/flash/flash.swf", "headerswf", "250", "250", "9", "0", flashvars, paramshswf, attributeshswf);
	}
}

/* end adaugat nicu */