﻿// Standard Overlay
// (C) 2004-2009 Virtual Surveys Ltd
// IMPORTANT - change these variables' values for each survey

var noPagesVisited;

var vslgSurveyName = 'PGI_2681';  //E.g. name+survey, used in cookie
var vslgSurveyTitle;
var closeText;

overlayImageSrc = "http://www.preciousplatinum.com/Images/logo_pt.gif";
overlayImageAlt = "Platinum Guild International";
var surveyIntroText;
var sit;

var vslgSurveyURL = "http://survey.euro.confirmit.com/wix/p383406102.aspx";

var triggerLocation = new Array();
var vslgDefaultLocationNumber = 1;  //Default

var vsltest, vslregexp;

vslregexp = /\/en-GB\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 1;

vslregexp = /\/en-US\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 2;

vslregexp = /\/en\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 3;

vslregexp = /\/zh-CN\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 4;

vslregexp = /\/ja\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 5;

vslregexp = /\/it\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 6;

vslregexp = /\/de\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 7;

vslregexp = /\/fr\//i;
vsltest = vslregexp.test(document.location.href)
if (vsltest == true) vslgDefaultLocationNumber = 8;
  
var surveyLaterText;
if (vslgDefaultLocationNumber == 1 || vslgDefaultLocationNumber == 2 || vslgDefaultLocationNumber == 3) surveyLaterText = "Take survey later"; // UK / India / US
if (vslgDefaultLocationNumber == 4) surveyLaterText = "稍后参与调查"; // China
if (vslgDefaultLocationNumber == 5) surveyLaterText = "あとでアンケートに参加する"; // Japan
if (vslgDefaultLocationNumber == 6) surveyLaterText = "Partecipo in un secondo momento"; // Italy
if (vslgDefaultLocationNumber == 7) surveyLaterText = "Später an Umfrage teilnehmen"; // Germany
if (vslgDefaultLocationNumber == 8) surveyLaterText = "Répondre plus tard"; // France

if (vslgDefaultLocationNumber == 1 || vslgDefaultLocationNumber == 2 || vslgDefaultLocationNumber == 3) vslgSurveyTitle = 'Visitor Survey'; // UK
if (vslgDefaultLocationNumber == 4) vslgSurveyTitle = '访问者调查问卷'; // China
if (vslgDefaultLocationNumber == 5) vslgSurveyTitle = 'ビジターアンケート'; // Japan
if (vslgDefaultLocationNumber == 6) vslgSurveyTitle = 'Questionario per i visitatori'; // Italy
if (vslgDefaultLocationNumber == 7) vslgSurveyTitle = 'Besucherumfrage'; // Germany
if (vslgDefaultLocationNumber == 8) vslgSurveyTitle = 'Enquête auprès des visiteurs'; // France

if (vslgDefaultLocationNumber == 1 || vslgDefaultLocationNumber == 2 || vslgDefaultLocationNumber == 3) sit = "Sorry for the interruption. Please help us to improve the website by taking part in our visitor survey, which will only take about 5 minutes to complete. Please fill in the survey after you have completed your visit."; // UK / US / India
if (vslgDefaultLocationNumber == 4) sit = "很抱歉打扰您了。我们诚邀您参与我们的访问者调查问卷，以帮助我们改善网站。完成该问卷仅需 5 分钟。请在浏览结束时填写该问卷。"; // China
if (vslgDefaultLocationNumber == 5) sit = "私どものビジターアンケートに参加してウェブサイトの改善にご協力いただけませんでしょうか。所要時間は5分程度です。サイトの閲覧を終えられましたら、ぜひアンケートにご記入下さい。ご協力宜しくお願いします。"; // Japan
if (vslgDefaultLocationNumber == 6) sit = "Ci scusiamo per l'interruzione. La preghiamo di aiutarci a migliorare il sito web partecipando al nostro questionario per i visitatori. Per completarlo sono necessari circa 5 minuti. Dopo aver completato la sua visita, completi il questionario."; // Italy
if (vslgDefaultLocationNumber == 7) sit = "Bitte entschuldigen Sie die kurze Unterbrechung. Bitte nehmen Sie an unserer Besucherumfrage teil und helfen Sie uns so, die Website zu verbessern. Die Beantwortung der Fragen wird nur ca. 5 Minuten dauern. Bitte füllen Sie den Fragebogen nach dem Besuch der Website aus."; // Germany
if (vslgDefaultLocationNumber == 8) sit = "Veuillez nous excuser pour cette interruption. Nous vous serions reconnaissants de nous aider à améliorer ce site Internet en participant à notre enquête auprès des visiteurs qui ne vous prendra que 5 minutes. Merci de bien vouloir remplir le questionnaire après avoir terminé votre visite du site."; // France

