var check=true;

var DateEr='incorrect date ';
//var del='Are you sure you want to delete this category?';
function checkincl(form,checkn,name,discr)
{
	if((eval('document.'+form+'.'+checkn+'.checked'))&&(eval('document.'+form+'.'+name+'.value==""')))
	{
	check=false;
	alert(discr);
	}
	else
	{
	check=true;
	}
}
function inarray(array,val)
{
var i
	for(i=0;i<array.length;i++)
	{
		if(array[i] == val)
		{
		return i;
		}
	}
return false;	
}
function checkform(param,nameparam,form)
{
if(check==true)
{
 if (eval('document.'+form+'.'+param+'.value')=="")
 {alert (fillfield+nameparam);
  check=false;

      eval('document.'+form+'.'+param+'.focus()');
 }
}
}

function checkform_message(message,param,form)
{
 if((eval('document.'+form+'.'+param+'.value')=="")&&(check==true))
 {
 alert (message);
 check=false;
 check_form=false;
 eval('document.'+form+'.'+param+'.focus()');
 }
 /*else
 {
	if ((eval('document.'+form+'.'+param+'.value!=""'))&&(check==false))
 	{
	check=true;
	}
	
 }*/

}

function checkformdate(param,nameparam,form,day)
{
if(check==true)
{
 if (eval('document.'+form+'.'+param+'.value')=="")
 {alert ("Please fill the field "+nameparam);
  check=false;

      eval('document.'+form+'.'+day+'.focus()');
 }
}
}
function attacheck(form,field,arext)
{
	var extcheck = true;
	var ext, path;
	path = eval('document.'+form+'.'+field+'.value');
	ext = path.substring((path.length-3),(path.length));
	if ((ext=="gif"||ext=="jpeg"))
	{check=true;}
	else
	{
	check=false;
	alert("Wrong file extension");
	}
}

function checkdate(day,month,year,form)
{
if(check==true)
{
day1=eval('document.'+form+'.'+day+'.value');
month1=eval('document.'+form+'.'+month+'.value');
year1=eval('document.'+form+'.'+year+'.value');
month3=(parseFloat(month1)-1);
	if((day1!="")&&(month1!="")&&(year1!=""))
	{
	dateObjectName = new Date(year1, month3, day1);
	month2=dateObjectName.getMonth();
		if(month3!=month2)
		{
    	check=false;
    	alert(DateEr);
    	eval('document.'+form+'.'+day+'.focus()');
		}
		else
		{
		check=true;
		//str=eval(year1+month1+day1);
		//eval('document.'+form+'.'+to+'.value='+str);	
		}
	}
	else
    {
      if((day1!="")||(month1!="")||(year1!=""))
      {
      alert(DateEr);
      check=false;
      eval('document.'+form+'.'+day+'.focus()');
      }
   
	}
}
}

function check2dates(form,from,to)
{
date_to=eval('document.'+form+'.'+to+'.value');
if(date_to!="")
{
date_from=eval('document.'+form+'.'+from+'.value');
from_day=date_from.slice(0,2);
temp=date_from.slice(3,date_from.length);
from_month=temp.slice(0,2);
from_year=temp.slice(3,temp.length);
to_day=date_to.slice(0,2);
temp=(date_to.slice(3,date_to.length));
to_month=temp.slice(0,2);
to_year=temp.slice(3,temp.length);

date_fromDate=new Date(from_year,from_month-1,from_day);
date_toDate=new Date(to_year,to_month-1,to_day);
	if(eval(date_fromDate)>eval(date_toDate))
	{
	alert(secondDate);
	check=false;
	}
	
}		
}

