// JavaScript Document

// renamed getCookie and addCookie to avoid naming conflicts with existing tracking scripts

function checkCookie(URL,returl) {
		if (LC_readCookie("cmLearningCenter") != null) {
				//alert ("cookie detected.");
				window.location.href=URL; //collateral
		}
		else {
				window.location.href=returl; //teaser page
		}
}

function checkCookiePop(URL,returl) {
		if (LC_readCookie("cmLearningCenter") != null) {
				//alert ("cookie detected.");
				window.open(URL); //collateral
		}
		else {
				window.location.href=returl; //teaser page
		}
}

function checkCookieModal(URL,returl) {
		if (LC_readCookie("cmLearningCenter") != null) {
				//alert ("cookie detected.");
				window.open(returl); //collateral - edemo and videos
		}
		else {
				Modalbox.show(URL, {title: "Get Access to All of our School Learning Center Resources!", width: 740}); //leadform followed by lp
		}
}

function checkCookieOLSedu(URL,returl) {
		if (LC_readCookie("cmLearningCenter") != null) {
				//alert ("this is where I would like to pass another URL to this function, and make a call for Modalbox.show.");
				Modalbox.show(returl, {title: "Online Seminar Registration - Education: K-12", width: 740}); //short form
		}
		else {
				Modalbox.show(URL, {title: "Online Seminar Registration - Education: K-12", width: 740});
		}
}

function checkCookieOLSgen(URL,returl) {
		if (LC_readCookie("cmLearningCenter") != null) {
				//alert ("this is where I would like to pass another URL to this function, and make a call for Modalbox.show.");
				Modalbox.show(returl, {title: "Online Seminar Registration", width: 740}); //short form
		}
		else {
				Modalbox.show(URL, {title: "Online Seminar Registration", width: 740});
		}
}

// Modalbox.show(URL, {title: "Get Access to All of our School Learning Center Resources!", width: 740});

function LC_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=/";
}

function LC_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 LC_eraseCookie(name) {
	createCookie(name,"",-1);
}
		
		
//		function LC_findCookie(cookieName) {
//  			var results = document.cookie.match ( '(^|;) ?' + cookieName + '=([^;]*)(;|$)' );
//
//  			if ( results )
//    				return ( unescape ( results[2] ) );
//  			else
//    				return null;
//		}
//
//		function LC_createCookie(cookieName, id, expirationDate) {
//			alert('LC_createCookie()');
//			document.cookie = cookieName + "=" + document.getElementById(id).value + "; expires=" + expirationDate + ";";
//		}
//
//		function submitForm() { //not being used
//
//			LC_createCookie('cmLearningCenter', 'email', "01/01/09 00:00:00");
//
//			//window.location = "http://www.cmarket.com/resources/ebook_thankyou.htm";
//
//		}
//
//		function deleteCookie() {
//			var myCookie = "cmLearningCenter=; expires=" + new Date() + ";";
//
//			alert("deleting cookie... " + myCookie);
//			document.cookie = myCookie;
//		}