surveyIntroText = document.createTextNode(sit);
  
var vslgLang
if (vslgDefaultLocationNumber == 1 || vslgDefaultLocationNumber == 2 || vslgDefaultLocationNumber == 3) vslgLang = 9; // UK / US / India
if (vslgDefaultLocationNumber == 4) vslgLang = 4; // China
if (vslgDefaultLocationNumber == 5) vslgLang = 17; // Japan
if (vslgDefaultLocationNumber == 6) vslgLang = 16; // Italy
if (vslgDefaultLocationNumber == 7) vslgLang = 7; // Germany
if (vslgDefaultLocationNumber == 8) vslgLang = 12; // France

var vslgPopupHeight = 540;
var vslgPopupWidth = 650;

var surveyOuterContainer, surveyInnerDiv, surveyLinkLater;

var overlay_position = "centered"; // "specified" or "centered"
var persist_position = "absolute"; // use "fixed" or "absolute"

var vslgIntervalURL = 'http://survey.euro.confirmit.com/isa/HMCYGPGAHXJXBHABPDEBCDDRJDMAGPBF/2861_PGI/job2861interval.js'; // use job number in name, note different domain to client

var vslgCookiePersistence = 90*24*60*60*1000; //set to 30*24*60*60*1000 if 30 day cookie required. 10 milliseconds
var vslgBodyFontSize = 1 / 0.65; // as 1/(font-size of containing document, 0.7 is font-size of 70%)

var vslgBorderCol = '#369'; // colour name (blue) or hex value (#00f)
var vslgIntervalRetry = 2000; // 2000 milliseconds - time allowed for loading external interval script
var vslgIntervalTimeout = 5000; // 5 seconds
var time_before_appearing = 2000; //Time before overlay appears

//IMPORTANT don't change anything below this line------------------------------------------------

var bd, vslgObjHeight, vslgObjWidth, vslgTopPos, vslgLeftPos, background, backgroundDiv;

vslgObjHeight = 250;
vslgObjWidth = 400;

vslgTopPos = 50; //in px - absolute only.
vslgLeftPos = 50; //in px - absolute only

if (!window.XMLHttpRequest) persist_position = "absolute"; //IE6 and lower override

var vslgInterval = 0;     //default 0, will be changed by external file
var vslgDebug = false;
var vslgIntervalID;
var vslgIntervalAttempts = 0; // DO NOT CHANGE

if (window.screen) {
  vslgSWidth = window.screen.width; 
  vslgSHeight = window.screen.height;
}

vslgWWidth = sizeArray[0];
vslgWHeight = sizeArray[1];

var vslgOS = 3;
var vslgCook = 3;

getOS();
cookiesEnabled();

var vslgrandomnum = (new Date()).getTime();
vslgrandomnum = Math.round(Math.abs(Math.sin(vslgrandomnum) * 1000000)) % 1000;
var vslgHitSample = false;

if (vslgInterval != 0) {
  vslgHitSample = ((vslgrandomnum + 1) * vslgInterval /1000 <= 1) && vslgCook != "2" && vslfGetCookie(vslgSurveyName) != 1;
}

function vslfGetCookieVal (offset) {

  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1){
    endstr = document.cookie.length;
  }
  return unescape(document.cookie.substring(offset, endstr));
}

function vslfGetCookie (name) {

  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {

    var j = i + alen;
    if (document.cookie.substring(i, j) == arg){
      return vslfGetCookieVal (j);
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0){
      break;
    }
  }
  return null;
}

function vslfSetCookie (name, value) {

  var argv = vslfSetCookie.arguments;
  var argc = vslfSetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");

}

