/**
 * Adversitement B.V.
 *
 * Current version: 1.1.0
 * Last updated: 2011-12-21
 * 
 * s_code.js
 * 
 * Code for loading Omniture SiteCatalyst scripts.
 * 
 * Changelog
 * 
 * 2011-11-24: Force host for loading scripts to www.vgz.nl for domains other than vgz.nl
 * 2011-12-21: Added s object
 *  */

var copyright = "2010-2011 - Insite Innovations and Properties B.V., an Adversitement group company. All rights reserved.";
var wa = {};
if(typeof(s) == "undefined") var s = {};
// Fetch protocal used:
wa.protocol = "http";
if (typeof(document.location) != "undefined" && document.location != "") {
	if (document.location.toString().indexOf("https://")>-1) {
		wa.protocol = "https";
	}
}

// Fetch host:
wa.host = "";
if(typeof(document.location) != "undefined" && document.location != "" && typeof(document.location.host) != "undefined" && document.location.host != "") {
	wa.host = document.location.host;
	if(wa.host.toString().indexOf("vgz.nl")==-1){
		wa.host = "www.vgz.nl";
	}
} 

wa.track = function(startTracking) {
	if(typeof(startTracking)!="undefined" && startTracking!="" && (startTracking=="yes" || startTracking=="no")) wa.doTrack = startTracking;
	else wa.doTrack = "yes";
}

// Initialize load script:
wa.loadScript = function(a,b,c){var d=document.createElement("script");d.type="text/javascript",typeof b!="undefined"&&b(),d.readyState?d.onreadystatechange=function(){if(d.readyState=="loaded"||d.readyState=="complete")d.onreadystatechange=null,typeof c!="undefined"&&c()}:d.onload=function(){typeof c!="undefined"&&c()},d.src=a,document.getElementsByTagName("head")[0].appendChild(d)}
// Load the SiteCatalyst related script files:
wa.iID = "";
wa.trackingDone = false;
wa.loadScript(wa.protocol+"://" + wa.host + "/Style Library/Vgz/script/s_code_vgz.js", function() { // Label specific	
}, function() {
	wa.loadScript(wa.protocol+"://" + wa.host + "/Style Library/Vgz/script/s_code_bp.js", function() {}, function(){ // Best practice
		// Search for the wa.pagecode on the page. When it has been found execute a SiteCatalyst request.
		wa.iID = window.setInterval(function() {
			if (typeof(wa.doTrack) != "undefined" && wa.doTrack == "yes" && typeof(wa.sct) != "undefined" && typeof(wa.sct) == "function") {	
				wa.doTrack = "no";	
				wa.sct();
				wa.trackingDone = true;
				clearInterval(wa.iID);
			}
		}, 100);
	});
});

window.onload = function() {
	if(wa.trackingDone == true) clearInterval(wa.iID);
	else var t = setTimeout("clearInterval(wa.iID)", 100);
	
	wa.track = function(startTracking) {
		wa.sct();
	}
}
