function galleryFlipper (src) {
        var img,titlebox;
        img      = document.getElementById('galImgElement');
        if (img) {
          img.style.backgroundImage = "url('"+src+"')";
        }
}

function footer(pic) { 
        document.getElementById("logo_footer").style.backgroundPosition="0px -"+pic+"px";
}


function validateComment (frm) {
        if (frm.name.value == '') {
          alert('Va rog introduceti numele dumneavoastra.');
          return false;
        }
        if (frm.name.value.length < 4 || frm.name.value.length > 32) {
          alert('Numele trebuie sa contina 4-32 caractere.');
          return false;
        }
        if (frm.comment.value == '') {
          alert('Va rog sa introduceti comentariul dumneavoastra.');
          return false;
        }
        if (frm.comment.value.length < 10) {
          alert('Comentariul trebuie sa aiba minim 10 caractere.');
          return false;
        }
        if (frm.captcha.value.length != 4) {
          alert('Va rog introduceti codul de securitate din imagine.');
          return false;
        }
}
function validateContact (frm) {
        if (frm.contactname.value == '') {
          alert('Va rog introduceti numele dumneavoastra.');
          return false;
        }
        if (frm.contactname.value.length < 4 || frm.name.value.length > 32) {
          alert('Numele trebuie sa contina 4-32 caractere.');
          return false;
        }
        if (frm.contactemail.value == '') {
          alert('Va rog sa introduceti adresa dumneavoastra de email.');
          return false;
        }
        var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/i;
        if (frm.contactemail.value.match(re) == null) {
          alert('Adresa de email introdusa este invalida.');
          return false;
        }
        if (frm.contactmessage.value.length < 10) {
          alert('Mesajul trebuie sa aiba minim 10 caractere.');
          return false;
        }
        if (frm.captcha.value.length != 4) {
          alert('Va rog introduceti codul de securitate din imagine.');
          return false;
        }
}

function validateNewsletterSubscribe(frm) {
        if (frm.name.value == '') {
          alert('Va rog introduceti numele dumneavoastra.');
          return false;
        }
        if (frm.name.value.length < 3 || frm.name.value.length > 32) {
          alert('Numele trebuie sa contina 3-32 caractere.');
          return false;
        }

        if (frm.email.value == '') {
          alert('Va rog introduceti adresa dumneavoastra de email.');
          return false;
        }        
        var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/i;
        if (frm.email.value.match(re) == null) {
          alert('Adresa de email introdusa este invalida.');
          return false;
        }
        
        if (frm.captcha.value.length != 4) {
          alert('Va rog introduceti codul din imagine.');
          return false;
        }
}

function selfClean (element, defaultValue) {
        if (element.value == defaultValue) element.value='';
}
// --- Search Box in Admin
function validateSearch(frm) {
  if (frm.query.value == '') {
    alert('Va rog introduceti textul cautat.');
    return false;
  }
  if (frm.query.value.length < 4) {
    alert('Textul cautat trebuie sa contina minim 4 caractere.');
    return false;
  }
}


$(document).ready(
        function() {
		if ($('#slideshow')) {
			$('#slideshow').cycle({
				fx:     'fade',
				speed:  'slow',
				timeout: 2500,
				pager:  '#pager',
				slideExpr: 'img'
			});
		}
		
		$('#ticker').cycle({ 
    		fx:     'scrollLeft', 
    		timeout: 5000, 
    		delay:  -1500,
    		next : "#tnext",
    		pause : 1,
    		prev : "#tback"
		});
		$("#tstop").click(
			function()
			{
				$('#ticker').cycle('pause');
			}
		);
                
		if ($('#portal-slide-elements')) {
	                $("#portal-slide-elements").cycle({
	                	speed:  'fast',
	                	timeout: 0,
	                	pager:  '#portal-slide-elements-list',
	                	pagerEvent:'mouseover',
	                	pagerAnchorBuilder: function(idx, slide) {
	                		return '#portal-slide-elements-list li:eq(' + idx + ') a';
	                	}
	                });
			$('#portal-slide-elements-list ul li a').click(function() { 
        			window.open($(this).attr('href'),'_blank');
	    		}); 
		}

                $('#gallery-container-single a').lightBox();
                $('#gallery-container-multi a').lightBox();
                
        }
);