function vslfCheckIntervalFile() {

  try {

    setSampleIntervalRemote();

    if (vslgInterval != 0) {

      vslgHitSample = ((vslgrandomnum + 1) * vslgInterval /1000 <= 1) && vslgCook != "2" && vslfGetCookie(vslgSurveyName) != 1;

    }

    clearInterval(vslgIntervalID);

    if (vslgHitSample) {

      setTimeout("vslfDoPopOver();",time_before_appearing);

    }

  } catch (e) {

    vslgIntervalAttempts++;

    if ((vslgIntervalAttempts * vslgIntervalRetry) >  vslgIntervalTimeout) {

      clearInterval(vslgIntervalID);

    }
  }
}

function setSampleInterval(remoteInterval) {

  vslgInterval = remoteInterval;

}

function vslfLoadwork() {
	sizeArray=getPageSize();

  var remoteScript=document.createElement('script');
  remoteScript.id = 'vsltrs';
  remoteScript.setAttribute('type','text/javascript');
  remoteScript.setAttribute('src',vslgIntervalURL);
  var hd=document.getElementsByTagName('head')[0];
  hd.appendChild(remoteScript);
  vslgIntervalID = setInterval("vslfCheckIntervalFile()",vslgIntervalRetry);

}

function getPageSize(){
  
  var xScroll, yScroll;
  
  if (window.innerHeight && window.scrollMaxY) {  
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }
  
  var windowWidth, windowHeight;
  if (self.innerHeight) {  // all except Explorer
    windowWidth = self.innerWidth;
    windowWidth2 = document.body.clientWidth; //Measurement excluding scollbars for opaque div
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowWidth2 = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowWidth2 = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }  

  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else { 
    pageHeight = yScroll;
  }

  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){  
    pageWidth = windowWidth;
  } else {
    pageWidth = xScroll;
  }

  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,windowWidth2) 
  return arrayPageSize;

}

function getScrollXY(rvalue) {

  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

  if (rvalue == "height") return scrOfY;
  if (rvalue == "width")  return scrOfX;

}

