function FormFocus(obj) {
	if(obj.value==obj.defaultValue) obj.value='';
}

function FormBlur(obj) {
	if(obj.value=='') obj.value=obj.defaultValue;
}

function FormSubmit(form){
	  document.getElementById(form).submit(); return false;
}

function q(){
	if(document.getElementById("q").value!="")
	{
		//FormSubmit("search");
		document.getElementById("search").submit(); 
		return false;
	}else{
		return false;
	}
}
	
function addToNewsletter(lang){

	var r = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;	
	
	if($("n").value!="your e-mail here")
	{
		if( !r.test( $("n").value ) )
		{
			alert("incorect e-mail!"); 
			return false;
		}
		else
		{

			new Ajax.Request('/'+lang+'/member/addtonewsletter/', 
								{ 
									onComplete:function(){$("n").value="your e-mail here"; alert("Succes");},								
									parameters: $("newsletter").serialize(true) 
								}
							);
							
		}					
	
	}
	else
	{
		return false;
	}
	
}

function changePicture(photo){	
	if(photo=="n"){ current = current+1; }
	else if(photo=="p"){ current = current-1; }

	
	if(current > (count-1)){ current = current-1; }
	else if(current < 0){ current = 0; }

	next = current+1;
	previous = current-1;
	
	if(previous<0){ $("p").className = "off"; }
	else{ $("p").className = "on"; }
	
	if(next>=count){ $("n").className = "off"; }
	else{ $("n").className = "on"; }

	$("p_main").src = '/photo/thumbs/600_/1/'+ photos[current];	
	
	$("cp").innerHTML  = (current+1) + " / " + count;
}

function Key(){
	document.onkeydown = checkKeycode
}

function checkKeycode(e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	
	if(keycode == 80) { changePicture("p"); }
	else if(keycode == 78) { changePicture("n"); }
	else { void(0); }
}