function CheckSelect(variable,msg)
{
  for (i=0; ;i++)
  {
    thisVar = variable + '_' + i;
    obj = document.getElementById(thisVar);
    if (obj)
    {
      if (obj.checked)
        return true;
    }
    else
      break;
  }
  window.alert(msg);
  return false;
}

function CheckSearch(formObj,msg)
{
 if (document.forms[formObj].elements['keywords'].value == '')
 {
   window.alert(msg);
    return false;
 }
 else
  return true;
}

function CheckAll(element)
{
  for(i=0;;i++)
  {
  	var thisObj = document.getElementById(element+i);
  	if (!thisObj)
  	  break;
  	thisObj.checked=true; 
  }
  return;
}

function UncheckAll(element)
{
  var allObj = document.getElementById('all_'+element);
  var allVal = true;	
  for (i=0;;i++)
  {
  	var thisObj = document.getElementById(element+i);
  	if (!thisObj)
  	  break; 
  	else if(!thisObj.checked)
  	{
  	  allVal = false;	
  	  break;	
  	}
  }
  allObj.checked = allVal;
}

//Form Validation

function eCheckEMail(sn){
    s= sn.value;
    if (s.indexOf("@") == -1) return false;
    if (s.indexOf(".") == -1) return false;
    at=false;
    dot=false;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1);
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                if (ch == "@"){
                  if (at) return false;
                  else at=true;
                }
                if ((ch==".") && at)
                   dot=true;
        }
        else return false;
    }
   return dot;
}

function CheckEMail(theForm,theEmailFields,theMsg){
   for(var i=0; i<theEmailFields.length; i++)
         if (!eCheckEMail(theForm.elements[theEmailFields[i]])){
            alert(theMsg);
            theForm.elements[theEmailFields[i]].focus();
            return false;
        }
   return true;
}


function CheckRequiredFields(theForm,theRequiredFields,theMsg)
{
   for(i=0; i<theRequiredFields.length; i++)
        if(theForm.elements[theRequiredFields[i]].value==""){
            alert(theMsg);
            theForm.elements[theRequiredFields[i]].focus();
            return false;
        }
   return true;
}

function CheckForm(theForm,theEmailFields,theRequiredFields,theEmailMsg,theGlobalMsg){
     if(CheckRequiredFields(theForm,theRequiredFields,theGlobalMsg))
     if(CheckEMail(theForm,theEmailFields,theEmailMsg))
          return true;
  return false;
}

//End

/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=75

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

function changeLang()
{
  var obj = document.getElementById('chlang');
  var selectedVal = obj.options[obj.selectedIndex].value;
  
  if (selectedVal == "")
    return;
  
  location.href = selectedVal;  
}