﻿ 
    // JScript File
isIE = document.all ? 1 : 0

function CheckNumaricValue(e) {
    keyEntry = !isIE ? e.which : event.keyCode;
    if (keyEntry >= '48' && keyEntry <= '57' || keyEntry == '0' || keyEntry == '8')
        return true;
    return false;
}

function CheckDecimalValue(e) {
    keyEntry = !isIE ? e.which : event.keyCode;
    var src = (e.srcElement) ? e.srcElement : e.target;

    if (keyEntry == 46) {
        val = src.value;
        if (val.indexOf('.') > -1)
            return false;
        return true;
    }
    if (CheckNumaricValue(e))
        return true;
    //event.returnValue = false;
    return false;
}

function CheckMultiDecimalValue(e) {
    keyEntry = !isIE ? e.which : event.keyCode;

    // 46 => .(dot)
    if (keyEntry == 46)
        return true;

    if (CheckNumaricValue(e))
        return true;

    //event.returnValue = false;
    return false;
}

function CheckCharacterValue(e) {
    keyEntry = !isIE ? e.which : event.keyCode;
    // A => 65
    // Z => 90
    // a => 97
    // z => 122
    if ((keyEntry >= '65' && keyEntry <= '90') || (keyEntry >= '97' && keyEntry <= '122'))
        return true;

    //event.returnValue = false;
    return false;
}

function CheckString(e) {
    keyEntry = !isIE ? e.which : event.keyCode;

    //if ((e.keyChar >= 'A' && e.keyChar <='Z') || (e.keyChar >= 'a' && e.keyChar <= 'z') || 
    //  (e.keyChar == '\'' || e.keyChar == '-') )

    //alert(keyEntry);
    if (CheckDecimalValue(e))
        return true;

    if (CheckCharacterValue(e))
        return true;

    if (keyEntry == '32' || keyEntry == '44') {
        return true;
    }
    else
        return false;

}

function CheckName(e) {
    keyEntry = !isIE ? e.which : event.keyCode;


    if (CheckMultiDecimalValue(e))
        return true;

    if (CheckCharacterValue(e))
        return true;
    // alert(keyEntry);
    // 32 =>  (Space)
    // 35 => #(Hash)
    // 39 => '(Single cot)
    // 44 => ,(Comma)
    // 45 => -(Dash)
    // 95 => _(Underscore)
    // 37 => % (Persant)
    // 60 => < (less than)
    // 62 => > (greater than)
    // 94 => ^ (caret), 36 => $, 35 => #
    //    if (keyEntry == '32' || keyEntry == '35' || keyEntry == '39' || keyEntry == '44' 
    //        || keyEntry == '45' || keyEntry == '95')
    if (keyEntry == '35' || keyEntry == '36' || keyEntry == '37' || keyEntry == '60' || keyEntry == '62' || keyEntry == '94') {
        return false;
    }
    else
        return true;
}

function CheckAddress(e) {
    keyEntry = !isIE ? e.which : event.keyCode;

    //alert(keyEntry);
    if (CheckMultiDecimalValue(e))
        return true;

    if (CheckCharacterValue(e))
        return true;

    // 32 =>  (Space)
    // 35 => #(Hash)
    // 39 => '(single cot)
    // 44 => ,(comma)
    // 45 => -(dash)
    // 47 => /(Forward slash)
    // 95 => _(underscore)
    if (keyEntry == '32' || keyEntry == '39' || keyEntry == '44'
        || keyEntry == '45' || keyEntry == '47') {
        return true;
    }
    else
        return false;
}




function CheckDescription(e) {
    keyEntry = !isIE ? e.which : event.keyCode;

    //alert(keyEntry);
    if (keyEntry == '35' || keyEntry == '36' || keyEntry == '37' || keyEntry == '60' || keyEntry == '62' || keyEntry == '94' || keyEntry == '13')
        return false;
    return true;
    //    if (CheckMultiDecimalValue(e))
    //        return true;
    //    
    //    if (CheckCharacterValue(e))
    //        return true;

    // 32 =>  (Space)
    // 35 => #(Hash)
    // 39 => '(single cot)
    // 44 => ,(comma)
    // 45 => -(dash)
    // 47 => /(Forward slash)
    // 95 => _(underscore)
    //    if (keyEntry == '32' || keyEntry == '37' || keyEntry == '39' || keyEntry == '44' 
    //        || keyEntry == '45' || keyEntry == '47' || keyEntry == '95')
    //    {
    //        return true;
    //    }
    //    else
    //        return false; 
}
function trim(str) {
    return str.replace(/^\s*|\s*$/g, "");
}
function CheckPhone(e) {
    keyEntry = !isIE ? e.which : event.keyCode;

    //alert(keyEntry);
    if (CheckNumaricValue(e))
        return true;

    //     44 => ,(Comma),
    //     45 => -(Dash)
    //     43 => +(Plus)
    //     40 => ( 
    //     41 => )
    if (keyEntry == '44' || keyEntry == '43' || keyEntry == '45' || keyEntry == '40' || keyEntry == '41') {
        return true;
    }
    else
        return false;
}
function validateDate(fld) {

    var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
    var errorMessage = 'Please enter valid date  dd/mm/yyyy.';
    if ((fld.match(RegExPattern)) && (fld.value != '')) { return true; } else { return false; }
}

