<!--
// Declare search engines. These strings are going to be matched by referrer.
var rExp = /(\d{2,9})\|?(\d{0,5})/;
var engines = new Array("google", "yahoo", "msn", ".aol.", "a9.com", "prweb.com", ".ask.", ".alltheweb.", ".altavista.", ".dogpile.","bing","baidu");
	
// Declare a source code for each engine.
engines["google"] = '06v43';
engines["yahoo"] = '6fzt8';
engines["msn"] = '1vpqd';
engines[".aol."] = 20011;
engines["a9.com"] = 20012;
engines["prweb.com"] = 80694;
engines[".ask."] = 81090;
engines[".alltheweb."] = 81091;
engines[".altavista."] = 81092;
engines[".dogpile."] = 81093;
engines["bing"] = '0u1fl';
engines["baidu"] = '0dtxm';


var search_terms = new Array("online casino",  "online slots",  "online gambling",  "online casino gambling",  "internet casino",  "online internet casino",  "internet casino gambling",  "online roulette",  "online blackjack",  "online keno",  "best online casino",  "blackjack online",  "online casino games",  "online bingo",  "multiline slots",  "online casino craps",  "intercasino");
search_terms["online casino"] = "09681"; 	search_terms["online slots"] = "09682"; 	search_terms["online gambling"] = "09683"; 	search_terms["online casino gambling"] = "09684"; 	search_terms["internet casino"] = "09685"; 	search_terms["online internet casino"] = "09686"; 	search_terms["internet casino gambling"] = "09687"; 	search_terms["online roulette"] = "09688"; 	search_terms["online blackjack"] = "09689"; 	search_terms["online keno"] = "09690"; 	search_terms["best online casino"] = "09691"; 	search_terms["blackjack online"] = "09692"; 	search_terms["online casino games"] = "09693"; 	search_terms["online bingo"] = "09694"; 	search_terms["multiline slots"] = "09695"; 	search_terms["online casino craps"] = "09696"; search_terms["intercasino"] = "09697"; 
	
var cookie301 = getCookie('301');
var tracking_code = window.location.search;
tracking_code = tracking_code.substring(1,tracking_code.length);

var set_cookies = false;

// 301 cookie
if (cookie301) {

	set_cookies = true;
	tracking_code = cookie301;
	
	// delete 301 cookie.
	var expiresAt = new Date();
	expiresAt.setFullYear(expiresAt.getFullYear() - 1);
	document.cookie ="301=; expires=" + expiresAt.toGMTString() +"; path=/";	

// this is to catch old school tracking via query string (shouldnt be needed)
} else if(tracking_code.length>1 && tracking_code != 'undefined'){

		set_cookies = true;
	
// referrer tracking
} else {
	
	var phrase_id = null;
	var allurl = (self != top) ? parent.document.referrer : document.referrer; 
	allurl = allurl.toLowerCase();
	
		// If we have a "?"
	if (allurl.indexOf("?") != -1) {
		//Get rid of site name, we only want data after the ".com" part
		var nositename = allurl.split("?");
		
		//split on "&"
		var terms_array = nositename[1].split("&");
	}
	else {
		var terms_array = allurl.split("&");
	}
	
	// Declare search engines. These strings are going to be matched by referrer.
	

	//test engine against referrer.
	for (i=0; i<engines.length; i++) { 
		
		var result = allurl.indexOf(engines[i]);
		if (result != -1) {
			//We have an ENGINE match
						
			if (engines[i] == "google" || engines[i] == "64.233.167.104") {
					// Stop redirect
					var stop_redirect = 1;
					//And allow exit traffic
					parent.no_exit_question = 0;
			}
			
			//Test for search terms
			for (a=0; a<search_terms.length; a++) {
				
				//Make sure url and search phrase are in lower case
				
				search_term_lowercase = search_terms[a].toLowerCase();
				
				//OK, here we loop through the Splitted refferer URL. We check each 
				//element, and look for the above search term
				for (b=0; b<terms_array.length; b++) {	
					//if "q=" or "p=" is found
					if (terms_array[b].indexOf("q=") != -1 || terms_array[b].indexOf("p=") != -1) {
						
						//get rid of the search prefix ("p=" or "q=") for comparison purposes
						query_with_no_search_param = terms_array[b].replace(/p=|q=/g, "");
				
						//If one of the terms in 'search_terms' is found...
						if (search_formatter(search_term_lowercase) == query_with_no_search_param){
						
						//assign phrse id the corresponding creative id
						phrase_id = search_terms[search_terms[a]];
						
						}
					}
				}
			}
			
			//If we have a match, retrieve src code for that engine and cookie user with it.
			set_cookies = true;
			tracking_code = engines[engines[i]];
			tracking_code = (phrase_id)?tracking_code + "|" + phrase_id : tracking_code;
		}
	}
	
}

if (!set_cookies && !getCookie('src_cd')) {
	tracking_code='5kf8d';
	set_cookies=true;
}

if (set_cookies) {
	
	
	
	//DATABLADE COOKIE
	var merchant_id_c2 = 'IC1';
	var merchant_id_cu = 'CUC';
	var merchant_id_d8 = 'D8C';
	var ioll_url = '<IMG '
	   + 'SRC="http://www.datablade.com/cgi-bin/image.cgi?';


		if(window.location.search.indexOf("&np") != -1){
			var postionOfnp = window.location.search.indexOf("&np");
			tracking_code = tracking_code.substring(0,postionOfnp -1);		
		}
		tracking_code = new String(tracking_code);
		// hbx 
		var result = tracking_code.match(rExp);
		/* hbx no longer used if (result != null) {
			if (result[1]) hbx.dcmp='OTL-'+result[1];
			if (result[2]) hbx.hra=result[2];
		} */
		//tracking_code = escape(tracking_code);
		forc2 = ioll_url+merchant_id_c2 + '|' + tracking_code 
		+ '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		forcu = ioll_url+merchant_id_cu + '|' + tracking_code 
		+ '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		ford8 = ioll_url+merchant_id_d8 + '|' + tracking_code 
		+ '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		document.write(forc2);	document.write(forcu);document.write(ford8);
	
		// Our cookie
		var expiresAt = new Date();
		expiresAt.setFullYear(expiresAt.getFullYear() + 1);
		document.cookie ="src_cd="+tracking_code+ "; expires=" + expiresAt.toGMTString() +"; path=/";	
	
	
}

function getCookie(Name) {   	

	var search = Name + "="   

	if (document.cookie.length > 0) { 
	
	// if there are any cookies      
	offset = document.cookie.indexOf(search)       

	if (offset != -1) { 
		// if cookie exists          
		offset += search.length          
		// set index of beginning of value         
		end = document.cookie.indexOf(";", offset)          
		// set index of end of cookie value         
		if (end == -1)             
			end = document.cookie.length         
			return unescape(document.cookie.substring(offset, end))      
		}    
	}
}
function search_formatter (phrase) {
	formatted = phrase.replace(/ /g, "+");
	return formatted;
}

//-->	
