//alert ("Iperception Test")
var date = new Date();
date.setTime(date.getTime()+(90*24*60*60*1000));
var cookExpire = date.toUTCString();

var sValue1 = 1;
var sName1 = "PNcookieTEST";
var docReferrer;

docReferrer = document.referrer;
 document.cookie = sName1 + "=" + escape(sValue1) + ";path=\; expires=" + cookExpire + ";"
 
//alert (document.cookie)

var keepThisInvitationActive = "true";
//var keepThisInvitationActive = "false";
//alert (document.cookie)

var globalJSFile = "http://group11.iperceptions.com/Invitations/Javascripts/GlobalShutOff.js";

//check to see if the user is coming from url: dealer_view
	var doURL = String(document.location);
	if (doURL.match(/dealer_view/g) == 'dealer_view') 
            {
           	donothing();
            }
		else
		{
		 loadScript(globalJSFile);
        }


//loadScript(globalJSFile);
// This function loads an external javascript file into this file when called
// from this file
function loadScript(file)
{
	// Create script DOM(Document Object Model) element
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = file;
	

	// Alert when the script is loaded
	if (typeof(script.onreadystatechange) == 'undefined') // W3C
		script.onload = function(){ this.onload = null;  };
	else // IE
		script.onreadystatechange = function(){ if (this.readyState != 'loaded' && this.readyState != 'complete') return; this.onreadystatechange = null;  }; // Unset onreadystatechange, leaks mem in IE

	// Add script DOM(Document Object Model) element to document tree
	document.getElementsByTagName('head')[0].appendChild(script);
}


function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0])
		return unescape(aCrumb[1]);
    else
		return false;

  }
}

function SetCookie(sName, sValue)
{
  
  document.cookie = sName + "=" + escape(sValue) + ";path=\; expires=" + cookExpire + ";"
}
	
function Hitit(){
	var sValue = 1;
	var sName = "PNcookie314";
	var rndNum;
	rndNum=Math.floor ((Math.random()*1800));
    //Oct. 23rd 2009 : rate 5/450	
		if (rndNum < 25 && document.cookie.indexOf(sName) == -1) //if cookie has not been set
		{
			//alert (document.cookie.indexOf(sName1))
			
			if( GetCookie('PNcookieTEST') == null || document.cookie==null ||document.cookie.indexOf(sName1)==-1)
			//if (document.cookie)
			{
				//alert ("donothing")
				donothing();
			}
			else
			{
				//alert ("SET COOKIE")
			SetCookie(sName, sValue);
			if (navigator.appName.indexOf("Microsoft")==-1)
				//alert("other")
				setTimeout('OpenPopup()',1); 
			else
				//alert("ie")
				OpenPopup() 	
			}    
		}
		else
		{
			donothing();
		}
	/*}
	else
	{
		
	alert ("donothing")
		donothing();
	}*/
	
}


function OpenPopup() {

	
	var a
	a = 1
	if (a==1){ 
		top.location="http://www.gm.ca/invitations/gmcanada/gmcanadainvitation.html?DR=" + docReferrer ;
	}
	
}

function donothing() {
	var a;
	
}

//alert ("Iperceptions Test 2")






