﻿function GetWidth() {
    var myWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
     } else if (document.documentElement && document.documentElement.clientWidth) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
     } else if (document.body && document.body.clientWidth) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
   }
   return myWidth - (myWidth * .2);
  
}

function GetHeight() {
    var myHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        //Non-IE
       myHeight = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        //IE 6+ in 'standards compliant mode'
       myHeight = document.documentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        //IE 4 compatible
      myHeight = document.body.clientHeight;
    }
    return myHeight -(myHeight * .2);
}


//Trimming the string
function trimAll(str) {
    str = str.replace(/^\s+/, '');
    for (var i = str.length - 1; i >= 0; i--) {
        if (/\S/.test(str.charAt(i))) {
            str = str.substring(0, i + 1);
            break;
        }
    }
    return str;
}

//Function to remove special characters like "$" and "," etc...
function filterNum(str) {
    re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
    return str.replace(re, "");
}



function TrimsURL(strurl) {
try {
    var strnewurl = filterNum(trimAll(strurl[0]));
    while (strnewurl.indexOf(' ') >= 0)
        strnewurl = strnewurl.replace(' ', '-');
    return strnewurl + ".aspx";
    }
    catch(e){}
}

//Validate Name
function ValidateName(strValue) {
    var objRegExp = /^[a-zA-Z. ]{1,25}/;
    //check for valid Name
    return objRegExp.test(strValue);
}
//Validate Mobile
function ValidateMobile(strValue) {
    var objRegExp = /^[0]?9[1-9]{1}[0-9]{8}$/;
    //check for valid Mobile No
    return objRegExp.test(strValue);
}

//Validate EmailId
function ValidateEmail(strValue) {
    var objRegExp = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    //check for valid email
    return objRegExp.test(strValue);
}
//Author:Manish Srivastava 
//Date :07-Nov-2009
//------------Function To Blank And Unblank TextBox--------------
function blank(a) { if (a.value == a.defaultValue) a.value = ""; }
function unblank(a) { if (a.value == "") a.value = a.defaultValue; }

//somesh

function clickButton(e, buttonid) {
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt) {
        if (evt.keyCode == 13) {
            bt.click();
            return false;
        }
    }
}
function taLimit(obj, e) {
    var taObj = obj;
    var unicode = e.keyCode ? e.keyCode : e.charCode
    unicode = e.keyCode;
    if (taObj.value.length >= 400 && unicode != 8 && unicode != 46 && unicode != 37 && unicode != 38 && unicode != 39 && unicode != 40) return false;
}
function taCount(obj, e) {
    var taObj = obj;
    if (taObj.value.length > 400)
        taObj.value = taObj.value.substring(0, 400);
}