    function createCookie(name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
		//alert(value);
        refresh();
    }

    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }

    function eraseCookies() {
	//alert(readCookie("Docs"));
        createCookie('Docs', "", -1);
        createCookie('Events', "", -1);
        createCookie('News', "", -1);
        createCookie('Companyname', "", -1);

//alert(readCookie("Docs"));
    }

    var doctoOpen;

    function openDoc() { newwindow = window.open(doctoOpen, 'Doc', 'height=800,width=600,status = 1,left=0,top=0'); }

    function refresh() { window.location.reload(false); }

    var newwindow;

    function checkforCookie(type, doc) {

        if (type == 'Docs') {
            if (readCookie(type) == 'Yes') {
                newwindow = window.open(doc, 'Doc', 'height=800,width=600,status = 1,left=0,top=0');
            }
            else {
                doctoOpen = doc;
                newwindow = window.open('../registration/RegisterDocs.htm?Type=' + type + '&Doc=' + doc, 'Register', 'height=500,width=600');
                if (window.focus) { newwindow.focus() }
            }
        }

        if (type == 'News') {
            if (readCookie(type) == 'Yes') {
                alert('You have already subscribed');
            }
            else {
                newwindow = window.open('../registration/RegisterNews.htm?Type=' + type, 'Register', 'height=500,width=600');
            }
        }

        if (type == 'Events') {
            if (readCookie(type) == 'Yes') {
                alert('You have already subscribed');
            }
            else {
                newwindow = window.open('../registration/RegisterEvents.htm?Type=' + type, 'Register', 'height=500,width=600');
            }
        }
		
		 if (type == 'Train') {
            if (readCookie(type) == 'Yes') {
                alert('You have already subscribed');
            }
            else {
                newwindow = window.open('../registration/RegisterTrain.htm?Type=' + type, 'Register', 'height=500,width=600');
            }
        }

    }

