// Rev1.3 Copyright 2005-2008 activecore. Inc. 
var _c_creative_js = "//tracer.a-cast.jp/creative_click.js?cid="; 
function _adGetCookie(cn) {
   var get_data = document.cookie;
   var cv = new Array();
   var gd = get_data.split(";");
   var i;
   for (i = 0; i < gd.length; i++) { 
      var a = gd[i].split("=");
      a[0] = a[0].replace(" ","");
      cv[a[0]] = a[1];
   }
   if (cv[cn]) return cv[cn];
   else return "";
}
function _adSetCookie(cn,val,exp) {
   document.cookie = cn + "=" + val + "; path=/; expires=" + exp + ";";
}
function writeFlash(tags) {
 	document.write(tags); 
}
function _ACast(_target, _alt, _alt_link, _width, _height, _location_id) {
	this.ref=escape(document.referrer);
	try {
		if( parent != self ){
			this.ref=escape(top.document.referrer);
		}
	} catch(e) {
     	// this.ref = escape(document.referrer);
   	}
	this.url=escape(window.location);
	this.target = _target;
	this.alt = _alt;
	this.alt_link = _alt_link;
	this.timerId = null;
	this.timeout = 10 * 1000;
	this.width = _width;
	this.height = _height;
	this.location_id = _location_id;
}
_ACast.prototype.timeoutHandler = function() {
	clearInterval(this.timerId);
	var _id = document.getElementById("ID" + this.location_id);
	if (_id == null) {
		var _alt_id = document.getElementById(this.location_id);
		if (_alt_id != null && this.alt != '') {
			if (_alt_id.innerHTML) {
				_alt_id.innerHTML = '<a href="' + this.alt_link + '">' 
				+ '<img src="' + this.alt + '" border="0" alt="" width="' + this.width + '" height="' + this.height + '">' + '</a>';
			}
		}
	}	
}
_ACast.prototype.request = function() {
    var _now = new Date();
	this.timerId = setInterval( "_aCast_" + this.location_id + ".timeoutHandler()" , this.timeout);
	var _ac_ck = _adGetCookie('ac'); 
	var _adsvr_ck = _adGetCookie('ac_adsvr');
	document.write('<script language=\"JavaScript\" src=\"' + this.target + 'url=' + this.url + ';' + 'referer=' + this.ref + ';rand=' + Math.round(Math.random() * _now.getTime()) + ';' + location.protocol 
	+ ';ac_del=&' + 'ac_ck=' + _ac_ck + '&adsvr_ck=' + _adsvr_ck +  '\"><\/script>');
}
function _void() { 
	return; 
}
function ac_SetStatus(_cid, _status, _url) {
    if (_status == "") return;
    if (_cid == "") return;
    var _now = new Date();
    var _proto=location.protocol;
    if (_proto != "http:" && _proto != "https:") {
		return;
	}
	var _path=_proto + '//' + _url + '?' + "st_" + _cid + "=" + _status;
	document.write('<script language=\"JavaScript\" src=\"' + _path + '&' + 'rand=' + Math.round(Math.random() * _now.getTime()) + '\"><\/script>');
	
}

function _aCastNoRedirectClick(_redirectURL, _c_location_id, _c_creative_id, _c_cid, _adsvr_ck, _ac_ck) {
	var _c_proto = window.location.protocol;
	var _now = new Date();
	if (_c_proto == "http:" || _c_proto == "https:") {
		var _path = _c_proto 
		+ _c_creative_js + _c_cid + '&location_id=' + _c_location_id 
		+ '&creative_id=' + _c_creative_id
		+ '&rand=' + Math.round(Math.random() * _now.getTime()) 
		+ ';ac_del=&ac_ck=' + _ac_ck 
		+ '&adsvr_ck=' + _adsvr_ck 
		;
		var _img=new Image(1,1);
		_img.src=_path;
		_img.onload=function() {_void();}
	}
	location.href=_redirectURL;
	return;
}


