/*------------------------------------------------------------------------------------------------*

 * The following function is used to validate the Y E A R s in the publication maintenance screen *

 *------------------------------------------------------------------------------------------------*/

function validatePubYears(objRef) {

  var msg = "";

  var frmObj = objRef.form;

  var elementName = "";

  var elementValue = objRef.value;



  if(objRef.name == "inpPubYear") {

    elementName = "Year of Publication";

  } else if(objRef.name == "inpFSFrom") {

    elementName = "FS From";

  } else if(objRef.name == "inpFSTo") {

    elementName = "FS To";

  } else if(objRef.name == "inpYrRev1") {

    elementName = "1<sup>st</sup> Year of Revision";

  } else if(objRef.name == "inpYrRev2") {

    elementName = "2<sup>nd</sup> Year of Revision";

  }



  if(!isYear(elementValue)) {

    msg = "<li class='errorMsg'>" + elementName + " is not a valid year</li>";

  } else {

    if(frmObj.inpFSFrom.value != "" && frmObj.inpFSTo.value != "") {

      if(frmObj.inpFSFrom.value * 1 >= frmObj.inpFSTo.value * 1) {

        msg = msg + "<li class='errorMsg'>FS From must be less than FS To</li>";

      }

    }

    if(frmObj.inpPubYear.value != "" && frmObj.inpYrRev1.value != "") {

      if(frmObj.inpPubYear.value * 1 >= frmObj.inpYrRev1.value * 1) {

        msg = msg + "<li class='errorMsg'>1<sup>st</sup> Year of Revision must be greater than Year of Publication</li>";

      }

    }

    if(frmObj.inpPubYear.value != "" && frmObj.inpFSFrom.value != "") {

      if(frmObj.inpPubYear.value * 1 < frmObj.inpFSFrom.value * 1) {

        msg = msg + "<li class='errorMsg'>Year of Publication cannot be less than FS From</li>";

      }

    }

    if(frmObj.inpPubYear.value != "" && frmObj.inpYrRev2.value != "") {

      if(frmObj.inpPubYear.value * 1 >= frmObj.inpYrRev2.value * 1) {

        msg = msg + "<li class='errorMsg'>2<sup>nd</sup> Year of Revision must be greater than Year of Publication</li>";

      }

    }

    if(frmObj.inpYrRev2.value != "" && frmObj.inpYrRev1.value != "") {

      if(frmObj.inpYrRev1.value * 1 >= frmObj.inpYrRev2.value * 1) {

        msg = msg + "<li class='errorMsg'>1<sup>st</sup> Year of Revision must be less than 2<sup>nd</sup> Year of Revision</li>";

      }

    }

  }



  if(msg != "") {

    document.getElementById("errorDiv").innerHTML = "<ul>" + msg + "</ul>";

    canSubmit[0] = false;

  } else {

    canSubmit[0] = true;

  }

}



/*-----------------------------------------------------------------*

 * The following method is used to render E R R O R  M E S S A G E *

 *-----------------------------------------------------------------*/

function writeErrMsg(msg) {

  document.getElementById('errorDiv').innerHTML = '<ul><li class="errorMsg">' + msg + '</li></ul>';

}



/*-----------------------------------------------------------------------------*

 * The following method is used to render I N F O R M A T I O N  M E S S A G E *

 *-----------------------------------------------------------------------------*/

function writeInfoMsg(msg) {

  document.getElementById('errorDiv').innerHTML = '<ul><li class="infoMsg">' + msg + '</li></ul>';

}



/*---------------------------------------------------------------------------*

 * The following function is used to display the left navigation panel links * 

 *---------------------------------------------------------------------------*/

function writeLink(url, linkId, label) {

  if(url != "#" && url != "") {

    urls = url.split("#");

    if(urls.length == 1) {

      document.write('<a class="leftPaneLink" href="' + url + '?linkId=' + linkId + '" target="_top">' + label + '</a>');

    } else {

      document.write('<a class="leftPaneLink" href="' + urls[0] + '?linkId=' + linkId + '#' + urls[1]  +  '" target="_top">' + label + '</a>');

    }

  } else {

    document.write('<font class="leftPaneLink">' + label + '</font>');

  }

}



