// JavaScript Document

function SearchNews(){
	var searchText=$('#news').val();
	if($('#news').val()!=''){window.location='index.php?p=news&news='+searchText}
	else {alert('Search field is empty.'); return false;}
	}

function SearchModel(){
	
	var searchText=$('#Actor').val();
	if($('#Actor').val()!=''){window.location='index.php?p=models&Actor='+searchText}
	else {alert('Search field is empty.'); return false;}
	}
	
function SearchMaillists(){
	var searchText=$('#Maillist').val();
	if($('#Maillist').val()!=''){window.location='index.php?p=maillist&Maillist='+searchText}
	else {alert('Search field is empty.'); return false;}
	}

function SearchEditor(){
	
	var searchText=$('#Editor').val();
	if($('#Editor').val()!=''){window.location='index.php?p=editors&Editor='+searchText}
	else {alert('Search field is empty.'); return false;}
	}
	
function validateChangePwd(lang){	
	valiclass=field.getAttribute("valiclass");	
	valimessage=field.getAttribute("valimessage");
	idOfField=field.getAttribute("id");
	
	if(lang==''){
		if($("oldpass").val()=='')
			return displayStyleErr(idOfField,valimessage);	
		if(validPwd($("oldpass").val()))
			alert(1);
		}
	}
	
function validateAddEditUser(alreadyRegister){
	if(trim($("#user_name").val()).length<5){
		return displayStyleErr("user_name","Enter username of at least 5 characters.");				
		}	
	if(isValidEmail(trim($("#email").val()))==0){
		return displayStyleErr("email","Enter valid email address.");												
		}
	if(trim($("#password").val()).length<5 && ( alreadyRegister==0 || trim($("#password").val())!='')){
		return displayStyleErr("password","Enter password of at least 5 characters.");									
		}
	if(trim($("#password").val()) != trim($("#cpassword").val())){
		return displayStyleErr("cpassword","Password Mismatch.");									
		}	
	$("#save").val("true");
}

function chkNewsletterSend(){	
	var chk=CheckClicked();
	if(chk==0){
		alert('Bitte w&auml;hlen Sie die Benutzer.');
		return false;
	}
	else if($("#newsletterList").val()==0){
		alert('Bitte wählen Sie den Newsletter zu versenden.');
		return false;
		}
	else{
		document.getElementById('listitems').method="POST";
		document.getElementById('listitems').action="index.php?p=news-let";
		//document.getElementById('listitems').action="index.php?p=news-let-proces";
		document.getElementById('listitems').submit();		
	}
}


function SendNewsletter(){	

	var chk=ChkClicked();
	if(chk==0){
		
		alert('Bitte w&auml;hlen Sie die News.');
		return false;
	}
	
	else{
		document.getElementById('formNewsletter').method="POST";
		//document.getElementById('listitems').action="index.php?p=news-let";
		document.getElementById('formNewsletter').action="index.php?p=news-let-proces";
		document.getElementById('formNewsletter').submit();		
	}
}
