﻿function Textareaonly(e){
    var key;
    var isCtrl = false;
    if(window.event) {
	    key = e.keyCode;
	    isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
	    key = e.which;
	    isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) return true;
	    keychar = String.fromCharCode(key);
    	
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=13 && unicode!=32 && unicode!=isCtrl){ //if the key isn't the backspace key (which we should allow)
    if ((unicode<40||unicode>57) && (unicode<65 || unicode>90) && (unicode<97 || unicode>122)) //if not a alphabet
    return false //disable key press
    }
}


function CountWords (this_field,span_num) {
    var char_count = this_field.value.length;
    if (char_count > 0) {
    if (char_count == 1) {
    charOrChars = " character";
    } else {
    charOrChars = " characters";
    }
    document.getElementById('word_count_span'+span_num).innerHTML = char_count+charOrChars;
    } else {
    document.getElementById('word_count_span'+span_num).innerHTML = '0 character';
    }
    }

    // function for limit text
    function limit_text_250(id,limit_val) {
    if(id.value.length > limit_val)
    id.value=id.value.substr(0,limit_val);
}



function AlphabetsNumbersSpaceonly(e){
    var key;
    var isCtrl = false;
    if(window.event) {
	    key = e.keyCode;
	    isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
	    key = e.which;
	    isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) return true;
	    keychar = String.fromCharCode(key);
    	
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=32 && unicode!=isCtrl){ //if the key isn't the backspace key (which we should allow)
    if ((unicode<48||unicode>57) && (unicode<65 || unicode>90) && (unicode<97 || unicode>122)) //if not a alphabet
    return false //disable key press
    }
}

function AlphabetsSpaceonly(e){
    var key;
    var isCtrl = false;
    if(window.event) {
    key = e.keyCode;
    isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
    key = e.which;
    isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) return true;
    keychar = String.fromCharCode(key);

    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=32 && unicode!=isCtrl){ //if the key isn't the backspace key (which we should allow)
    if ((unicode<65 || unicode>90) && (unicode<97 || unicode>122)) //if not a alphabet
    return false //disable key press
    }
}

function Emailsonly(e){
    var key;
    var isCtrl = false;
    if(window.event) {
	    key = e.keyCode;
	    isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
	    key = e.which;
	    isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) return true;
	    keychar = String.fromCharCode(key);
    	
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=45 && unicode!=46 && unicode!=95 && unicode!=isCtrl){ //if the key isn't the backspace key (which we should allow)
    if ((unicode<48||unicode>57) && (unicode<64 || unicode>90) && (unicode<97 || unicode>122)) //if not a alphabet
    return false //disable key press
    }
}

function AlphabetsNumbersonly(e){
    var key;
    var isCtrl = false;
    if(window.event) {
	    key = e.keyCode;
	    isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
	    key = e.which;
	    isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) return true;
	    keychar = String.fromCharCode(key);
    	
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=isCtrl){ //if the key isn't the backspace key (which we should allow)
    if ((unicode<48||unicode>57) && (unicode<65 || unicode>90) && (unicode<97 || unicode>122)) //if not a alphabet
    return false //disable key press
    }
}

function OnlyNumbersonly(e){
    var key;
    var isCtrl = false;
    if(window.event) {
	    key = e.keyCode;
	    isCtrl = window.event.ctrlKey
    }
    else if(e.which) {
	    key = e.which;
	    isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) return true;
	    keychar = String.fromCharCode(key);
    	
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8 && unicode!=isCtrl){ //if the key isn't the backspace key (which we should allow)
    if (unicode<48||unicode>57) //if not a alphabet
    return false //disable key press
    }
}

function on_key_press_enter(e) {
    var keyCode = (e.keyCode) ? e.keyCode : e.which;
    if (keyCode == '13'){
        window.location="VenueResult.aspx?st="+document.getElementById('tbSearch').value+"&s=Nothing&c=Nothing&t=Venue&mi=0&mx=0&a=1&vt=1&rt=0";
    }   
}