/*---------------------------------------------------------------------------------------------------*

 * The following function is used to validate the P R I C E D  R E P O R T  S E A R C H  S C R E E N *

 *---------------------------------------------------------------------------------------------------*/

function validatePricedReportSearchScreen(frmObj) {

  var msg = "";



  if((frmObj.inpAuthor.value == "") && (frmObj.inpTitle.value == "") && (frmObj.inpRegion.value == "") && (frmObj.inpComm.value == "") &&  (frmObj.inpFSFrom.value == "") && (frmObj.inpFSTo.value == "") && (frmObj.inpPriceFrom.value == "") && (frmObj.inpPriceTo.value == "")) {

    msg = msg + "Please specify atleast one search condition";

  }



  if(!isYear(frmObj.inpFSFrom.value)) {

    msg = msg + "<font class='messageLink'>FS From</font> - is not a valid year<br/>";

  }

  if(!isYear(frmObj.inpFSTo.value)) {

    msg = msg + "<font class='messageLink'>FS To</font> - is not a valid year<br/>";

  }

  if(!isAmount(frmObj.inpPriceFrom.value)) {

    msg = msg + "<font class='messageLink'>Price From</font> - is not a valid amount<br/>";

  }

  if(!isAmount(frmObj.inpPriceTo.value)) {

    msg = msg + "<font class='messageLink'>Price To</font> - is not a valid amount<br/>";

  }

  if(msg != "" ) {

    document.getElementById("errorDiv").innerHTML = msg;

  } else {

    frmObj.submit();

  }

}



/*-------------------------------------------------------------------------------------------------------------------------*

 * The following function is used to validat the U N P U B L I S H E D  R E P O R T  M A R I N E  S E A R C H  S C R E E N *

 *-------------------------------------------------------------------------------------------------------------------------*/

function validateUnpubReportMarineSearchScreen(frmObj) {

  var msg = "";



  if((frmObj.inpAuthor.value == "") && (frmObj.inpTitle.value == "") && (frmObj.inpToposheetNo.value == "") && (frmObj.inpLocation.value == "") && (frmObj.inpFolder.value == "") && (frmObj.inpNHO.value == "") && (frmObj.inpPriceFrom.value == "") && (frmObj.inpPriceTo.value == "") && (frmObj.inpLatFrom.value == "") && (frmObj.inpLatTo.value == "") && (frmObj.inpLongFrom.value == "") && (frmObj.inpLongTo.value == "") && (frmObj.inpTheme.value == "") && (frmObj.inpSubtheme.value == "") && (frmObj.inpState.value == "") && (frmObj.inpDistrict.value == "") && (frmObj.inpFSPFrom.value == "") && (frmObj.inpFSPTo.value == "")) {

    msg = msg + "Please specify atleast one search condition";

  }



  if(!isAmount(frmObj.inpPriceFrom.value)) {

    msg = msg + "<font class='messageLink'>Price From</font> - is not a valid amount<br/>";

  }

  if(!isAmount(frmObj.inpPriceTo.value)) {

    msg = msg + "<font class='messageLink'>Price To</font> - is not a valid amount<br/>";

  }

  if(!isYear(frmObj.inpFSPFrom.value)) {

    msg = msg + "<font class='messageLink'>FS From</font> - is not a valid year<br/>";

  }

  if(!isYear(frmObj.inpFSPTo.value)) {

    msg = msg + "<font class='messageLink'>FS To</font> - is not a valid year<br/>";

  }

  if(!isPositiveDecimal(frmObj.inpLatFrom.value)) {

    msg = msg + "<font class='messageLink'>Latitude From</font> - is not a valid data<br/>";

  }

  if(!isPositiveDecimal(frmObj.inpLatTo.value)) {

    msg = msg + "<font class='messageLink'>Latitude To</font> - is not a valid data<br/>";

  }

  if(!isPositiveDecimal(frmObj.inpLongFrom.value)) {

    msg = msg + "<font class='messageLink'>Longitude From</font> - is not a valid data<br/>";

  }

  if(!isPositiveDecimal(frmObj.inpLongTo.value)) {

    msg = msg + "<font class='messageLink'>Longitude To</font> - is not a valid data<br/>";

  }

  if(msg != "" ) {

    document.getElementById("errorDiv").innerHTML = msg;

  } else {

    frmObj.submit();

  }

}



