	$(document).ready(function() {	
		$("#site-news").newsTicker();
		$("#site-events").newsTicker();
				
	   $('.titletovalue').attr('value', function() {
    		return (this.value == '' ? this.title : this.value);
 	   });    
 
   	   $('.titletovalue').blur(function() {
    		$(this).attr('value', function() {
     		 return (this.value == '' ? this.title : this.value);
   		 });
  	   });
 
 	   $('.titletovalue').focus(function() {
   		 $(this).attr('value', function() {
    		 return (this.value == this.title ? '' : this.value);
         });
       });
		
		$(".sublinks").hover(
		function () {
			$("#productthumb").attr("src",$(this).attr("name"));
  		}, 
  		function () {	});
		
		$(".grouplistlinks").hover(
		function () {
			$("#groupthumb").attr("src",$(this).attr("name"));
  		}, 
  		function () {	});
		
		$(".allprcatlinks").hover(
		function () {					
			$("#catthumb").attr("src",$(this).attr("name"));
			$("#all-prducts-img-preview").show();			
  		}, 
  		function () {
			$("#catthumb").attr("src","images/empty.png");
			$("#all-prducts-img-preview").hide();
		});
		
		$(".mmAllPr").hover(
			function () {				
			$("#menubelirtgec").css("display", "block" );
			//$("#products-content").css("filter:alpha",opacity=30);
  		}, 
  		function () {
			$("#menubelirtgec").css("display", "none" );
		});
		
	});
	
	featuredcontentglider.init({
		gliderid: "new-products-glidder", //ID of main glider container
		contentclass: "new-products", //Shared CSS class name of each glider content
		togglerid: "new-products-page-swap", //ID of toggler container
		remotecontent: "", //Get gliding contents from external file on server? "filename" or "" to disable
		selected: 0, //Default selected content index (0=1st)
		persiststate: false, //Remember last content shown within browser session (true/false)?
		speed: 500, //Glide animation duration (in milliseconds)
		direction: "leftright", //set direction of glide: "updown", "downup", "leftright", or "rightleft"
		autorotate: true, //Auto rotate contents (true/false)?
		autorotateconfig: [4000, 99] //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]
	})
	
	var prArea = featuredcontentglider;
	prArea.init({
		gliderid: "production-areas-glidder", //ID of main glider container
		contentclass: "aproductionarea", //Shared CSS class name of each glider content
		togglerid: "productionAreas", //ID of toggler container
		remotecontent: "", //Get gliding contents from external file on server? "filename" or "" to disable
		selected: 0, //Default selected content index (0=1st)
		persiststate: false, //Remember last content shown within browser session (true/false)?
		speed: 500, //Glide animation duration (in milliseconds)
		direction: "rightleft", //set direction of glide: "updown", "downup", "leftright", or "rightleft"
		autorotate: true, //Auto rotate contents (true/false)?
		autorotateconfig: [10000, 99] //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]
	})
	function contactFormSubmit() {
		lang	=   document.getElementById("sitelang").value;
		
		var bDir = "";
		if (lang != "en") bDir = "../";
		
		$("#contactformresult").html("<img src='"+bDir+"images/loading.gif' alt='Loading'>");
		name	=	document.getElementById("contactname").value;
		cmail	=   document.getElementById("contactmail").value;
		cmessage	=   document.getElementById("contactmessage").value;
		
		$.ajax({									
			url: bDir+"ajax/sendmessage.php",	
			data: "lang="+lang+"&name="+name+"&email="+cmail+"&message="+cmessage,
			cache: false,
			success: function(html) {
				$("#contactformresult").html(html);
			}
		});
	}
	
	var listItemHeight = 22;	
	function setSubMenuTop(index,total) {
		mm = document.getElementById("sm"+index);				
		itemCount =  mm.childNodes.length;				
		
		imgPrevPos =  index * listItemHeight;
		
		if (index+itemCount > total) {
			//alert(total-index-itemCount);
			mm.style.marginTop = (total-index-itemCount-1) * listItemHeight +"px";
			imgPrevPos = (total-itemCount) * listItemHeight;
		}				
		
		fark = (total * listItemHeight) - (imgPrevPos + 184);				

		if (fark < 0) imgPrevPos = imgPrevPos+fark;			
		document.getElementById("all-prducts-img-preview").style.marginTop = imgPrevPos +"px";		
	}	
	
	function suggestToAFriend() {
		lang	=   document.getElementById("sitelang").value;
		
		var bDir = "";
		if (lang != "en") bDir = "../";
		name	=	document.getElementById("frename").value;
		cmail	=   document.getElementById("fremail").value;		
		pname	=   document.getElementById("p_name").value;
		pimg	=   document.getElementById("p_img").value;
		plink	=   document.getElementById("p_link").value;
		
		$("#suggest-internal").html("<img src='"+bDir+"images/loading.gif' alt='Loading'>");
		$.ajax({									
			url: bDir+"ajax/sendsuggestion.php",	
			data: "lang="+lang+"&2name="+name+"&email="+cmail+"&p_name="+pname+"&p_img="+pimg+"&p_link="+plink,
			cache: false,
			success: function(html) {
				$("#suggest-internal").html(html);
			}
		});
	}
	function isValidEmail(strEmail){
	  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	  //strEmail = document.forms[0].email.value;
	
	   // search email text for regular exp matches
		if (strEmail.search(validRegExp) == -1) 
	   {
		//  alert('A valid e-mail address is required.\nPlease amend and retry');
		  return false;
		} 
    return true; 
}

