//*************************************************************************************************
function SP(){
  document.forms.mainform.action.value='SearchProduct';
  document.forms.mainform.submit();
}

//*************************************************************************************************
function S(){
  if (document.forms.mainform.searchstr.value.length<3){
    alert('Please enter min 3 chars !');
    document.forms.mainform.searchstr.focus();
  }else{
    document.forms.mainform.page.value='Search';
    document.forms.mainform.submit();
  }
}

var reEmail=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
var reText=/^([a-zA-Z0-9 \-']{2,30})+$/

//*************************************************************************************************
function validateFeedback(){  
  var ErrorMessage='';
  var FirstError='';
  if (!reText.test(document.forms.mainform.f_firstname.value)){
    ErrorMessage+="\n - First Name";
    if (FirstError=='') FirstError='f_firstname';
  }
  if (!reText.test(document.forms.mainform.f_lastname.value)){
    ErrorMessage+="\n - Last Name";
    if (FirstError=='') FirstError='f_lastname';
  }
  if (!reEmail.test(document.forms.mainform.f_email.value)){
    ErrorMessage+="\n - Email";
    if (FirstError=='') FirstError='f_email';
  }
  if (document.forms.mainform.f_comment.value==''){
    ErrorMessage+="\n - Comment";
    if (FirstError=='') FirstError='f_comment';
  }
  if (ErrorMessage==''){
    document.forms.mainform.action.value='SubmitContactRequest';
    document.forms.mainform.submit();
  }else{
    alert('You are required to complete the following fields: '+ErrorMessage);
    document.forms.mainform[FirstError].focus();
  }
}

//****************************************************************************************************************
function ListSearch(){
  if (document.forms.mainform.gotopage) {
    if (document.forms.mainform.gotopage.selectedIndex==0) {
      document.forms.mainform.SearchAll.value='1';
    }else{
      document.forms.mainform.page.value=document.forms.mainform.gotopage.value;      
    }
  }
  document.forms.mainform.DoSearch.value='1';
  document.forms.mainform.submit();
}

//*************************************************************************************************************
var ActiveMenuId=0;

function ShowMenu(DivId){
  clearTimeout(MenuTimer);
  if (DivId==ActiveMenuId) return;
  if (ActiveMenuId!=0) {
    AdministrateMaskIframe('SubMenu_'+ActiveMenuId,'Hide');
    document.getElementById('SubMenu_'+ActiveMenuId).style.visibility='hidden';
  }
  if (DivId!=0) {
    document.getElementById('SubMenu_'+DivId).style.visibility='visible';
    AdministrateMaskIframe('SubMenu_'+DivId,'Action');
  }
  ActiveMenuId=DivId;
  
}

var MenuTimer='';
//*************************************************************************************************************
function HideMenu(DivId){
  clearTimeout(MenuTimer)
  MenuTimer=setTimeout('doHideMenu()',2000)
}

//*************************************************************************************************************
function doHideMenu(){
  if (document.getElementById('SubMenu_'+ActiveMenuId)) {
    AdministrateMaskIframe('SubMenu_'+ActiveMenuId,'Hide');
    document.getElementById('SubMenu_'+ActiveMenuId).style.visibility='hidden';
  }
  ActiveMenuId=0;
}

//****************************************************************************************************************
function AdministrateMaskIframe(DivId,Action){
  var tmpDiv=document.getElementById(DivId);
  if (document.getElementById(DivId+'_iframe')){
    var tmpIframe=document.getElementById(DivId+'_iframe');
  }else{  
    var tmpIframe = document.createElement("iframe");
    document.body.appendChild(tmpIframe);
    tmpIframe.id=DivId+'_iframe';
  }
  if (Action=='Hide'){
    tmpIframe.style.display="none";
  }else{
    tmpIframe.style.width=tmpDiv.offsetWidth;
    tmpIframe.style.height=tmpDiv.offsetHeight;
    tmpIframe.style.top=tmpDiv.style.top;
    tmpIframe.style.left=tmpDiv.style.left;    
    tmpIframe.style.zIndex=tmpDiv.style.zIndex - 1;
    tmpIframe.style.display="block";
    tmpIframe.style.position='absolute';
 }
}