/*----------------------------------------------------------------------------------------------------------------------------------*

 * The following function is used to validate the U N P U B L I S H E D R E P O R T S  G E N  &  C O A L   S E A R C H  S C R E E N *

 *----------------------------------------------------------------------------------------------------------------------------------*/

function validateUnpublishedRepGenCoalSearchScreen(frmObj) {

  var msg = "";

  

  if((frmObj.inpAuthor.value == "") && (frmObj.inpToposheetNo.value == "") && (frmObj.inpLocation.value == "") && (frmObj.inpLatFrom.value == "") && (frmObj.inpLatTo.value == "") && (frmObj.inpLongFrom.value == "") && (frmObj.inpLongTo.value == "") && ((frmObj.inpThemeGen.value == "") || (frmObj.inpThemeCoal.value == "")) && (frmObj.inpSubtheme.value == "") && (frmObj.inpStateDesc.value == "") && (frmObj.inpDistrictDesc.value == "") && (frmObj.inpFSPFrom.value == "") && (frmObj.inpFSPTo.value == "")) {

    msg = msg + "Please specify atleast one more search condition";

  }



  if(!isYear(frmObj.inpFSPFrom.value)) {

    msg = msg + "<font class='messageLink'>FS From</font> - is not a valid year<br/>";

  }



  if(!isYear(frmObj.inpFSPTo.value)) {

    msg = msg + "<font class='messageLink'>FS To</font> - is not a valid year<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLatFrom.value)) {

    msg = msg + "<font class='messageLink'>Latitude From</font> - is not a valid data<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLatTo.value)) {

    msg = msg + "<font class='messageLink'>Latitude To</font> - is not a valid data<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLongFrom.value)) {

    msg = msg + "<font class='messageLink'>Longitude From</font> - is not a valid data<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLongTo.value)) {

    msg = msg + "<font class='messageLink'>Longitude To</font> - is not a valid data<br/>";

  }



  if(msg != "" ) {

    document.getElementById("errorDiv").innerHTML = msg;

  } else {

    frmObj.submit();

  }

}


function validateUnpublishedRepGenCoalSearchScreen_New(frmObj) {

  var msg = "";

  

  if((frmObj.inpAuthor.value == "") && (frmObj.inpToposheetNo.value == "") && (frmObj.inpLocation.value == "") && (frmObj.inpLatFrom.value == "") && (frmObj.inpLatTo.value == "") && (frmObj.inpLongFrom.value == "") && (frmObj.inpLongTo.value == "") && ((frmObj.inpThemeGen.value == "") || (frmObj.inpThemeCoal.value == "")) && (frmObj.inpSubtheme.value == "") && (frmObj.inpState.value == "") && (frmObj.inpDistrictDesc.value == "") && (frmObj.inpFSPFrom.value == "") && (frmObj.inpFSPTo.value == "")) {

    msg = msg + "Please specify atleast one more search condition";

  }



  if(!isYear(frmObj.inpFSPFrom.value)) {

    msg = msg + "<font class='messageLink'>FS From</font> - is not a valid year<br/>";

  }



  if(!isYear(frmObj.inpFSPTo.value)) {

    msg = msg + "<font class='messageLink'>FS To</font> - is not a valid year<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLatFrom.value)) {

    msg = msg + "<font class='messageLink'>Latitude From</font> - is not a valid data<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLatTo.value)) {

    msg = msg + "<font class='messageLink'>Latitude To</font> - is not a valid data<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLongFrom.value)) {

    msg = msg + "<font class='messageLink'>Longitude From</font> - is not a valid data<br/>";

  }



  if(!isPositiveDecimal(frmObj.inpLongTo.value)) {

    msg = msg + "<font class='messageLink'>Longitude To</font> - is not a valid data<br/>";

  }



  if(msg != "" ) {

    document.getElementById("errorDiv").innerHTML = msg;

  } else {

    frmObj.submit();

  }

}