function confirmmy(field)
{
	if (confirm(del + field)) 
	{
	check=true;
	}
	else
	{
	check=false;
	}   
}
function checkvalueint(param,form,start,end)
{

  str= eval('document.'+form+'.'+param+'.value');
  if(str!="")
  {
      flag=checkint(str);
      if ((flag==false)||(str<start)||(str>end))
      {
       alert("Incorrect value");
       eval('document.'+form+'.'+param+'.focus()');
       check=false;
      }
  }
}
function checkvaluenoint(param,form,from,to)
{

  str= eval('document.'+form+'.'+param+'.value');
  if(str!="")
  {
      flag=checkint(str);
	  
      if (flag==true)
      {
       alert("Incorrect value");
       eval('document.'+form+'.'+param+'.focus()');
       check=false;
      }
  }
  else
  {
   alert("Please fill this field");
   eval('document.'+form+'.'+param+'.focus()');
   check=false;
  }
}
function checkint(str)
{
 n=parseInt(str);
 if (isNaN(n))
 {
     return false;}
 else
 {
 n="'"+n+"'";
 if ((n.length-2)!=str.length)
 {return false;}
 return true;
 }
}

function submitform_ex(form,action)
{
if (check==true)
{
eval('document.'+form+'.action="'+action+'"');		
eval('document.'+form+'.submit()');
var _form_holder = document.getElementById("navara_pdf_download_form");
_form_holder.style.display = 'none';
var to_hide_after_click = document.getElementById("to_hide_after_click");
to_hide_after_click.style.display = 'none';
var navara_pdf_download_form_message = document.getElementById("navara_pdf_download_form_message");
navara_pdf_download_form_message.style.display = 'inline';
}
check=true;
}



function submitform(form,action)
{
if (check==true)
{

eval('document.'+form+'.action="'+action+'"');		
eval('document.'+form+'.submit()');
}
check=true;
}

function submitformdel1(form,action,textl)
{

if( (check==true)&&(window.confirm(textl)))
{

eval('document.'+form+'.action="'+action+'"');		
eval('document.'+form+'.submit()');
}
check=true;
}

function submitformdel(form,action)
{

if( (check==true)&&(window.confirm(" Moechten Sie diese Veranstaltung wirklich loeschen?")))
{

eval('document.'+form+'.action="'+action+'"');		
eval('document.'+form+'.submit()');
}
check=true;
}


function checkmail(form,mail)
{
if (check==true)
{
	if (eval('document.'+form+'.'+mail+'.value')!="")
	{
	var s= eval('document.'+form+'.'+mail+'.value');
	var v=s.indexOf("@",1);
	var p=s.indexOf(".",3);
		if ((v==-1)||(p==-1))
		{
		alert(maildiscr);
		eval('document.'+form+'.'+mail+'.select()');
		eval('document.'+form+'.'+mail+'.focus()');
		check=false;
		}
	}
}
}

function checkmail_message(message,mail,form)
{
	var s= eval('document.'+form+'.'+mail+'.value');
	var v=s.indexOf("@",1);
	var p=s.indexOf(".",3);
		if( ((v==-1)||(p==-1))&&(check==true))
		{
		alert(message);
		eval('document.'+form+'.'+mail+'.select()');
		eval('document.'+form+'.'+mail+'.focus()');
		check=false;
		check_form=false;
		}
		/*else
		{
		check=true;
		}*/
	
}



var sw = screen.width/2;
var sh = screen.height/2;
var img='';
var i=0;

function time_out(el)
{
  h=img.height;
  w=img.width;
  s=img.src;
  wnn="wnd"+i;
  ttl=el;
	wnd=window.open("",wnn,"width="+ w+",height="+h+",status=0,toolbal=0,menubar=0,location=0,resizable=0,scrollbar=0");
	wnd.document.open();
	wnd.document.write("<html><head><title>Extranet</title></head><body onClick='self.close()' marginheight=0 marginwidth=0 leftmargin=0 topmargin=0><h1><img src='"+s+"'border=0></h1></body></html>"); 
	wnd.document.close();
  clearTimeout();
}
function newdoc(el)
{
 i++;
 el1=el;
 img= new Image();
 img.src=el;
 setTimeout("time_out(el1)",1000);
}
function seldisable(form,check,name)
{
	if(eval('document.'+form+'.'+check+'.checked'))
	{
	eval('document.'+form+'.'+name+'.disabled=false')
	}
	else
	{
	eval('document.'+form+'.'+name+'.disabled=true')
	}
}
//select


