//*  ==================================================================== 
//*  Edvantis Software inc.
//*  Copyright (c) 2005-2006 
//*
//*  All rights reserved. 
//*   ==================================================================== 
//*/

function check_login_form()
{
  jn=0;
  if (document.forms["login"].username.value==""){jn=1};
  if (document.forms["login"].passwd.value==""){jn=1};
  if (jn==0){document.forms["login"].submit();
             return true}
  if (jn==1){alert("There is no Login or Password entered!");
            return false}
}


function search_sbm() {
 if (document.forms["frm_search"].query.value == "") {
    alert("Search field is empty!");
    document.forms["frm_search"].query.focus();
    return false;
  } 
  if (document.forms["frm_search"].query.value.length < 2) {
    alert("The search string length is shorter of 2 symbols!");
    document.forms["frm_search"].query.focus();
    return false;
  }
  document.forms["frm_search"].submit();
  return true;
}


function search_sbm_google() {
 if (document.forms["frm_search"].q.value == "") {
    alert("Search field is empty!");
    document.forms["frm_search"].q.focus();
    return false;
  } 
  if (document.forms["frm_search"].q.value.length < 2) {
    alert("The search string length is shorter of 2 symbols!");
    document.forms["frm_search"].q.focus();
    return false;
  }
  document.forms["frm_search"].submit();
  return true;
}





function emailCheck(txt) {
 if (txt.indexOf("@")<2){
   alert("Sorry. This email address seems wrong. Please"
   +" check the prefix and '@' sign.");return false;
   }
tst=txt.substring(txt.indexOf("@"),txt.length)
  if (tst.indexOf(".")-tst.indexOf("@")<2){
   alert("Sorry. This email address seems wrong. Please"
   +" check the suffix for accuracy.");return false;
  }
  return true;
 }

function emailcode(email)
{
if (email != "") {
      ecd = "";
      for (i = 0; i < email.length; i++) {
        ecd += "&#" + String(email.charCodeAt(i)) + ";";
        };
      return ecd;
     };
  return false
};

function email (login, domain)
{
eml = login + "@" + domain;
return eml;
}


function emailwrite (login, domain)
{
document.write (emailcode(email(login, domain)));
}

function emailto (login, domain,sub)
{
eml = emailcode("mailto:") + emailcode(email(login, domain));

if (sub != "") eml += "?subject=" + sub;

window.location.href = eml;
}



 
function numericcheck(nr1,un){
  flg=0;
  str="";
  spc=""
  arw="";
  for (var i=0;i<nr1.length;i++){
   if (un>0) {cmp="0123456789-()+ ";}else{cmp="0123456789()#@&*%+|~_!=\/{};:^?<>";}
   tst=nr1.substring(i,i+1)
   if (un*(cmp.indexOf(tst))<0){
    flg++;
    str+=" "+tst;
    spc+=tst;
    arw+="^";
   }
   else{arw+="_";}
  }
  if (flg!=0){
   if ((spc.indexOf(" ")>-1)&&(un>0)) {
    str+=" and a space";
    }
   if (un>0){alert(nr1+"\r"+arw+"\rSorry. This entry must be a number. I found "
   +flg+" unacceptable: "+str+".");return false;}
   if (un<0) {alert(nr1+"\r"+arw+"\rSorry. This entry must be a text. I found "
   +flg+" unacceptable: "+str+".");return false;}
  }  if ((nr1.length<6)&&(un>0)) {alert(nr1+"\rSorry. This entry must be a real number. "); return false;}
     if ((nr1.length<1)&&(un<0)) {alert(nr1+"\rSorry. This entry must be a real text. "); return false;} 
  return true;
 }



function client_login_sbm() {
 if (document.forms["frm_client_login"].fld_login.value == "") {
    alert("Login field is empty!");
    document.forms["frm_client_login"].fld_login.focus();
    return false;
  } 
  if (document.forms["frm_client_login"].fld_login.value.length < 2) {
    alert("The Login string length is shorter of 2 symbols!");
    document.forms["frm_client_login"].fld_login.focus();
    return false;
  }


 if (document.forms["frm_client_login"].fld_passwd.value == "") {
    alert("Password field is empty!");
    document.forms["frm_client_login"].fld_passwd.focus();
    return false;
  } 
  if (document.forms["frm_client_login"].fld_passwd.value.length < 8) {
    alert("The Password string length is shorter of 8 symbols!");
    document.forms["frm_client_login"].fld_passwd.focus();
    return false;
  }
document.forms["frm_client_login"].submit();
  return true;
}