/*------------------------------------------------------------------------------------------------*

 * The following function is used to validate the P U B L I C A T I O N  S E A R C H  S C R E E N *

 *------------------------------------------------------------------------------------------------*/

function validatePublicationSearchScreen(frmObj) {

  var msg = ""; 



  if(frmObj.inpPubType.value == "") {

    msg = msg + "<li class='errorMsg'>Type - is a mandatory search condition</li>";

  }



  if((frmObj.inpNo.value == "") && (frmObj.inpPart.value == "") && (frmObj.inpVol.value == "") &&  (frmObj.inpPubYearFrom.value == "") && (frmObj.inpPubYearTo.value == "") && (frmObj.inpTitle.value == "")  && (frmObj.inpAuthor.value == "") && (frmObj.inpRegion.value == "")) {

    msg = msg + "<li class='infoMsg'>Please specify another search condition along with Type</li>";

  }



  if(!checkInteger(frmObj.inpNo.value)) {

    msg = msg + "<li class='errorMsg'>Number - is not a valid integer</li>";

  }

  if(!checkInteger(frmObj.inpPart.value)) {

    msg = msg + "<li class='errorMsg'>Part - is not a valid integer</li>";

  }

  if(!checkInteger(frmObj.inpVol.value)) {

    msg = msg + "<li class='errorMsg'>Volume - is not a valid integer</li>";

  }

  if(!isYear(frmObj.inpPubYearFrom.value)) {

    msg = msg + "<li class='errorMsg'>Publication Year From - is not a valid year</li>";

  }



   if(!isYear(frmObj.inpPubYearTo.value)) {

    msg = msg + "<li class='errorMsg'>Publication Year To - is not a valid year</li>";

  }



  if(msg != "" ) {

    document.getElementById("errorDiv").innerHTML = "<ul>" + msg + "</ul>";

  } else {

    frmObj.submit();

  }

}



function checkMandatory(formObj) {

  return true;

}

function hover(that,cName) { that.className = cName; }

var cur=-1;

function showAnswer(divId){ if(cur!=-1)document.getElementById(cur).style.display = 'none'; document.getElementById(divId).style.display = 'block'; cur=divId}

function openImageViewer(docTypeId, docId) {

 features = "top=0,left=0,height=300,width=400,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,status=no";

 window.open("/pls/portal/url/page/GSI_WEB/GSI_WEB_IMAGE_VIEWER?docTypeId=" + docTypeId + "&docId=" + docId, "_blank",features);

}

function openQuizAnswers() {

 features = "top=0,left=0,height=600,width=777,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,status=no";

 window.open("/pls/gsiptl/PKG_PTL_UTILITY.pGenerateHeaderDetailPage?inpProcedureName=MaintainGeoQuizAnswer&inpScreenMode=U&inpValues="+document.forms[0].inpDtlId.value,"_blank",features);

}

function openEmp(targets) {

features = "top=0,left=0,height=600,width=700,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no";

window.open("/pls/gsiptl/PKG_PTL_PHOTO_GALLERY.pEmployeeLov?inpTargets=" + targets, "_blank", features);

}

function openSULov(targets) {

features = "top=0,left=0,height=600,width=700,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no";

window.open("/pls/gsiptl/PKG_PTL_PHOTO_GALLERY.pSpecialUserLov?inpTargets=" + targets, "_blank", features);

}



function checkName(val) {

  re = /^[A-Za-z][A-Za-z\. ]*$/;

  return( re.test(val) || (val == "") )

}

