function checkEnter(e){
var characterCode;// literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e;
characterCode = e.which; //character code is contained in NN4's which property
}
else{
e = event;
characterCode = e.keyCode; //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
searchSite(); //submit
return false;
}
else{
return true;
}
}

function searchSite() {
	var cc = document.getElementById("searchtxt").value;
	if (cc=="" || cc==null || cc.length<4 || cc=="cauta in site") {
		alert("Introduceti un text de cautare de minim 4 caractere");
	} else {
		top.location.href=baseURL+"cauta/?"+cc;
	}
}

function switchNews() {

	var cc = 1*document.getElementById("crntSS").value;
	var ncc = 0;
	if (cc==0) {
		ncc = 1;
	} else if (cc==5) {
		ncc = 1;
	} else {
		ncc = cc+1;
	}
	
	showSSnews2(ncc);
		
	var Timer_ID = setTimeout( "switchNews()", 3500);
	document.getElementById("crntTimer").value=Timer_ID;
	
}

function setElements() {

	var w = windowWidth();
	var x = 0;
	if (w<=1200) {
		x = 0;
	} else {
		var dif = (w-1000)/2;
		x = dif-100;
	}
	document.getElementById('logo').style.left=x+"px";
	
	var xx = 0;
	
	if (w<=1000) {
		xx = 700;
	} else {
		var dif2 = (w-1000)/2;
		xx = dif2+1000-280;
	}
	document.getElementById('search').style.left=xx+"px";
	
	document.getElementById('logo').style.display="block";
	document.getElementById('search').style.display="block";
}

function windowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

function windowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function showSSnews(x) {

	var tid = document.getElementById("crntTimer").value;
	clearTimeout(tid);

	document.getElementById("ssart1").style.display="none";
	document.getElementById("ssart2").style.display="none";
	document.getElementById("ssart3").style.display="none";
	document.getElementById("ssart4").style.display="none";
	document.getElementById("ssart5").style.display="none";
	
	document.getElementById("ssart"+x).style.display="block";
	document.getElementById("crntSS").value=x;
}

function showSSnews2(x) {

	document.getElementById("ssart1").style.display="none";
	document.getElementById("ssart2").style.display="none";
	document.getElementById("ssart3").style.display="none";
	document.getElementById("ssart4").style.display="none";
	document.getElementById("ssart5").style.display="none";
	
	document.getElementById("ssart"+x).style.display="block";
	document.getElementById("crntSS").value=x;
}

function validEmail(address) {

if (address.length==0) {
  return (true);
}
else
{
if (address.length>=6) {
if (address.indexOf("@")>0) {
if ((address.indexOf("@")+1)<address.lastIndexOf(".")) {
if (address.lastIndexOf(".")<(address.length-2)) {
return (true);
}
}
}
}
}
return (false);
}
