function randomSurvey(formName, pageType, fidArray){
  var dosurvey = true;
	var expdate = new Date ();
	var surveyCookieName = "CARFAX_SURVEY";
	var percentOfferedSurvey = 60; // CHANGE THIS PARAMETER TO CONTROL SAMPLING RATE value was 20 LHT
	if(fidArray !=null){
	   var dosurvey = false;
	   for (i=0; i<fidArray.length; i++) {
		  if(fidArray[i] == document.forms[formName].FID.value){
			  var dosurvey = true;
		  }
	   }
    }
  if (dosurvey){
	 // partner dependant url
	  if (document.forms[formName].FID.value== '1406' ||  document.forms[formName].FID.value== '2504' ||
		  document.forms[formName].FID.value== '2265' ||  document.forms[formName].FID.value== '1868' ||
		  document.forms[formName].FID.value== '6930' ||  document.forms[formName].FID.value== '6931'){
		var surveyLocation = "http://www.insightexpress.com/s/Bran75848";
	  }  
	  else if (document.forms[formName].FID.value== '2867' ||  document.forms[formName].FID.value== '2871' ||
			   document.forms[formName].FID.value== '2872' ||  document.forms[formName].FID.value== '2873'){
		var surveyLocation = "http://www.insightexpress.com/s/Part76072"; 
	  }
	  else if (document.forms[formName].FID.value== '1724' ||  document.forms[formName].FID.value== '2869' ||
			   document.forms[formName].FID.value== '2184' ||  document.forms[formName].FID.value== '2525'){
		if(pageType == 'receiptPage'){
			var surveyLocation = "http://www.insightexpress.com/s/PPCB76068";
		} else {
			var surveyLocation = "http://www.insightexpress.com/s/PPCB76070"; 
		}
	  }
	  else {
		var dosurvey = false;
		var surveyLocation = 'nosurvey';
	  }
  }
  //alert(surveyLocation);

  if (dosurvey){
	var popupNewWindow = true; //or show the survey in the same window.
	expdate.setTime (expdate.getTime() + (60 * 24 * 60 * 60 * 1000)); // 60 days from now
	var stored_value = GetCookie(surveyCookieName);
	var dd=new Date();
	cn= Math.round(dd.getTime() / 100) % 100;
	if ((cn <= percentOfferedSurvey) && (stored_value == null)){
	  SetCookie(surveyCookieName, "alreadyOffered", expdate);
	  nwin=window.open(surveyLocation,'new_window','width=840,height=600,resizable=yes,scrollbars=yes');
	  nwin.focus();
	}
  }
}
function SetCookie (name,value,expires,path,domain,secure){
  document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}
function getCookieVal (offset){
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
	endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name){
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  
  if((document.cookie == null) || (document.cookie.length == null)){
  return null;
  }
  var i = 0;
  while (i < clen){
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
	  return getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0) break;
  }
  
  return null;
}
  function NewWindow(mypage, myname, w, h, scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    // convert all characters to lowercase to simplify testing
    var agt = navigator.userAgent.toLowerCase();
    // Browser info again
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    // Get browser version, if Netscape
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));

    if (is_nav3 || is_nav2 || is_nav4) {
      WindowOpts = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",scrollbars=yes,resizable=yes";
    } else {
      WindowOpts = "height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + ",scrollbars=" + scroll + ",resizable=yes";
    }
    WindowResults = window.open(mypage, myname, WindowOpts);
    if(parseInt(navigator.appVersion) >= 4) {
      WindowResults.window.focus();
    }
  }
  
  function NewWindowCloseOld(mypage,myname,w,h,scroll){
    NewWindow(mypage,myname,w,h,scroll);
    window.close();
  }
  
function palmsampleWindow(partner, fid) {
    psampleWindow=window.open('/vehicle_history/report_tour_vhr.cfm?partner='+partner+'&FID='+fid,'psampleWin','width=695,height=600,scrollbars=yes')
}		