﻿
   /* function ajaxGetDisclaimer() {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else {
            alert("Your browser does not support XMLHTTP!");
        }

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {
                document.myForm.time.value = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "/Contents/disclaimer.htm", true);
        xmlhttp.send(null);
    }

*/
    var fileUrl = '';

    function linkClicked(linkurl) {
        fileUrl = linkurl
        /*var cookieName = "disclaimerRead";
        if (checkCookie(cookieName) == true) {
            window.open(linkurl);
        }
        else {
           */
            var hiddenObj = document.getElementById('disclaimerLaunch');

            if (hiddenObj.value == 'true') {
                //alert('checkpoint 2false');
                //window.open('/Contents/disclaimer.htm');
                document.getElementById('disclaimerContent').style.display='block';   
                document.getElementById('fade').style.display='block'; 

                
            }
            else {
                window.open(linkurl);
            }

            
        //}
    }

    function checkCookie(cName) {

        if (document.cookie == null) {
            return false;
        }
        else {
           
            var nameEQ = cName + "=";
            var cArr = document.cookie.split(';');
            for (var i = 0; i < cArr.length; i++) {
               // alert('here');
		        var c = cArr[i];
		        while (c.charAt(0)==' ') c = c.substring(1,c.length);
		        if (c.indexOf(nameEQ) == 0)
		            return true;
	        }
	        return false;
        }
    }

    function closeDisclaimer() {
        var checkBoxObj = document.getElementById('ckbxAccept');
        var hiddenObj = document.getElementById('disclaimerLaunch');
        
        if (checkBoxObj.checked == true) {
            document.getElementById('disclaimerContent').style.display = 'none';
            document.getElementById('fade').style.display = 'none';
            //setCookie();
            hiddenObj.value = 'false';
            window.open(fileUrl);
        }
        else {
           var answer = confirm("You haven't accepted the terms in the disclaimer.\n  You won't be able to open the resource files. \n Are you sure you want to close the disclaimer?");
           if (answer) {
               document.getElementById('disclaimerContent').style.display = 'none';
               document.getElementById('fade').style.display = 'none';
           }
          
        }

    }
    
    function setCookie() {
        var cName = "disclaimerRead";
        var expireAfterDays = 365;
        var date = new Date();
        //alert('checkpoint 3');
		date.setTime(date.getTime()+(expireAfterDays*24*60*60*1000));
		document.cookie = cName +"=opened; expires =" + date.toGMTString()+ "; path=/";
    }
