// JavaScript Document
//These functions will be used to show IE users a warning message
//once a day when they try to watch a video
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function alertOrNot(){
browserName=navigator.appName; 
if ((get_cookie('wtc_popunder')=='')&&(browserName=="Microsoft Internet Explorer")){
	//give alert
	promoteFF();
	//see if we need to set cookie
	if(get_cookie('wtc_popunder')==''){
		setcookie("wtc_popunder","yes",3);
		}
	}

}

function promoteFF(){
	//give firefox plug
	$msg = "It appears you\'re using Internet Explorer which has been known to cause problems when viewing some videos. Many of our visitors prefer using Firefox, which is also recommended by Google.\n\nIf you would like to experience optimum performance when viewing our videos please click 'OK' for further information.\n\nAlternatively to continue using Internet Explorer just click 'Cancel'." ;
	$link = "http://www.whatsthatcode.com/warning.php";
	if(confirm($msg)){
		//redirect
		window.location = $link;
	}
}

function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration)+";path=/";
document.cookie=cookiestring;
}

function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}

//MAIN: run script
alertOrNot();