function isDate(val) {

  reDate = /^\d{2}\/\d{2}\/\d{4}$/;

  if(val != '' && !val.match(reDate)) {

    return false;

  } else {

    day = val.substring(0,2);

    mon = val.substring(3,5);

    year = val.substring(6,10);

    if(eval(mon) > 12) {

      return false;

    } else {

      if( mon == '04' || mon == '06' || mon == '09' || mon == '11')

        return (day <= 30);

      if( mon == '01' || mon == '03' || mon == '05' || mon == '07' || mon == '08' || mon == '10' || mon == '12')

        return (day <= 31);

      if(mon == 2) {

        if( (year % 100) == 0) {

          if( (year % 400) == 0)

            return (day <= 29);

          else

            return (day <= 28);

        }

        if( (year % 4) != 0)

          return (day <= 28);

        else

          return (day <= 29);

      }

    }

  }

  return true;

}

function openUploadScreen(type, key, storeFlag, docId, docType, multipleFlag) {

features = 'top=0,left=0,height=200,width=500,location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no,status=no';

url = '/gsi/OpenUploadDialog.do?type=' + type + '&key=' + key + '&storeFlag=' + storeFlag + '&docId=' + docId + '&docType=' + docType + '&multipleFlag=' + multipleFlag;

window.open(url,'_blank',features);

}

function checkFormFields1(val) {

  var formObj = document.forms[val];

  var okStatus = false;

  for( i = 1; i < formObj.elements.length; i++) {

    if( (formObj.elements[i].value != "") && (formObj.elements[i].type != "button") && (formObj.elements[i].type != "reset") && (formObj.elements[i].type != "hidden") ) {

      okStatus = true;

      break;

    }

  }

  if(!okStatus)

    alert("Atleast another search criteria needs to be entered!");

  return okStatus;

}

function checkFormFields(val) {

  var formObj = document.forms[val];

  var okStatus = false;

  for( i = 0; i < formObj.elements.length; i++) {

    if( (formObj.elements[i].value != "") && (formObj.elements[i].type != "button") && (formObj.elements[i].type != "reset") && (formObj.elements[i].type != "hidden") ) {

      okStatus = true;

      break;

    }

  }

  if(!okStatus)

    alert("Atleast one search criteria needs to be entered!");

  return okStatus;

}

function isYearMonth(val) {

  reYearMonth = /^\d{2}-\d{1,}$/;

  if(val != '' && !val.match(reYearMonth))

    return false;

  if( eval(val.substring(0,2)) > 12)

    return false;

  return true;

}



/*----------------------------------------------------------*

 * The following function is used to validate N U M E R I C *

 *----------------------------------------------------------*/

function isNumeric(val) {

  if(val != "" && isNaN(val)) {

    return false;

  }

  return true;

}



/*----------------------------------------------------*

 * The following function is used to validate Y E A R *

 *----------------------------------------------------*/

function isYear(val) {

  re = /^[1-9][0-9]{3}$/;

  return((re.test(val)) || (val == ""));

}



/*--------------------------------------------------------*

 * The following function is used to validate A M O U N T *

 *--------------------------------------------------------*/

function isAmount(val) {

  re = /^\d+(\.\d{2})?$/;

  return((re.test(val)) || (val == ""));

}



/*---------------------------------------------------------------------------*

 * The following function is used to check whether value_1 >= value_2 or not *

 *---------------------------------------------------------------------------*/

function isGreaterEqual(value_1, value_2) {

  if((value_1 == "") || (value_2 == "")) {

    return true;

  }

  first = value_1 * 1;

  second = value_2 * 1;

  if(first >= second) {

    return true;

  } else {

    return false;

  }

}



/*-------------------------------------------------------------*

 * The following function is used to check I N T E G E R value *

 *-------------------------------------------------------------*/

function checkInteger(val) {

  re = /^[1-9][0-9]*$/;

  return((re.test(val)) || (val == ""));

}



/*----------------------------------------------------------------------*

 * The following function is used to check P O S I T I V E  N U M B E R *

 *----------------------------------------------------------------------*/

function isPositiveDecimal(val) {

  if(isNumeric(val) && val >= 0) {

      return true;

  } else {

    return false;

  }

}



