var hiddenWindowURL = "/survey/choosesurvey.htm"

var newWin;

function isCookieEnabled()
 {    var cookie_is_enabled = false;
      var brwsrVer = navigator.appVersion;
      var arr1 = brwsrVer.split(" ");
      var brversion = parseFloat(arr1[3]);
   if (navigator.appName == "Microsoft Internet Explorer")
   {

      if (brversion >= 4.0 )
      {
         this.cookieEnabled = window.navigator.cookieEnabled;

         if (this.cookieEnabled)
         {
           cookie_is_enabled = true;
         }
         else
         {
            cookie_is_enabled = false;
         }
      }
      else
      {
        if (cookieCheck())
        {
          cookie_is_enabled=true;
        }
        else
        {
         cookie_is_enabled=false;
        }
      }
  }
  else
  {
    if (navigator.appName == "Netscape")
    {
      if (cookieCheck())
      {
          cookie_is_enabled=true;
      }
      else
      {
         cookie_is_enabled=false;
      }
    }
  }
 return cookie_is_enabled;
}

function cookieCheck()
{
  var cookie_is_found=false;
  
  setCookie('AMDCookieCheck','CHECK');
  if (getCookieValueString('AMDCookieCheck')!="")

  {
     cookie_is_found = true;
  }
  else
  {
    cookie_is_found=false;
  }
  return cookie_is_found;
}

function setCookie(name, value)
{
    var cookieDate = new Date();
    var expire_date = 90;
    cookieDate.setTime (cookieDate.getTime() + (1000 * 60 * 60 * 24 * expire_date));
    cookie_set = name + "=" + escape(value);
    cookie_set += "; expires=" + cookieDate.toGMTString();
    cookie_set += "; path=/;";
    document.cookie = cookie_set;

}


function getCookieValueString(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}



function FunctionLoad ()
{
   window.name = "MyParent";

   random_number = Math.random()*100;
	
        
   if (isCookieEnabled())
   {
      if ((window.location.href.search("wwwsecure") < 0)) 
      {
		// 04/22/2008   Subhasis Rout	EAP345177
		// exclude the survey if the user is from subdomain of amd

		  if ((window.location.hostname.search(/vip/i) == -1)&&(window.location.hostname.search(/vincent/i) == -1)&&(window.location.hostname.search(/villain/i) == -1)&&(window.location.hostname.search(/vivian/i) == -1))
		  {	
            if ((window.location.href.search("us-en") > 0) || (window.location.href.search("us%2Den") > 0) || (window.location.href.search("gb-uk") > 0) || (window.location.href.search("gb%2Duk") > 0) || (window.location.href.search("fr-fr") > 0) || (window.location.href.search("fr%2Dfr") > 0) || (window.location.href.search("kr-kr") > 0) || (window.location.href.search("kr%2Dkr") > 0) || (window.location.href.search("la-es") > 0) || (window.location.href.search("la%2Des") > 0) || (window.location.href.search("br-pt") > 0) || (window.location.href.search("br%2Dpt") > 0) || (window.location.href.search("de-de") > 0) || (window.location.href.search("de%2Dde") > 0) || (window.location.href.search("es-es") > 0) || (window.location.href.search("es%2Des") > 0) || (window.location.href.search("it-it") > 0)|| (window.location.href.search("it%2Dit") > 0)|| (window.location.href.search("pl-pl") > 0)|| (window.location.href.search("pl%2Dpl") > 0)|| (window.location.href.search("ru-ru") > 0)|| (window.location.href.search("ru%2Dru") > 0)|| (window.location.href.search("sg-en") > 0)|| (window.location.href.search("sg%2Den") > 0)|| (window.location.href.search("jp-ja") > 0)|| (window.location.href.search("jp%2Dja") > 0)|| (window.location.href.search("th-th") > 0)|| (window.location.href.search("th%2Dth") > 0))
            {
				if ((window.location.href.search("/Processors/ProductInformation/0,,30_118_11120,00.html") > 0) || (window.location.href.search("SupportDrivers/ProcessorSupport/0,,15218_15219,00.html") > 0)||(window.location.href.search("Processors/TechnicalResources/0,,30_182,00.html") > 0)) 			   
				{     		
					var country_percent = 10;
             
					// Set cookie for where the person came from
					 setCookie("Survey2Location", location.pathname);


					// 03/27/2008   Subhasis Rout	
					//set cookie to store the full Parent URL. This was required in EAP 339618 where one of the new requirement 
					// was to add the parent URL to survey URL after "refurl" as a parameter. 
					// For eg: http://www.amdsurveys.com/se.ashx?s=5A1E27D231CA9B85&refurl=http://ati.amd.com/products/index.html			   	
						//setCookie("fullParentURL",window.location);	
						
						//10/1/2008 Avisek Rishi for EAP 374618 (appending exit url to intercept url)
						setCookie("fullParentURL",window.location);
						

            
					   var sPageVisited;
						sPageVisited = "";
						sPageVisited = getCookieValueString("sPageVisited2");

						if (sPageVisited==null && random_number < country_percent)
						{
						   setCookie("sPageVisited2", "true");	
						   newWin = window.open ( hiddenWindowURL, "babyWindow", "status=no,status=0,width=1,height=1,top=3333,left=3333" );
						}

						// Now setting cookie only if get survey. setCookie("sPageVisited2", "true");
						 }
						 else
						 {
							//Do Nothing
						 }
			        }
              }
         }
     }
}

//window.onload=FunctionLoad;   //This line is commented to disable Exit Survey....EAP348134...05/09/2008
				//Simply comment/uncomment this line to disable/enable the survey


// window.onload=FunctionLoad; //Enabling Exit Survey EAP 374618
                              //Disabling Exit Survey EAP 377783
                              //Enabling Exit Survey EAP 386359 09/12/08
			      // Disabling Exit Survey 01/21/2009