// JavaScript Document
function trim(string){
    return string.replace(/^\s*|\s*$/g,"");
}

function v_image(string) 
{
    if(string.match(/(.)+(\.){1}(jpeg|gif|png|jpg){1}$/i)){
      return true;
  }else{
      return false;
  }
}

function v_docFile(string) 
{
    if(string.match(/(.)+(\.){1}(doc|rtf|pdf){1}$/i)){
      return true;
  }else{
      return false;
  }
}


function v_url(string) 
{
    if(string.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i)){
      return true;
  }else{
      return false;
  }
}

function v_domain(string) 
{
    if(string.match(/^((ftp|http|https):\/\/){0,1}[a-z]+[a-z0-9\.\-]+[a-z]{2,4}$/i)){
        return true;
    }else{
        return false;
    }
}

function v_customUrl(string)
{
    var string = trim(string);
    if(string.match(/^[a-z]+[a-z0-9\.\-\/\_]*[a-z0-9]+$/i)){
        return true;
    }else{
        return false;
    }
}

function v_fileName(string){
    var string = trim(string);
    if(string.match(/^[a-z]{1}[a-z]{5,28}[a-z]{1}$/i)){
        return true;
    }else{
        return false;
    }
}


function v_email(string){
    if(trim(string).match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i)){
        return true;
    }
    return false;
}

function v_username(string){
        var string = trim(string);
        if(string.match(/^[a-z0-9][a-z0-9_]{4,23}[a-z0-9]$/i)){
          return true;
      }else{
          return false;
      }
}


function v_char(string){
   var string = trim(string);
     if(string.match(/(.)+/)){
        return true;
    }else{
        return false;
    } 
}

function v_commanChar(string){
    var string = trim(string);
     if(string.match(/^[a-z0-9]{1}[\w\,\(\)\:\s]{1,28}[a-z0-9]{1}$/i)){
        return true;
    }else{
        return false;
    } 
}

function v_alphaNumeric(string){
   var string = trim(string);
     if(string.match(/^[a-z0-9]+$/i)){
        return true;
    }else{
        return false;
    } 
}

function v_alphaNumericSpace(string){
   var string = trim(string);
     if(string.match(/^[a-z0-9]+[\sa-z0-9]+[a-z0-9]+$/i)){
        return true;
    }else{
        return false;
    } 
}

function v_name(string){
   var string = trim(string);
     if(string.match(/^[\w]+[\w\s\-\./']*[\w]+$/)){
        return true;
    }else{
        return false;
    } 
}
function v_address(string){
   var string = trim(string);
     if(string.match(/^[\w]+[\w\s\-/']*[\w]+$/)){
        return true;
    }else{
        return false;
    } 
}

function v_postalCode(string){
    var string = trim(string);
        if(string.match(/^[\w]+[\w\s]*[\w]+$/)){
        return true;
    }else{
        return false;
    }
}

function v_hour(string){
   if(string.match(/^[\w]+[\w\s\-\:]*[\w]+$/)){
        return true;
    }else{
        return false;
    } 

}
function v_phone(string){
    if(string.match(/^[\+]?[\s]?[\d]+?[\s]?[/]?[\s][\d\s\-]+[\d]+$/)){
        return true;
    }else{
        return false;
    }
}

function v_card(string){
    var string = trim(string);
        if(string.match(/^[\d]+[\d\s]{14,}[\d]+$/)){
        return true;
    }else{
        return false;
    }
}

function v_number(string){
    var string = trim(string);
        if(string.match(/^[\d]+$/)){
        return true;
    }else{
        return false;
    }
}

function v_float(string){
    var string = trim(string);
        var newV = parseFloat(string);
    if(newV == string){
        return true;
    }else{
        return false;
    }

}


function v_mobile(string){
   if(string.match(/^[\+]?[\d]+[\d\s]+[\d]+$/)){
        return true;
    }else{
        return false;
    }
}

function v_null(string){
   if(string==''){
        return false;
    }else{
        return true;
    }
}

function v_date(d,m,y)
{
    var yl=1990; 
    var ym=2050; 
    if (m<1 || m>12)
        return(false);
    if (d<1 || d>31) 
        return(false);
    if (y<yl || y>ym) 
        return(false);
    if (m==4 || m==6 || m==9 || m==11)
    if (d==31) 
        return(false);
    if (m==2)
    {
        var b=parseInt(y/4);
        if (isNaN(b))
            return(false);
        if (d>29)
            return(false);
        if (d==29 && ((y/4)!=parseInt(y/4))) 
            return(false);
    }
     return(true);
}

function v_compareDate(date,month,year)
{
if(month<10)
    {
        month='0'+month;
    }
    if(date<10)
    {
        date='0'+date;
    }
    var tempDate=year+month+date;
    return tempDate;
}

function showHide(stringId){
    var showHideStat = document.getElementById(stringId).style.display;
    if(showHideStat == 'none'){
        document.getElementById(stringId).style.display = 'block';
    }else{
        document.getElementById(stringId).style.display = 'none';
    }
}

function popup(pageUrl){
    window.open(pageUrl,'mypopup','width=400 height=50');

}

function goToUrl(urlString){
    document.location.href = urlString; 
}



function focusOn(filedName){

}
/* =========================================================================== */
/* =========================================================================== */
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert("Your browser is not updated?");
    }
}
//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();
//Called from any event.
//Starts the AJAX request.
function makeRequest(custom_url,custom_function) {
    if (searchReq.readyState == 4 || searchReq.readyState == 0) {
         searchReq.open("GET", custom_url, true);
        searchReq.onreadystatechange = custom_function; 
        searchReq.send(null);
    }        
}
/* =========================================================================== */
/* =========================================================================== */
function addOption(selectbox,text,value )
    {
        
        if (text)
        {           
            var optn = document.createElement("OPTION");
            optn.text = text;
            optn.value = value;
            selectbox.options.add(optn);
        }
    }
    
    function deleteOption(selectbox)
    {
        for (i = selectbox.length; i > 0 ; i--)
        {
            selectbox.remove(i);
        }
    }
/* =========================================================================== */
/* =========================================================================== */
    function resetForm(formObj)
    {
        formObj.reset();
        obj1 = formObj.getElementsByTagName('DIV'); 
        for(i = 0; i < obj1.length ; ++i) 
        {
            if(!(obj1[i].id == '') && obj1[i].id.match('_msg')) {
                document.getElementById(obj1[i].id).style.display = 'none';
            }
        }
    }
/* =========================================================================== */
/* =========================================================================== */