/*---------------------------------------------------------------------------------------*

 * The following procedure is used as the onload action of F A Q  M A I N T A I N screen *

 *---------------------------------------------------------------------------------------*/

function onLoadFAQ() {

  if(document.forms[0].inpHdrId != null) {

    frmObj = document.forms[0];

    if(frmObj.inpHdrId.value == "") {

      frmObj.inpMail.disabled = true;

      frmObj.inpAssign.disabled = true;

      frmObj.inpStatus.disabled = true;

      frmObj.inpStatus.className = "locked";

      frmObj.inpStatus.value = "N";

    } else {

      frmObj.btnSubmit.value = "Update";

      if(frmObj.inpPostedBy.value == "") {

        frmObj.inpMail.disabled = true;

      }

      if(frmObj.inpAssignedTo.value != "") {

        frmObj.inpAssign.value = "Reassign";

      }

    }

  }

}



/*-------------------------------------------------------------------------------------------------------------------*

 * The following procedure is used as the onload action of F E E D B A C K  &  C O N T A C T  M A I N T A I N screen *

 *-------------------------------------------------------------------------------------------------------------------*/

function onLoadFeedbackContact() {
  if(document.forms[0].inpHdrId != null) {
    /*if(document.forms[0].inpReqType.value == 'F') {
      document.forms[0].inpAssign.disabled = true;
	  document.forms[0].inpAssign.disabled = false;
    } else {*/
      if(document.forms[0].inpEmpNo.value != '') {
        document.forms[0].inpAssign.value = 'Reassign';
     /*}*/
    }
  }
}


function isEmpty (strfield){

if (strfield == "" || strfield == null){

alert(" is a mandatory field.\nPlease enter some value.");}}

function isValidEmail(inpEmail){

validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

strEmail = document.forms[0].inpEmail.value;

if (strEmail.search(validRegExp) == -1){

alert("A valid e-mail address is required.\nPlease amend and retry");}}

function checkRequired(frmObj){

for (i=0; i<frmObj.elements.length; i++){

if (frmObj.elements[i].className=="required") {

if (frmObj.elements[i].value == "" || frmObj.elements[i].value == null){

alert("Please enter a value for mandatory field."); frmObj.elements[i].focus(); return false;}}

}return true}

function openUrl(url) {

  var features = "top=0,left=0,height=600,width=800,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no";

  window.open(url,"_blank", features);

}

NS4=(document.layers) ? true : false;function isEnterPressed(event){ var code = 0; if (NS4) code = event.which; else code = event.keyCode; if (code==13) {return true} return false; }



function openTreeScreen(strfield) {

//features = 'top=0,left=0,height=600,width=500,location=no,menubar=yes,resizable=no,scrollbars=yes,toolbar=yes,status=yes';

features = 'top=0,left=0,height=600,width=500,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no,status=no';

url = '/gsi/OpenTreeScreen.do?name=GSI-Site&target='+ strfield + '&startFrom=90';

window.open(url,'_blank',features);

}



function openFSPUploadScreen(type, key, storeFlag, docId, docType, multipleFlag,region) {

features = 'top=0,left=0,height=250,width=500,location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no,status=no';

url = '/gsi/OpenFSPUploadDialog.do?type=' + type + '&key=' + key + '&storeFlag=' + storeFlag + '&docId=' + docId + '&docType=' + docType + '&multipleFlag=' + multipleFlag + '&region=' + region;

window.open(url,'_blank',features);

}

///Added by Prashanta on 13-07-10 for upload file for Tour
function openTourUploadScreen(type, key, storeFlag, docId, docType, multipleFlag, tourFlag) {

features = 'top=0,left=0,height=250,width=500,location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no,status=no';

url = '/gsi/OpenTourUploadDialog.do?type=' + type + '&key=' + key + '&storeFlag=' + storeFlag + '&docId=' + docId + '&docType=' + docType + '&multipleFlag=' + multipleFlag + '&tourFlag=' + tourFlag;

window.open(url,'_blank',features);

}
//End of addition by Prashanta