function closeW() {
    if (navigator.appName == 'Netscape') {
        window.open('', '_self');
        window.close();
    }
    else {
        window.opener = '';
        window.close();
    }
}

function refreshParent() {


    window.opener.location.href = window.opener.location.href;
    window.opener.location.reload();
    if (window.opener.progressWindow) {
        window.opener.progressWindow.close()
    }
    window.close();
}
function isLogin(isLogin) {
    if (document.getElementById("ctl00_hdUser").value == "") {
        alert(isLogin);
        return false;
    }
    return true;
}

function popitup(url) {

    //var newwindow = window.open(url, 'name', 'width=800,height=1000,menubar=no,status=no,top=50,left=50,location=no,toolbar=no,scrollbars=yes');
    var newwindow = window.open(url, 'welcome', 'width=800,height=1000,top=50px,left=50px')
    if (window.focus) {
        newwindow.focus()
    }
    return false;
}
function printpopup(url) {

   // var newwindow = window.open(url, 'name', 'width=800,height=500,menubar=no,status=no,top=50,left=50,location=no,toolbar=no,scrollbars=yes');
    var newwindow = window.open(url, 'welcome', 'width=800,height=500,top=50px,left=50px')
    
    if (window.focus) {
        newwindow.focus()
    }
    return false;
}
function openFavouriteMessagewindowSize(page, pagename, touserid) {
    if (isLogin(pagename) == true) {

        if (document.getElementById("ctl00_hdUser").value.toLowerCase() == touserid.toLowerCase()) {
            alert("This is your own video , Please Choose another!");
            return false;

        }

        //window.open(page, pagename, 'width=560,height=400,top=220,left=230,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
        window.open(page, 'welcome', 'width=560,height=300,top=220px,left=230px,scrollbars=yes')
        return true;
    }
    return false;
}
function openFanMessagewindowSize(page, pagename, touserid) {
    if (isLogin(pagename) == true) {

        if (document.getElementById("ctl00_hdUser").value.toLowerCase() == touserid.toLowerCase()) {
            alert("This is your own video , Please Choose another!");
            return false;

        }

        //window.open(page, pagename, 'width=560,height=400,top=220,left=230,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
        window.open(page, 'welcome', 'width=560,height=300,top=220px,left=230px')
        return true;
    }
    return false;
}
function openLoginwindowSize(page, pagename) {
    

        //window.open(page, pagename, 'width=560,height=400,top=220,left=230,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
        window.open(page, 'welcome', 'width=560,height=350,top=220px,left=230px')

        return true;
    
}

