
function getNewHTTPObject() {
	var xmlhttp;
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
	    xmlhttp = new XMLHttpRequest();
	    if (xmlhttp.overrideMimeType) {
	        xmlhttp.overrideMimeType('text/xml');
	        // See note below about this line
	    }
	} else if (window.ActiveXObject) { // IE
	    try {
	        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	        try {
	            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {}
	    }
	}
	
		if (!xmlhttp) {
	    return false;
	}
	
	return xmlhttp;
}

var tr_today = new Date();
var ms = tr_today.getTime();

var sdateObj = new Date("12/6/2011");
var ms_campaign_start = sdateObj.getTime();

var edateObj = new Date("12/8/2011");
var ms_campaign_end = edateObj.getTime();

var tr_exp_date = new Date(tr_today.getFullYear(), tr_today.getMonth(), tr_today.getDate(), 23, 59, 59, 0);
var tr_exp_time = (tr_exp_date.getTime() - tr_today.getTime())/86400000;

Set_Cookie("tr_test", 1, tr_exp_time);
var tr_tmp = Get_Cookie("tr_test");

if(tr_tmp != null) {

	tr_ad_unit = new Array();
	tr_ad_unit["id"] = 5;
	tr_ad_unit["width"] = 728;
	tr_ad_unit["height"] = 450;
	tr_ad_unit["views_per_ip"] = 1;
	tr_ad_unit["show_per_hour"] = 10;
	tr_ad_unit["timeout"] = 8000;
	tr_ad_unit["728x90"] = true;
	tr_ad_unit["300x250"] = true;
	
	var tr_shown = Get_Cookie("tr_shown");
	var tr_when = Get_Cookie("tr_when");
	
	if(tr_shown == null) {
		tr_shown = 0;
	} else {
		tr_shown = parseInt(tr_shown);
	}
	//alert(tr_shown);
	if(tr_when == null) {
		tr_when = 0;
	} else {
		tr_when = parseInt(tr_when);
	}
	
	if (ms >= ms_campaign_start) {
		if (ms < ms_campaign_end) {
			if(tr_shown < tr_ad_unit["views_per_ip"] && (tr_today.getTime() - tr_when) > 60000) {
			
					url = 'http://sync.darikweb.com/checkTransitionalIpRestrictions.php?s=2&c=' + tr_ad_unit["id"] + '';
					xmlHttp = getNewHTTPObject();
					var now = new Date();
					url += '?m=' + now.getYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds() + '';
					
					var tr_new_val = tr_shown + 1;
					Set_Cookie("tr_shown", tr_new_val, tr_exp_time);
					Set_Cookie("tr_when", tr_today.getTime(), tr_exp_time);
										
					window.location = 'http://gong.bg/ad.php?u=' + encodeURIComponent(window.location)  + '&s=2&a=' + tr_ad_unit["id"];
			}
		}
	}
}
					