function getSelected(opt)
{     var intLoop;
      var selected = new Array();
      var index = 0;
	  len=eval(opt+'.length');
      for (intLoop=0; intLoop < len; intLoop++)
	  {
         if (eval(opt+'[intLoop].selected'))
		 {
            index = selected.length;
            selected[index] = new Object;
            selected[index].value = eval(opt+'[intLoop].value');
            selected[index].index = intLoop;
         }
      }
      return selected;
}
function fillBox(name,sel)
{
valname=eval("document.form1."+name+".value=''");
len=eval("document.form1."+sel+".length");
 for(var i=0;i<len;i++)
 {
  	if(i!=0) eval("document.form1."+name+".value += \",\"");
	eval("document.form1."+name+".value += \""+eval("document.form1."+sel+"["+i+"].value")+"\"");
 }
}

function loadselect(formn,opskey,opsval,selname,idx)
{

	while(eval('document.'+formn+'.'+selname+'.length >0'))
 	{
 	eval('document.'+formn+'.'+selname+'.options[document.'+formn+'.'+selname+'.length-1] = null');
 	}
	
	if(!opsval)
	{
	return;
	}
 	for(i=0;i<opsval.length;i++)
 	{	
	eval('document.'+formn+'.'+selname+'.options[document.'+formn+'.'+selname+'.length] = new Option("'+opsval[i]+'","'+opskey[i]+'")');
		if(opskey[i]==idx)
		{
		
		eval('document.'+formn+'.'+selname+'.selectedIndex='+i); 
		}
	}

}
 
function changeselect(formn,arraykey,arrayval,selname,selchange,num)
{
var us=new Array();
sel=getSelected('document.'+formn+'.'+selname);
	if (sel=="")
	{
	return;
	}
idx=sel[0].value;
maskey=arraykey[idx];
masval=arrayval[idx];
loadselect(formn,maskey,masval,selchange,num);
}

function enablecheck(form,obj)
{
	for(i=0;i<eval('document.'+form+'.elements.length');i++)
	{
	elem=eval('document.'+form+'.elements['+i+']'); 
		if(obj.checked)
		{
			if(elem.name=="mainperm_"+obj.value)
			{
			elem.disabled=false;
			}
			if(elem.name.indexOf("submenu_"+obj.value)>=0)
			{
			elem.disabled=false;
			enablecheck1(form,elem)
			}
		}
		else
		{
			if(elem.name=="mainperm_"+obj.value)
			{
			elem.disabled=true;
			}
			if(elem.name.indexOf("submenu_"+obj.value)>=0)
			{
			elem.disabled=true;
			enablecheck1(form,elem)
			}
		}
	}

}
function enablecheck1(form,elem)
{
permsub=eval('document.'+form+'.subperm_'+elem.value);
	for(j=0;j<permsub.length;j++)
	{
		if((elem.checked)&&(elem.disabled==false))
		{
		permsub[j].disabled=false;
		}
		else
		{
		permsub[j].disabled=true;
		}
	}
}
function _color(form,field,color)
{
eval('document.'+form+'.'+field+'.value="'+color+'"');
//alert('document.all.'+field+'.background-color="'+color+'"');
//eval('document.all.'+field+'.background-color=ffffff');
eval(field+'.style.background="'+color+'"');
}
function restore(what,form,action) {
   if (confirm("Are you sure you want to overwrite the database with the file " + what +  "?")) 
   {
   eval('document.'+form+'.action="'+action+'"');	
   eval('document.'+form+'.submit()');
  }
}



//check registration

function isEmail (s) {
if (isEmpty(s)) return false;
var i = 1;
var sLength = s.length;
while ((i < sLength) && (s.charAt(i) != "@"))
{ i++
}
if ((i >= sLength) || (s.charAt(i) != "@")) return false;
else i += 2;
while ((i < sLength) && (s.charAt(i) != "."))
{ i++
}
if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
else return true;
}
function isEmpty(s) {
return ((s == null) || (s.length < 7))
}

function isProperEmail(string) {
var iChars = "*|,\":<>[]{}`\';()&$#%!?/";
for (var i = 0; i < string.length; i++) {
if (iChars.indexOf(string.charAt(i)) != -1)
return false;
}
return true;
}

