// 
// Rev2.0 Copyright 2005-2010 activecore. Inc. 
//
// ad insight V1.3 - API
// This software/code is licensed by activecore, Inc.
// You can N O T modify/use/distribute this file except in compliance with the License.
//
var _c_host = 'tracer.a-cast.jp';
function _adFillZero(s) {
	var digits = 5;
	if (s == null || s == undefined) {
		return s;
	}
	return Array((digits + 1) - s.toString().split('').length).join('0') + s;
}
function _adGetAPIQuery(_js, _cid, _var, _isDir, _testIP, _options) {
	try {
		var _c_proto = window.location.protocol;
		var _now = new Date();
		var _url = "";//escape(window.location);
		var _dir = '';
		var _optionParams = '';

		if (_isDir != undefined) {
			if (_isDir == 'y') {
				_dir = '/c' + _adFillZero(_cid);
			}
		}
		if (_options != undefined && _options != '') {
			_optionParams = '&' + _options;
		}
		var _url = _c_proto + '//' + _c_host + _dir + _js + '?cid=' + _cid 
				  + '&' + 'var=' + _var + '&' + 'url=' + _url 
				  + _optionParams
		          + '&rand=' + Math.round(Math.random() * _now.getTime()); 
		if (_testIP != undefined) {
			_url += '&ac_test_ip=' + _testIP; 
		}
		document.write('<scr' + 'ipt type="text/javascript" ' 
			+ 'language="JavaScript" src="' 
			+ _url + '" ></' + 'scr' + 'ipt>'); 

	} catch (e) {
		// alert(e);
	}
}
function getDivisionQuery(_cid, _var, _testIP) {
	var _js = '/division.js';
	_adGetAPIQuery(_js, _cid, _var, 'y', _testIP);
	return;
}
function getCityQuery(_cid, _var, _testIP) {
	var _js = '/city.js';
	_adGetAPIQuery(_js, _cid, _var, 'y', _testIP);
	return;
}
function getPageSegmentQuery(_cid, _var, _type) {
	var _js = '/page_segment.js';
	var _options = '';
	if (_type != undefined) {
		_options = 'page_type=' + _type;
	}
	_adGetAPIQuery(_js, _cid, _var, 'y', '', _options);
	return;
}

