function fnFormSub(pagid){
      if(pagid == '001'){
        document.forms[0].submit();
    }
    if(pagid == parseInt('002')){
        document.forms[1].submit();
    }
  }

function hideDiv() {
        document.getElementById('secondinnerdiv').style.display = 'none';
        document.getElementById('secondinnerdivforview').style.display = 'block';
}

/*function showDiv() {  
        document.sesvalfrm.submit();
}
function hideDiv1() {  
        document.sesvalhidefrm.submit();
}*/

function showDiv(datasource,sname) {  
    //document.sesvalfrm.submit();
    var url = sname+'/'+datasource;
    //alert(url);
    var options = {
         'sessval' : 1 
     };
     
     $.post(url, options,
      function (contents) {
        document.getElementById("secondinnerdiv").style.display = "block";
        document.getElementById("secondinnerdivforview").style.display = "none";
      }
     );
}
function hideDiv1(datasource,sname) {  
        //document.sesvalhidefrm.submit();
    var url = sname+'/'+datasource;
    var options = {
         'sessval' : 1 
     };
     
     $.post(sname+'/'+datasource, options,
      function (contents) {
        document.getElementById("secondinnerdiv").style.display = "none";
        document.getElementById("secondinnerdivforview").style.display = "block";
      }
     );
}


function showDiv1(){
    document.getElementById('secondinnerdiv').style.display = 'block';
    document.getElementById('secondinnerdivforview').style.display = 'none';
}
function getval(sortby,cattag){
    document.getElementById('sortby').value = sortby;
    document.getElementById('cattag').value = cattag;
    document.forms[0].submit();
}
function getpage(page,sortby,cattag){
    document.getElementById('pagenum').value = page;
    document.getElementById('sortby').value = sortby;
    document.getElementById('cattag').value = cattag;
    document.forms[0].submit();
}


function trim(str, chars) {
 return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
 chars = chars || "\\s";
 return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
 chars = chars || "\\s";
 return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function fnValidateEmailAddress(email) {
   
    if ( trim(email) == "" ) {
        alert ( "Please enter valid Email address" );
        return false;
    }
   
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
      alert('Please enter valid Email address');
      return false;
   }
   return true;
}