function openwindowSize(page, pagename) {

    
    //window.open(page, pagename, 'width=400,height=250,top=250px,left=250px,menubar=no,status=no,location=no,fullscreen =no,resizable =no,toolbar=no,scrollbars=no');
    window.open(page, 'welcome', 'width=400,height=250,top=250px,left=250px')
    return true;

}
function openimagehelp(page, pagename) {



    //window.open(page, pagename, 'width=400,height=200,top=420,left=430,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
    window.open(page, 'welcome', 'width=400,height=200,top=420px,left=430px')
    return true;

}
function popprivacy(url) {

                var newwindow =  window.open(url, 'welcome', 'width=950,height=800,top=420px,left=430px')//window.open(url, 'name', 'width=950,height=800,menubar=no,status=no,top=50,left=50,location=no,toolbar=no,scrollbars=yes');
                if (window.focus) {
                    newwindow.focus()
                }
                return false;
                }
      
    function chkCharVl(e) {
        isIE = document.all ? 1 : 0
        KeyEntry = !isIE ? e.which : event.keyCode;
        if ((KeyEntry > 64 && KeyEntry < 91) || (KeyEntry > 96 && KeyEntry < 123) || KeyEntry == '0' || KeyEntry == '8' || KeyEntry == '9' || KeyEntry == '13' || KeyEntry == '32') {
            return true;
        }
        else {
            return false;
        }
    }
    function refreshParent() {


        window.opener.location.href = window.opener.location.href;
        window.opener.location.reload();
        if (window.opener.progressWindow) {
            window.opener.progressWindow.close()
        }
        window.close();
    }

    
    function HideText(id) {
        document.getElementById(id).style.display = 'none';
    }


    function getMessageBox(msg, middlebg, border,height) 
    {
        var str = "";
        str += "<div class='top-left-corner'><img src='contents/images/box-top-left_69.jpg' width='16' height='16' /></div><div class='top-middlebgh' style='width:" + middlebg + ";'  >&nbsp;</div>  <div class='top-right-corner'> <img src='contents/images/box-top-right_74.jpg' width='16' height='16' /></div><div id='border' style='width:" + border + ";height:" + height + "'><p class='class'>";
      str += msg;
        str += "</p></div><div class='bottom-left-corner'><img src='contents/images/box-bottom-left_93.jpg' width='16' height='16' /></div><div class='bottom-middle-bg' style='width:" + middlebg + ";'></div><div class='bottom-right-corner'><img src='contents/images/box-bottom-right_97.jpg' width='16' height='16' /></div>"

        return str;
    }   
    
    function ShowText(id) {
       
        document.getElementById(id).style.display = 'block';
    }


    function focusFormElement(id) {

        document.getElementById(id).style.display = "block";

    }

    function toggleErrors(id, bool) {
        document.getElementById(id).style.display = "none";
        if (bool == true) {
            document.getElementById(id).style.display = "block";
        }
    }
    //Function for validate Email addredd (Added By Akhilesh Jatav on 30Mar2010) 
    function validateEmailAddress(sEmailId) {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        if (reg.test(sEmailId) == false) {            
            return false;
        }
        return true;
    }
    //END Function for validate Email addredd (Added By Akhilesh Jatav on 30Mar2010)


    var BrowserDetect = {


        init: function() {
            this.browser = this.searchString(this.dataBrowser) || "An unknown browser";


            this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
            this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function(data) {
            for (var i = 0; i < data.length; i++) {
                var dataString = data[i].string;
                var dataProp = data[i].prop;
                this.versionSearchString = data[i].versionSearch || data[i].identity;
                if (dataString) {
                    if (dataString.indexOf(data[i].subString) != -1)
                        return data[i].identity;
                }
                else if (dataProp)
                    return data[i].identity;
            }
        },
        searchVersion: function(dataString) {
            var index = dataString.indexOf(this.versionSearchString);
            if (index == -1) return;
            return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
        },
        dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
        dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
function checkPopupBlocker(url) {

    var myTest = window.open(url, '', 'width=400,height=200,top=420px,left=430px');

    BrowserDetect.init();
        
        if (!(myTest) && (BrowserDetect.browser != 'Chrome')) 
        {
            alert('A popup blocker was detected.Please check your browser setting for using this page');
//            if (confirm('A popup blocker was detected.Please check your browser setting' = true)) {
//                return true;
//            }
//
            document.getElementById("ctl00_ContentCenter_btnSubmit").disabled = true;
            document.getElementById("ctl00_ContentCenter_ddlCatagory").disabled = true;
            document.getElementById("ctl00_ContentCenter_ddlState").disabled = true;
            document.getElementById("ctl00_ContentCenter_ddlDistrict").disabled = true;
            document.getElementById("ctl00_ContentCenter_ddlIncidentLocation").disabled = true;
            document.getElementById("ctl00_ContentCenter_txtIncidentLocation").disabled = true;
            document.getElementById("ctl00_ContentCenter_txtTitle").disabled = true;
            document.getElementById("ctl00_ContentCenter_txtDiscription").disabled = true;
            document.getElementById("ctl00_ContentCenter_txtMetaTagTitle").disabled = true;
            document.getElementById("ctl00_ContentCenter_txtMetaTagKeywords").disabled = true;
            document.getElementById("ctl00_ContentCenter_txtMetaTagDiscription").disabled = true;
            document.getElementById("ctl00_ContentCenter_btnSubmit").disabled = true;
        } 
}


function detectPopupBlocker(url) {

    var myTest = window.open(url, '', 'width=400,height=200,top=420px,left=430px');
    
    
    if (!myTest ) {

        alert("A popup blocker was detected.I am opening in new window,for next time check your  browser setting to desable popup blocker ");
        document.getElementById('link').href = url;
        window.location.href = document.getElementById('link').href;
        //window.location=url;
       
       
    } else {
            
            BrowserDetect.init();
            if (BrowserDetect.browser = 'Chrome') {
                window.location = url;
            }
        myTest.close();
        alert("No popup blocker was detected.");
    }
 
   
}



var windowHandle = null;
var windowHandle_closed = false;


                
                
function openWindow() {
    windowHandle = window.open('VideoFileUpload.aspx', 'windowName', 'height=200,width=200');
    if (windowHandle_closed) {
        windowHandle_closed = false;
    }
}

function closeWindow() {
    if (windowHandle != null) {
        if (!windowHandle_closed) {
            windowHandle_closed = true;
            windowHandle.close();
        }
    }
    else {
        alert('not yet opened');
    }

}


function ShowPopup(url) {

    window.open(url, "CategoryImage", 'width=600,height=600,menubar=no,status=no, locationbar=no,toolbar=no,scrollbars=yes');

}

function Popup(url) {

    window.open(url, "CategoryImage", 'width=530,height=250,menubar=no,status=no, locationbar=no,toolbar=no,scrollbars=yes');

}

function LoginCheck(url, cond) {

    if (document.getElementById("ctl00_hdUser").value == "") {
        alert("Please Login First To Upload " + cond + " Advertisement");
        return false;
    }
    else {
        document.location.href = url;
        return true;
    }

}
