var merchant_id = 'IC1';
var ioll_url = '<IMG '
   + 'SRC="http://www.datablade.com/cgi-bin/image.cgi?';
var tracking_code = window.location.search;
tracking_code = tracking_code.substring(1,tracking_code.length);
if(window.location.search.indexOf("&np") != -1){
	var postionOfnp = window.location.search.indexOf("&np");
	tracking_code = tracking_code.substring(0,postionOfnp -1);
}
tracking_code = escape(tracking_code);
if(tracking_code.length>1 && tracking_code != 'undefined'){
ioll_url += merchant_id + '|' + tracking_code 
+ '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
document.write(ioll_url);		
	
	// hbx dynamic campaign
	var tracking_code = new String(tracking_code);
	var rExp = /(\d{2,9})\|?(\d{0,5})/;
	var result = tracking_code.match(rExp);
	if (result == null) {
		//alert('didnt match');
	} else {
		//alert (result[1] +' and '+ result[2]);
		if (result[1]) hbx.dcmp='OTL-'+result[1];
		if (result[2]) hbx.hra=result[2];
	}

}
/*else if (!getCookie("src_cd")) {
// User came in with no tracking code
	var input = new String(window.location);
	var rExp = /intercasino\.tv/;

	var matchResultat = input.match(rExp);
	if (matchResultat != null) { // If we are at .TV, cookie with 22002
		tracking_code = 22002;
		ioll_url += merchant_id + '|' + tracking_code + '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		document.write(ioll_url);		
	} else { // We are at .NET, cookie with 22001
		tracking_code = 22001;
		ioll_url += merchant_id + '|' + tracking_code + '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		document.write(ioll_url);	
	}
}*/
//-->	



src_cd = window.location.search;
src_cd = src_cd.substring(1,src_cd.length);
var expiresAt = new Date();
expiresAt.setFullYear(expiresAt.getFullYear() + 1);
if (src_cd.length > 0) { 
//	document.cookie ="src_cd="+escape(src_cd) + "; expires=" + expiresAt.toGMTString() +"; path=/";	}
	document.cookie ="src_cd="+src_cd+ "; expires=" + expiresAt.toGMTString() +"; path=/";	
} else if (!getCookie("src_cd")) {
	// We have no source code, so we are going to force one on them 
	//IF THEY HAVE NOT BEEN COOKIED BEFORE
	
	//If they do not have a source code.
	var input = new String(window.location);
	var rExp = /intercasino\.tv/;
	var matchResultat = input.match(rExp);
	if (matchResultat != null) { // If we are at .TV, cookie with 22002
		document.cookie ="src_cd=82263; expires=" + expiresAt.toGMTString() +"; path=/";	
		tracking_code = 82263;
		ioll_url += merchant_id + '|' + tracking_code + '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		document.write(ioll_url);		
		hbx.dcmp='OTL-82263';
		
	} else { // We are at .NET, cookie with 730055
		var cookie_content = "src_cd=82263; expires=" + t.toGMTString() + "; path=/";
		document.cookie = cookie_content;
		ioll_url += merchant_id + '|82263'
		+ '" WIDTH=1 HEIGHT=1 BORDER=0 ALT="">';
		document.write(ioll_url);
		hbx.dcmp='OTL-82263';
	}
}


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))      
		}    
	}
}