﻿function getMouseXY(evt) {
    try {
        if (!evt) var evt = window.event;
        if (document.all) { // grab the x-y pos.s if browser is IE
            xPos = evt.clientX + (document.documentElement ? document.documentElement.scrollLeft : document.body.scrollLeft);
            yPos = evt.clientY + (document.documentElement ? document.documentElement.scrollTop : document.body.scrollTop);
        } else {  // grab the x-y pos.s if browser is NS
            xPos = evt.pageX;
            yPos = evt.pageY;
        }
        // catch possible negative values in NS4
        if (xPos < 0) { xPos = 0 };
        if (yPos < 0) { yPos = 0 };
    }

    catch (err) {
    }
    // show the position values in the form named Show
    // in the text fields named MouseX and MouseY
    return true;
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all ? true : false;

// If NS - that is, !IE - then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var xPos = 0;
var yPos = 0;

function feedback() {
    if (document.getElementById('txtFeedback').value == '') {
        alert('Message field can not be empty');
        return true;
    }
    // document.getElementById('ct100_flashVers').value = GetSwfVer();         
    __doPostBack('updMaster', GetSwfVer());
    return false;
}

function hideflex() {
    if (document.getElementById('UploaderGuiStd') != null)
        document.getElementById('UploaderGuiStd').style.visibility = 'hidden';

    if (document.getElementById('FilemailStats') != null)
        document.getElementById('FilemailStats').style.visibility = 'hidden';

    if (document.getElementById('FilemailSlideshow') != null)
        document.getElementById('FilemailSlideshow').style.visibility = 'hidden';

    if (document.getElementById('Signup') != null)
        document.getElementById('Signup').style.visibility = 'hidden';

    if (document.getElementById('CorpSettings') != null)
        document.getElementById('CorpSettings').style.visibility = 'hidden';

    if (document.getElementById('MyUploads') != null)
        document.getElementById('MyUploads').style.visibility = 'hidden';

    if (document.getElementById('JavaApplet') != null)
        document.getElementById('JavaApplet').style.visibility = 'hidden';

}

function showflex() {
    if (document.getElementById('UploaderGuiStd') != null)
        document.getElementById('UploaderGuiStd').style.visibility = 'visible';

    if (document.getElementById('FilemailStats') != null)
        document.getElementById('FilemailStats').style.visibility = 'visible';

    if (document.getElementById('FilemailSlideshow') != null)
        document.getElementById('FilemailSlideshow').style.visibility = 'visible';

    if (document.getElementById('Signup') != null)
        document.getElementById('Signup').style.visibility = 'visible';

    if (document.getElementById('CorpSettings') != null)
        document.getElementById('CorpSettings').style.visibility = 'visible';

    if (document.getElementById('MyUploads') != null)
        document.getElementById('MyUploads').style.visibility = 'visible';

    if (document.getElementById('JavaApplet') != null)
        document.getElementById('JavaApplet').style.visibility = 'visible';
}

function getBrowserInfo() {
    return BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS;
}

 $(document).ready(function() {

     
	        //select all the a tag with name equal to modal
	        $('a[name=modal]').click(function(e) {
	            //Cancel the link behavior
	            e.preventDefault();

	            //Get the A tag
	            var id = $(this).attr('href');

	            //Get the screen height and width
	            var maskHeight = $(document).height();
	            var maskWidth = $(window).width();

	            //Set heigth and width to mask to fill up the whole screen
	            $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

	            //transition effect
	            $('#mask').fadeTo(0, 0.8);
	            $('#mask').fadeIn(0);


	            //Get the window height and width
	            var winH = $(window).height();
	            var winW = $(window).width();

	            //Set the popup window to center
	            $(id).css('top', winH / 2 - $(id).height() / 2);
	            $(id).css('left', winW / 2 - $(id).width() / 2);

	            //transition effect
	            $(id).fadeIn(0);
	            hideflex();

	        });

	        //if close button is clicked
	        $('.window .close').click(function(e) {
	            //Cancel the link behavior
	            e.preventDefault();

	            $('#mask').hide();
	            $('.window').hide();
	            showflex();
	        });

	        //if mask is clicked
	        $('#mask').click(function() {
	            $(this).hide();
	            $('.window').hide();
	            showflex();
	        });
	    });

	    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: "OmniWeb",
		            versionSearch: "OmniWeb/",
		            identity: "OmniWeb"
		        },
		        {
		            string: navigator.vendor,
		            subString: "Apple",
		            identity: "Safari"
		        },
		        {
		            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.platform,
		            subString: "Linux",
		            identity: "Linux"
		        }
	        ]

	    };
	    BrowserDetect.init();

	    //Check if cookie is set
	    if (document.cookie.indexOf("timeOffset" + "=") == -1) {
	        ourDate = new Date();
	        document.cookie = 'timeOffset=' + ourDate.getTimezoneOffset() + '; expires=Thu, 2 Aug 2020 20:47:11 UTC; path=/'
	        window.location = window.location; //Refresh page
	    }	