function Form_Validator(formadduser,ln) 
{
	if (formadduser.name.value == "" || formadduser.name.value.length < 2) {
  		alert(err[ln]['name']);
  		formadduser.name.focus();
  	return (false);
	}
	
	if (!formadduser.gender[0].checked && !formadduser.gender[1].checked) {
  		alert( err[ln]['gender']);
  return (false);
  	} 
	if (formadduser.email.length <= 3) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  	return (false);
	}
	if (formadduser.email.value == "") {
 		alert(err[ln]['email']);
  		formadduser.email.focus();
  	return (false);
	}
	if (!isProperEmail(formadduser.email.value)) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  		formadduser.email.select();
  	return (false);
	}
	if (!isEmail(formadduser.email.value)) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  		formadduser.email.select();
  	return (false);
	}
	if (formadduser.company.value == "" || formadduser.company.value.length < 2) {
  		alert(err[ln]['company']);
  		formadduser.company.focus();
  	return (false);
	}
	if (formadduser.city.value == "" || formadduser.city.value.length < 2) {
  		alert(err[ln]['city']);
  		formadduser.city.focus();
  	return (false);
	}
	if (formadduser.zip.value == "" || formadduser.zip.value.length < 2) {
  		alert(err[ln]['zip']);
  		formadduser.zip.focus();
  	return (false);
	}
	if (formadduser.country.value == "" || formadduser.country.value.length < 2) {
  		alert(err[ln]['country']);
  		formadduser.country.focus();
  	return (false);
	}
	
	if (formadduser.address.value == "" || formadduser.address.value.length < 2) {
  		alert(err[ln]['address']);
  		formadduser.address.focus();
  	return (false);
	}
	
	return (true);
}
function Form_Validator1(formadduser,ln) 
{
	if (formadduser.cookie.value == "" || formadduser.cookie.value.length < 2) {
  		alert(err[ln]['cookie']);
  		formadduser.cookie.focus();
  	return (false);
	}
	if (!formadduser.agree.checked ){
  		alert( err[ln]['agree']);
  return (false);
  	} 
	
	
	return (true);
}
function Form_Validator_mobile(formadduser,ln) 
{
	if (formadduser.name.value == "" || formadduser.name.value.length < 2) {
  		alert(err[ln]['name']);
  		formadduser.name.focus();
  	return (false);
	}
	
	 
	if (formadduser.email.length <= 3) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  	return (false);
	}
	if (formadduser.email.value == "") {
 		alert(err[ln]['email']);
  		formadduser.email.focus();
  	return (false);
	}
	if (!isProperEmail(formadduser.email.value)) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  		formadduser.email.select();
  	return (false);
	}
	if (!isEmail(formadduser.email.value)) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  		formadduser.email.select();
  	return (false);
	}
	if (formadduser.company.value == "" || formadduser.company.value.length < 2) {
  		alert(err[ln]['company']);
  		formadduser.company.focus();
  	return (false);
	}
	
	if (formadduser.phone.value == "" || formadduser.phone.value.length < 2) {
  		alert(err[ln]['phone']);
  		formadduser.phone.focus();
  	return (false);
	}
	
	return (true);
}
function Form_Validator_partner_profile(formadduser,ln) 
{
	if ((formadduser.company.value == "") || (formadduser.company.value.length < 2)) {
  		alert(err[ln]['company']);
  		formadduser.company.focus();
  	return (false);
	}
	
	 
	
	
	if( (!isEmail(formadduser.email.value))||(formadduser.email.value == "")||(!isProperEmail(formadduser.email.value))) {
  		alert(err[ln]['email']);
  		formadduser.email.focus();
  		formadduser.email.select();
  	return (false);
	}
	if (formadduser.phone.value == "" || formadduser.phone.value.length < 2) {
  		alert(err[ln]['phone']);
  		formadduser.phone.focus();
  	return (false);
	}
	if (formadduser.address.value == "" || formadduser.address.value.length < 2) {
  		alert(err[ln]['address']);
  		formadduser.address.focus();
  	return (false);
	}
	if (formadduser.city.value == "" || formadduser.city.value.length < 2) {
  		alert(err[ln]['city']);
  		formadduser.city.focus();
  	return (false);
	}
	if (formadduser.state.value == "" || formadduser.state.value.length < 2) {
  		alert(err[ln]['state']);
  		formadduser.state.focus();
  	return (false);
	}
	if (formadduser.zip.value == "" || formadduser.zip.value.length < 2) {
  		alert(err[ln]['zip']);
  		formadduser.zip.focus();
  	return (false);
	}
	if (formadduser.country.value == "" || formadduser.country.value.length < 2) {
  		alert(err[ln]['country']);
  		formadduser.country.focus();
  	return (false);
	}
	if (formadduser.website.value == "" || formadduser.website.value.length < 2) {
  		alert(err[ln]['website']);
  		formadduser.website.focus();
  	return (false);
	}
	/*if (formadduser.company_description.value == "" || formadduser.company_description.value.length < 150) {*/
	if (formadduser.company_description.value == "" ) {	
		alert(err[ln]['company_description']);
  		formadduser.company_description.focus();
  	return (false);
	}
	if (formadduser.n_employee.value == "" || formadduser.n_employee.value.length < 2) {
  		alert(err[ln]['n_employee']);
  		formadduser.n_employee.focus();
  	return (false);
	}
	if (formadduser.market.value == "" || formadduser.market.value.length < 2) {
  		alert(err[ln]['market']);
  		formadduser.market.focus();
  	return (false);
	}
	if (formadduser.customers_type.value == "" || formadduser.customers_type.value.length < 2) {
  		alert(err[ln]['customers_type']);
  		formadduser.customers_type.focus();
  	return (false);
	}
	if (formadduser.geography.value == "" || formadduser.geography.value.length < 2) {
  		alert(err[ln]['geography']);
  		formadduser.geography.focus();
  	return (false);
	}
	if (formadduser.company_skills.value == "" || formadduser.company_skills.value.length < 2) {
  		alert(err[ln]['company_skills']);
  		formadduser.company_skills.focus();
  	return (false);
	}
	if (formadduser.remedy_expertise.value == "" || formadduser.remedy_expertise.value.length < 2) {
  		alert(err[ln]['remedy_expertise']);
  		formadduser.remedy_expertise.focus();
  	return (false);
	}
	if (formadduser.other_solutions.value == "" || formadduser.other_solutions.value.length < 2) {
  		alert(err[ln]['other_solutions']);
  		formadduser.other_solutions.focus();
  	return (false);
	}
	if (formadduser.primary_name.value == "" || formadduser.primary_name.value.length < 2) {
  		alert(err[ln]['primary_name']);
  		formadduser.primary_name.focus();
  	return (false);
	}
	if (formadduser.primary_title.value == "" || formadduser.primary_title.value.length < 2) {
  		alert(err[ln]['primary_title']);
  		formadduser.primary_title.focus();
  	return (false);
	}
	if (formadduser.primary_phone.value == "" || formadduser.primary_phone.value.length < 2) {
  		alert(err[ln]['primary_phone']);
  		formadduser.primary_phone.focus();
  	return (false);
	}
	if( (formadduser.primary_email.value == "")||(!isProperEmail(formadduser.primary_email.value))||(!isEmail(formadduser.primary_email.value))) {
 		alert(err[ln]['email']);
  		formadduser.primary_email.focus();
  	return (false);
	}
	
	if (formadduser.marketing_name.value == "" || formadduser.marketing_name.value.length < 2) {
  		alert(err[ln]['primary_name']);
  		formadduser.marketing_name.focus();
  	return (false);
	}
	if (formadduser.marketing_title.value == "" || formadduser.marketing_title.value.length < 2) {
  		alert(err[ln]['primary_title']);
  		formadduser.marketing_title.focus();
  	return (false);
	}
	if (formadduser.marketing_phone.value == "" || formadduser.marketing_phone.value.length < 2) {
  		alert(err[ln]['primary_phone']);
  		formadduser.marketing_phone.focus();
  	return (false);
	}
	if( (formadduser.marketing_email.value == "")||(!isProperEmail(formadduser.marketing_email.value))||(!isEmail(formadduser.marketing_email.value))) {
 		alert(err[ln]['email']);
  		formadduser.marketing_email.focus();
  	return (false);
	}
	
	if (formadduser.techn_name.value == "" || formadduser.techn_name.value.length < 2) {
  		alert(err[ln]['primary_name']);
  		formadduser.techn_name.focus();
  	return (false);
	}
	if (formadduser.techn_title.value == "" || formadduser.techn_title.value.length < 2) {
  		alert(err[ln]['primary_title']);
  		formadduser.techn_title.focus();
  	return (false);
	}
	if (formadduser.techn_phone.value == "" || formadduser.techn_phone.value.length < 2) {
  		alert(err[ln]['primary_phone']);
  		formadduser.techn_phone.focus();
  	return (false);
	}
	if( (formadduser.techn_email.value == "")||(!isProperEmail(formadduser.techn_email.value))||(!isEmail(formadduser.techn_email.value))) {
 		alert(err[ln]['email']);
  		formadduser.techn_email.focus();
  	return (false);
	}
	return (true);
}