function vslfDoPopOver() {

  if (vslgHitSample) {

    var expdate = new Date();
    expdate.setTime(expdate.getTime() + (vslgCookiePersistence));
    vslfSetCookie(vslgSurveyName,"1",expdate,"/");

    var surveyWidth, surveyWidth2, surveyTop, surveyHeight;

    surveyLeft = vslgBodyFontSize*vslgLeftPos/16 + 'em';

    if (overlay_position == "centered" && persist_position == "absolute"){

      surveyWidth = vslgObjWidth + 'px';
      surveyWidth2 = vslgObjWidth + 'px';
      surveyHeight = vslgObjHeight + 'px';

      surveyTop =  ((sizeArray[3]/2) - (vslgObjHeight/2) + getScrollXY("height")) + 'px';
      surveyLeft = ((sizeArray[2]/2) - (vslgObjWidth/2) + getScrollXY("width")) + 'px';

    }

    if (overlay_position == "centered" && persist_position == "fixed"){

      surveyWidth2 = "100%";
    
      surveyHeightPercentage = 30;
      surveyWidthPercentage = 50;

      surveyWidth = surveyWidthPercentage + '%';
      surveyHeight = surveyHeightPercentage + '%';

      surveyLeft = (100 - surveyWidthPercentage)/2 + '%';
      surveyTop = (100 - surveyHeightPercentage)/2 + '%';

    }

    if (overlay_position == "specified" && persist_position == "fixed"){

      surveyHeight = "50%";
      surveyWidth = "50%";
      surveyWidth2 = "100%";
      surveyTop = vslgTopPos + "px";
      surveyLeft = vslgLeftPos + "px";

    }
  
    var vslgObjURL2 = "?c="+vslgDefaultLocationNumber+"&w="+vslgSWidth+"&h="+vslgSHeight+"&wW="+vslgWWidth+"&wH="+vslgWHeight+"&os="+vslgOS +"&si="+vslgInterval+"&l="+vslgLang;


    surveyOuterContainer = document.createElement("div");
    surveyInnerDiv = document.createElement("div");
    surveyInnerDiv.id = "surveyInnerDiv"

    surveyOuterContainer.style.zIndex = "9999";
    surveyOuterContainer.style.borderColor = vslgBorderCol;
    surveyOuterContainer.style.borderWidth = "2px";
    surveyOuterContainer.style.borderStyle = "solid";
    surveyOuterContainer.style.width = surveyWidth;
    if (surveyHeight) surveyOuterContainer.style.height = surveyHeight;
    surveyOuterContainer.style.position = persist_position;
    surveyOuterContainer.style.top  = surveyTop;
    surveyOuterContainer.style.left = surveyLeft;
    surveyOuterContainer.style.fontFamily = "Arial, Helvetica, sans-serif";
    surveyOuterContainer.style.textAlign = "left";
    surveyOuterContainer.style.fontWeight = "bold";
    surveyOuterContainer.style.backgroundColor = "white";
    surveyOuterContainer.id = "surveyouter";

    vfontsize = vslgBodyFontSize*0.75;
    vfontsize = vfontsize + 'em';
    surveyOuterContainer.style.fontSize = vfontsize;
    document.getElementsByTagName("body")[0].appendChild(surveyOuterContainer)
    surveyOuterContainer.appendChild(surveyInnerDiv)

    outerImageDiv = document.createElement("div");

    var overlayImage = document.createElement("img");
    overlayImage.src = overlayImageSrc;
    overlayImage.alt = overlayImageAlt;

    overlayImage.style.paddingLeft = "0.5em";
    overlayImage.style.paddingTop = "0.5em";
    overlayImage.style.paddingBottom = "0.5em";

    overlaySkipLink  = document.createElement("a");
    overlaySkipLink.id = "skiptarget";
    overlaySkipLink.name = "skiptarget";
    overlaySkipLink.className = "skip";
    overlaySkipLink.tabIndex = "-1";

    surveyInnerDiv.style.margin = "0.5em";
    br1 = document.createElement("br");
    br2 = document.createElement("br");
    surveyLinkContainer = document.createElement("div");
    surveyLinkContainer.style.textAlign = "center";
    surveyLinkContainer.id = "surveylinkcontainer";
    surveyLinkLater = document.createElement("a");
    surveyLinkLater.href = "#";
    surveyLinkLater.id = "surveylinklater";
	
    if (vslgDefaultLocationNumber == 1 || vslgDefaultLocationNumber == 2 || vslgDefaultLocationNumber == 3) surveyLinkLater.title = "Opens survey in a new window"; // UK / US / India
	if (vslgDefaultLocationNumber == 4) surveyLinkLater.title = "在新窗口打开调查问卷"; // China
	if (vslgDefaultLocationNumber == 5) surveyLinkLater.title = "新しいウインドウでアンケートを開く"; // Japan
	if (vslgDefaultLocationNumber == 6) surveyLinkLater.title = "Apre il questionario in una nuova finestra."; // Italy
	if (vslgDefaultLocationNumber == 7) surveyLinkLater.title = "Öffnet Umfrage in einem neuen Fenster"; // Germany
	if (vslgDefaultLocationNumber == 8) surveyLinkLater.title = "L'enquête s'ouvre dans une nouvelle fenêtre."; // France	
	
    surveyLinkLater.style.fontSize = "120%";
    surveyLinkLater.style.textDecoration = "underline";
    surveyLinkText = document.createTextNode(surveyLaterText);
    surveyLinkSpan = document.createElement("span");
    surveyLinkSpan.style.backgroundImage = "url(http://survey.euro.confirmit.com/isa/HMCYGPGAHXJXBHABPDEBCDDRJDMAGPBF/VirtualSurveys/link_open.gif)";
    surveyLinkSpan.style.repeat = "no-repeat";
    surveyLinkSpan.style.scroll = "scroll";
    surveyLinkSpan.style.cursor = "pointer";
    surveyLinkSpan.style.display = "inline-block";
    surveyLinkSpan.style.height = "14px";
    surveyLinkSpan.style.paddingRight = "21px";
    surveyLinkSpan.style.title= "Opens new window";
    surveyLinkSpanText = document.createTextNode("_");

    surveyInnerDiv.appendChild(surveyIntroText);
    surveyInnerDiv.appendChild(br1);
    surveyInnerDiv.appendChild(br2);
    surveyInnerDiv.appendChild(surveyLinkContainer);
    surveyLinkContainer.appendChild(surveyLinkLater);
    surveyLinkLater.appendChild(surveyLinkText);
    surveyLinkLater.appendChild(surveyLinkSpan);

    overlayHeaderContainer = document.createElement("div");
    surveyOuterContainer.insertBefore(overlayHeaderContainer,surveyInnerDiv);
    surveyOuterContainer.insertBefore(outerImageDiv,surveyInnerDiv);
    outerImageDiv.appendChild(overlayImage);
    outerImageDiv.appendChild(overlaySkipLink);

    overlayHeaderContainer.style.color = "#fff";
    overlayHeaderContainer.style.backgroundColor =   vslgBorderCol;
    overlayHeaderContainer.style.borderBottomColor = vslgBorderCol;
    overlayHeaderContainer.style.borderBottomStyle = "solid";
    overlayHeaderContainer.style.borderBottomWidth = "1px";
    overlayHeaderContainer.style.textAlign = "right";

    overlayTitleSpan = document.createElement("span");
    overlayCloseLink = document.createElement("a");

    overlayHeaderContainer.appendChild(overlayTitleSpan);
    overlayHeaderContainer.appendChild(overlayCloseLink);

    overlayTitleSpan.style.padding = "0 0.5em";
    var surveyTitle = document.createTextNode(vslgSurveyTitle);
    overlayTitleSpan.appendChild(surveyTitle);
    overlayTitleSpan.style.styleFloat = "left";
    overlayTitleSpan.style.cssFloat = "left";

    overlayCloseLink.style.padding = "0 0.5em";
    overlayCloseLink.title = "Close Overlay";
    overlayCloseLink.style.color = "#fff";
    overlayCloseLink.style.textDecoration = "underline";
    overlayCloseLink.href="#";

    var ct;
    if (vslgDefaultLocationNumber == 1 || vslgDefaultLocationNumber == 2 || vslgDefaultLocationNumber == 3) ct = "Close Survey Invite"; // UK / US / India
    if (vslgDefaultLocationNumber == 4) ct = "关闭调查邀请"; // China
    if (vslgDefaultLocationNumber == 5) ct = "アンケートへの勧誘を閉じる"; // Japan
    if (vslgDefaultLocationNumber == 6) ct = "Chiudi l'invito al questionario"; // Italy
    if (vslgDefaultLocationNumber == 7) ct = "Einladung zur Umfrageteilnahme schließen"; // Germany
    if (vslgDefaultLocationNumber == 8) ct = "Fermer l'invitation"; // France

    closeText = document.createTextNode(ct);
    overlayCloseLink.appendChild(closeText);

    overlayCloseLink.onclick = function(){
			  closeSurveyDiv();
			  return false;
			}

    overlaySkipLink.focus();
    surveyLinkLater.onclick = function(){
      vslgPu = window.open(vslgSurveyURL + vslgObjURL2,vslgSurveyName+Math.floor(Math.random()*10e20),"height="+vslgPopupHeight+",width="+vslgPopupWidth+",resizable=yes,scrollbars=yes,toolbar=no,menubar=no");
      closeSurveyDiv();
      self.focus(); // Hides modal window in firefox only
      return false;
    }

  }
}

/*if (!window.onload) {

  window.onload = vslfLoadwork;

} else {

  curr_onload = window.onload;
  window.onload = function()
                  {
                    vslfLoadwork();
                    curr_onload();
                  }
}*/

function closeSurveyDiv(){

  if (surveyOuterContainer) {

    surveyOuterContainer.style.display='none';

  }

  return false;

}

function getOS(){

  // operating system
  if (navigator.userAgent.match(/Windows/)) vslgOS=1;
  if (navigator.userAgent.match(/Macintosh/)) vslgOS=2;
  
}

function cookiesEnabled(){

  vslfSetCookie("cookieenabledcheck","1");
  if (vslfGetCookie("cookieenabledcheck") == 1){

    vslgCook = 1;

  } else {

    vslgCook = 2;

  }
}