function request_sbm() {
 if (document.forms["frm_request"].fld_first_name.value == "") {
    alert("First Name field is empty!");
    document.forms["frm_request"].fld_first_name.focus();
    return false;
  } 
  if (document.forms["frm_request"].fld_first_name.value.length < 2) {
    alert("The First Name string length is shorter of 2 symbols!");
    document.forms["frm_request"].fld_first_name.focus();
    return false;
  }
  if (!numericcheck(document.forms["frm_request"].fld_first_name.value,-1)) {
    document.forms["frm_request"].fld_first_name.focus();
    return false;
  }



 if (document.forms["frm_request"].fld_last_name.value == "") {
    alert("Last Name field is empty!");
    document.forms["frm_request"].fld_last_name.focus();
    return false;
  } 
  if (document.forms["frm_request"].fld_last_name.value.length < 2) {
    alert("The Last Name string length is shorter of 2 symbols!");
    document.forms["frm_request"].fld_last_name.focus();
    return false;
  }
 if (!numericcheck(document.forms["frm_request"].fld_last_name.value,-1)) {
    document.forms["frm_request"].fld_last_name.focus();
    return false;
  }


 if (document.forms["frm_request"].fld_company.value == "") {
    alert("Company field is empty!");
    document.forms["frm_request"].fld_company.focus();
    return false;
  } 
  if (document.forms["frm_request"].fld_company.value.length < 2) {
    alert("The Company string length is shorter of 2 symbols!");
    document.forms["frm_request"].fld_company.focus();
    return false;
  }


 if (document.forms["frm_request"].fld_job.value == "") {
    alert("Job Title field is empty!");
    document.forms["frm_request"].fld_job.focus();
    return false;
  } 
  if (document.forms["frm_request"].fld_job.value.length < 2) {
    alert("The Job Title string length is shorter of 2 symbols!");
    document.forms["frm_request"].fld_job.focus();
    return false;
  }

 if (document.forms["frm_request"].fld_phone.value == "") {
    alert("Phone field is empty!");
    document.forms["frm_request"].fld_phone.focus();
    return false;
  } 
  if (document.forms["frm_request"].fld_phone.value.length < 2) {
    alert("The Phone string length is shorter of 2 symbols!");
    document.forms["frm_request"].fld_phone.focus();
    return false;
  }
 if (!numericcheck(document.forms["frm_request"].fld_phone.value,1)) {
    document.forms["frm_request"].fld_phone.focus();
    return false;
  }


if (document.forms["frm_request"].fld_email.value == "") {
    alert("Email field is empty!");
    document.forms["frm_request"].fld_email.focus();
    return false;
  } 
  if (!emailCheck(document.forms["frm_request"].fld_email.value)) {
    document.forms["frm_request"].fld_email.focus();
    return false;
  }


 if (document.forms["frm_request"].fld_textarea.value == "") {
    alert("Quastion textarea is empty!");
    document.forms["frm_request"].fld_textarea.focus();
    return false;
  } 
  if (document.forms["frm_request"].fld_textarea.value.length < 2) {
    alert("The Quastion string length is shorter of 2 symbols!");
    document.forms["frm_request"].fld_textarea.focus();
    return false;
  }

  document.forms['frm_request'].submit();
  return true;
}


function outliner(nm,nm2) {
   ch =  document.getElementsByName(nm);
   if (ch) {if (ch.item(0).className == "collapsed") {ch.item(0).className = "expanded";}
                          else{ch.item(0).className = "collapsed";}
                       }
   ch2 =  document.getElementsByName(nm2);
   if (ch2) {if (ch2.item(0).className == "win_expandable") {ch2.item(0).className = "win_expandable2";}
                          else{ch2.item(0).className = "win_expandable";}
                       }


}


function LogPosition(evt){

    if (NN4||NN6){
    LEFT=evt.screenX;
    TOP=evt.screenY-10;
    }
    else{
    LEFT=event.screenX;
    TOP=event.screenY-10;
    }

}



function ShowCalendar(CONTROL,START_YEAR,END_YEAR,FORMAT){

ControlToSet = eval(CONTROL);
StartYear = START_YEAR;
EndYear = END_YEAR;
FormatAs = FORMAT;

var strFeatures = "width=" + CalWidth + ",height=140" + ",left=" + LEFT + ",top=" + TOP;
var CalWindow = window.open("calendar.php","Calendar", strFeatures)
CalWindow.focus();
} //End Function

function SetDate(DATE)
{
	if (ControlToSet)
	{
		ControlToSet.value = DATE; 
	}
	ControlToSet = null;
	StartYear = null;
	EndYear = null;
	FormatAs = null;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500,left = 390,top = 262');");
}


function ShowImage(IMAGESRC, WIDTH, HEIGHT)
{
	var strFeatures = "width=" + WIDTH + ",height="+HEIGHT + 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left = 390,top = 262' ;
	CloseImage();
    	ImageWindow = window.open("index.php?image="+IMAGESRC,"Image", strFeatures)
 	ImageWindow.focus();
} 

function CloseImage()
{
  if (ImageWindow != null) 
       {
          ImageWindow.close();
       }
}

var NN4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
var NN6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
var TOP;
var LEFT;
if (NN4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = LogPosition;
var ImageWindow;