var err=new Array();
err['en']=new Array();
err['nl']=new Array();
err['en']['name']='Please fill in your name.';
err['en']['gender']='Please select your gender.';
err['en']['email']='Please fill in a correct email address';
err['en']['company']='Please fill in your company name.';
err['en']['company_type']='Please select your company type.';
err['en']['state']='Please fill in your State.';
err['en']['city']='Please fill in your City.';
err['en']['zip']='Please fill in your Zip code.';
err['en']['country']='Please fill in your Country.';
err['en']['address']='Please fill in your Address.';
err['en']['website']='Please fill in Website.';
err['en']['is_remedy']='Please fill in Is your company a Remedy end user.';
err['en']['cookie']='Please fill in your cookie.';
err['en']['agree']='You should accept Conditions using the Navara Mobility Suite .';
err['en']['n_employee']='Please fill in No. of employees.';
err['en']['market']='Please fill in Markets served.';
err['en']['customers_type']='Please fill in Type of customers.';
err['en']['geography']='Please fill in Geographies served.';
err['en']['company_description']='Please enter Company description (100-150 words): for on the Navara website.';

err['en']['company_skills']='Please Describe company skill Areas.';
err['en']['remedy_expertise']='Please fill in Remedy / AR System Expertise.';
err['en']['other_solutions']='Please fill in Other solutions/applications supported .';
err['en']['primary_name']='Please fill in Name.';
err['en']['primary_title']='Please fill in Title.';
err['en']['phone']='Please fill in your Phone.';