function openFolderTreeScreen(strfield) {

features = 'top=0,left=0,height=600,width=700,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no,status=yes';

url = '/gsi/OpenFolderTreeScreen.do?name=Folder-Tree&target='+ strfield;

window.open(url,'_blank',features);

}

function isValidEmailId(inpEmail){

validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

strEmail = document.forms[0].inpEmail.value;

if (strEmail.search(validRegExp) == -1){

document.forms[0].inpEmail.value = "";alert("A valid e-mail address is required.\nPlease amend and retry");}}





function openEmpMultiSelection(targets) {

features = "top=0,left=0,height=600,width=700,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no";

window.open("/pls/gsiptl/PKG_PTL_PHOTO_GALLERY.pEmployeeLovMultiSelection?inpTargets=" + targets, "_blank", features);

}

function isValidEmailId_New(inpEmail){

validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
validRegExp2 = /gsi.gov.in/i;

strEmail = document.forms[0].inpEmail.value;
if (document.forms[0].inpOccupation.value=='')
{
document.forms[0].inpEmail.value = "";
alert("Please select Occupation first!");
}

else if (document.forms[0].inpOccupation.value==1014 && (strEmail.search(validRegExp2) == -1))
{
document.forms[0].inpEmail.value = "";
alert("Please enter your GSI Email address");
}

else if (strEmail.search(validRegExp) == -1){

document.forms[0].inpEmail.value = "";alert("A valid e-mail address is required.\nPlease amend and retry");
}

}


function openOutsideGSILOV(targets) {

features = "top=0,left=0,height=600,width=700,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no";

window.open("/pls/gsiptl/PKG_PTL_PHOTO_GALLERY.pMoMMultiSelectionOutsideGSI?inpTargets=" + targets, "_blank", features);

}

function viewDocLinks(reportId,reportType) {
 var features = "top=0,left=0,height=200,width=500,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no";
     updateWin = window.open("/pls/gsipub/PKG_PTL_TOUR_PAGES.pViewTourDocLinks?inpDocId="+reportId+"&inpDocType="+reportType, "_blank", features);
   }

function checkCommentLength() {
         if(document.forms[0].inpComment.value.length > 3500) {
          document.forms[0].inpComment.value = "";
          alert("Comment cannot be more than 3500 characters!");
         } 
      }

function viewTourCityDtl(TourId) {
 var features = "top=0,left=0,height=400,width=500,location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no";
     updateWin = window.open("/pls/gsipub/PKG_PTL_TOUR_PAGES.pViewTourCityDetails?inpTourId="+TourId, "_blank", features);
   }

function  viewTourPrintableVer(TId) {
 var features_printable = "top=0,left=0,height=600,width=800,location=no,menubar=no,resizable=no,scrollbars=yes,toolbar=no";
	window.open("/pls/gsipub/PKG_PTL_TOUR_PAGES.pGetPrintableTourReasDtls?inpTourId="+TId, "_blank", features_printable);
  }

function getDateObject(dateString,dateSeperator)
{
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;
	curPos=dateString.indexOf(sepChar);
	cDate=dateString.substring(0,curPos);
	endPos=dateString.indexOf(sepChar,curPos+1);
    cMonth=dateString.substring(curPos+1,endPos);
	curPos=endPos;
	endPos=curPos+5;
	cYear=curValue.substring(curPos+1,endPos);
	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);
	return dtObject;
}

function onloadTour(){
     var currentTime = new Date();
     var month = currentTime.getMonth()+1;
     var day = currentTime.getDate();
     var year = currentTime.getFullYear();
     var curDate= month + "/" + day + "/" + year;
      toDateCurDate= new Date(curDate);
      toDateEnddate= new Date(document.forms[0].inpTourEDate.value);
     if (document.forms[0].inpStatus.value=='APV' && toDateCurDate>toDateEnddate){
     document.forms[0].inpSubReport.style.display = 'block';
    }
     else{
     document.forms[0].inpSubReport.style.display = 'none';
     }
     }