err['en']['primary_phone']='Please fill in Phone.';

err['nl']['company']='Please fill in your company name.';
err['nl']['email']='Please fill in a correct email address';
err['nl']['name']='Please fill in your name.';
err['nl']['phone']='Please fill in your Telephone.';

function check_telephone(form, param, msg){
	
	if((eval('document.'+form+'.'+param+'.value')!="")&&(check==true)){
		
		phone = eval('document.'+form+'.'+param+'.value');
		phone_lenght = phone.length;
		for( i = 0; i < phone_lenght; i++ ){
			
			flag_digit = 'true';
			letter = phone.substr(i, 1);
			switch(letter){
				
				case '0': flag_digit = 'false'; break;
				case '1': flag_digit = 'false'; break;
				case '2': flag_digit = 'false'; break;
				case '3': flag_digit = 'false'; break;
				case '4': flag_digit = 'false'; break;
				case '5': flag_digit = 'false'; break;
				case '6': flag_digit = 'false'; break;
				case '7': flag_digit = 'false'; break;
				case '8': flag_digit = 'false'; break;
				case '9': flag_digit = 'false'; break;
				case '-': flag_digit = 'false'; break;
				case '/': flag_digit = 'false'; break;
				default : flag_digit = 'true';
			}
			if( flag_digit == 'true' ) {
				
				alert(msg);
				eval('document.'+form+'.'+param+'.focus()');
				return false;
			}
		}
		return true;		
	}
}

function showLostpass(idpass) {
   var x = document.getElementById(idpass);
   
   if(x.style.display == 'none') 
      x.style.display = '';
   else  x.style.display = 'none';
}

function downloadFile(filename) {
   window.open("/downloadform.php?dfile="+filename,"download","width=100,height=100,status=0,toolbal=0,menubar=0,location=0,resizable=0,scrollbar=0");
}

