//************************
//  clicktx iframe type             *
//************************
// index.js curvy.js 

// Ad Space Counting (Global Object)
if (typeof clicktx_client === "undefined"){ var clicktx_client; }
if (typeof pinktx_spaceCount === "undefined"){ var pinktx_spaceCount=0;}
if (typeof pinktx_adCount === "undefined"){ var pinktx_adCount=0; }
pinktx_spaceCount++;

(function (){
var frameName='pinktx_frameName';
var baseDomain = 'pink.clicktx.jp';
var copyrightUrl = 'http://'+baseDomain+'/directory/';
var p = (("https:" == location.protocol) ? "https://" : "http://");
var baseUri = p+baseDomain;
var imgPass = '/img/wait.gif';
var apiPass = '/api';
var verDirPass = '/ads/v2/';
var bannerText = 'FreeAD pinkTX';

var clicktx_spec= {
    // Default
    '468x60': { 'x':'2','y':'1','font_size':'12,11,10', 'line_height':'1.1', 'imgSize':'', 'url':'block' },
    //'468x200': { 'x':'2','y':'3','font_size':'11,11,10', 'line_height':'1.2', 'imgSize':'', 'url':'block', 'blank':'3' },
    '468x200': { 'x':'1','y':'3','font_size':'17,13,12', 'line_height':'1.2', 'imgSize':'', 'url':'block', 'blank':'3' },
    // Nomal
    '728x90': { 'x':'3', 'y':'1', 'font_size':'15,12,11', 'line_height':'1.3', 'imgSize':'', 'url':'block', 'blank':'3' },
    //'728x90': { 'x':'2', 'y':'1', 'font_size':'18,13,12', 'line_height':'1.3', 'imgSize':'', 'url':'block', 'blank':'3' },
    //'728x200': { 'x':'3','y':'3','font_size':'11,11,10', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    //'728x200': { 'x':'2','y':'2','font_size':'20,14,12', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    '728x200': { 'x':'2','y':'3','font_size':'16,13,12', 'line_height':'1.3', 'imgSize':'', 'url':'none' },
    
    // Scraper Type
    '120x250': { 'x':'1','y':'2','font_size':'12,12,10', 'line_height':'1.3', 'imgSize':'', 'url':'none' },
    '160x300': { 'x':'1','y':'3','font_size':'13,12,10', 'line_height':'1.3', 'imgSize':'', 'url':'none' },
    //'120x600': { 'x':'1','y':'5','font_size':'12,11,10', 'line_height':'1.5', 'imgSize':'', 'url':'none' },
    '120x600': { 'x':'1','y':'4','font_size':'14,12,12', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    //'160x600': { 'x':'1','y':'5','font_size':'12,12,10', 'line_height':'1.5', 'imgSize':'', 'url':'block' },
    '160x600': { 'x':'1','y':'4','font_size':'16,13,12', 'line_height':'1.4', 'imgSize':'', 'url':'block' },
    
    // Square Type
    '250x250': { 'x':'1','y':'3','font_size':'14,12,10', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    //'300x250': { 'x':'1','y':'3','font_size':'12,12,11', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    '300x250': { 'x':'1','y':'3','font_size':'16,12,11', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    //'350x250': { 'x':'1','y':'3','font_size':'13,13,11', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    '350x250': { 'x':'1','y':'3','font_size':'18,13,11', 'line_height':'1.3', 'imgSize':'', 'url':'block' },
    /*  350x240 */
    /*https://markezine.jp/article/detail/6534*/
    
    // Button Type
    '120x120': { 'x':'1','y':'1','font_size':'12,11,10', 'line_height':'1.3', 'imgSize':'', 'url':'none' },
    '160x160': { 'x':'1','y':'1','font_size':'16,13,12', 'line_height':'1.4', 'imgSize':'', 'url':'block' },
    '180x180': { 'x':'1','y':'1','font_size':'18,14,13', 'line_height':'1.4', 'imgSize':'', 'url':'block' },
    
    // for BLOG
    '120x200': { 'x':'1','y':'2','font_size':'11,10,10', 'line_height':'1.3', 'imgSize':'', 'url':'none' },
    '160x200': { 'x':'1','y':'2','font_size':'11,11,10', 'line_height':'1.5', 'imgSize':'', 'url':'none' },
    
 // ++++ image ++++

    '120x380': { 'x':'1','y':'2','font_size':'12,12,10', 'line_height':'1.3', 'imgSize':'60', 'url':'none','align':'left' },
    //'120x380': { 'x':'1','y':'1','font_size':'15,15,12', 'line_height':'1.4', 'imgSize':'110', 'url':'block','align':'top' },
    '120x630': { 'x':'1','y':'3','font_size':'12,11,10', 'line_height':'1.2', 'imgSize':'110', 'url':'none','align':'top' },
    '120x950': { 'x':'1','y':'4','font_size':'12,12,11', 'line_height':'1.2', 'imgSize':'110', 'url':'block','align':'top' },

    //'160x380': { 'x':'1','y':'3','font_size':'12,12,10', 'line_height':'1.2', 'imgSize':'80', 'url':'none','align':'left' },
    '160x380': { 'x':'1','y':'3','font_size':'12,12,10', 'line_height':'1.2', 'imgSize':'70', 'url':'none','align':'left' },
    '160x630': { 'x':'1','y':'5','font_size':'12,12,10', 'line_height':'1.2', 'imgSize':'70', 'url':'none','align':'left' },
    '160x950': { 'x':'1','y':'7','font_size':'13,12,12', 'line_height':'1.3', 'imgSize':'70', 'url':'none','align':'left' },

    //'180x300': { 'x':'1','y':'1','font_size':'18,14,12', 'line_height':'1.3', 'imgSize':'155', 'url':'block','align':'top' },
    '180x300': { 'x':'1','y':'2','font_size':'13,12,10', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    //'180x600': { 'x':'1','y':'2','font_size':'16,13,12', 'line_height':'1.3', 'imgSize':'155', 'url':'block','align':'top' },
    '180x600': { 'x':'1','y':'5','font_size':'12,11,11', 'line_height':'1.2', 'imgSize':'80', 'url':'none','align':'left' },
    '180x950': { 'x':'1','y':'3','font_size':'16,14,12', 'line_height':'1.4', 'imgSize':'155', 'url':'block','align':'top' },
    //'180x950': { 'x':'1','y':'3','font_size':'14,14,12', 'line_height':'1.5', 'imgSize':'155', 'url':'block','align':'top' },

    //'200x300': { 'x':'1','y':'3','font_size':'11,10,10', 'line_height':'1.3', 'imgSize':'70', 'url':'none','align':'left' },
    '200x300': { 'x':'1','y':'2','font_size':'12,11,10', 'line_height':'1.3', 'imgSize':'110', 'url':'none','align':'left' },
    //'200x600': { 'x':'1','y':'6','font_size':'11,10,10', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    '200x600': { 'x':'1','y':'4','font_size':'12,11,10', 'line_height':'1.1', 'imgSize':'110', 'url':'none','align':'left' },

    '125x125': { 'x':'1','y':'1','font_size':'11,10,10', 'line_height':'1.1', 'imgSize':'60', 'url':'none','align':'left' },
    '165x165': { 'x':'1','y':'1','font_size':'12,12,10', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    '185x185': { 'x':'1','y':'1','font_size':'14,13,12', 'line_height':'1.3', 'imgSize':'80', 'url':'block','align':'left' },
    '200x200': { 'x':'1','y':'1','font_size':'14,13,12', 'line_height':'1.3', 'imgSize':'110', 'url':'block','align':'left' },

    '300x300': { 'x':'1','y':'3','font_size':'14,13,11', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    '350x350': { 'x':'1','y':'4','font_size':'16,14,11', 'line_height':'1.3', 'imgSize':'70', 'url':'none','align':'left' },
    //'350x350': { 'x':'1','y':'3','font_size':'16,14,11', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    '360x90': { 'x':'1','y':'1','font_size':'16,14,11', 'line_height':'1.3', 'imgSize':'70', 'url':'none','align':'left' },

    //'500x210': { 'x':'1','y':'2','font_size':'18,14,12', 'line_height':'1.3', 'imgSize':'80', 'url':'block','align':'left' },
    '500x210': { 'x':'2','y':'2','font_size':'14,12,10', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    //'600x350': { 'x':'1','y':'4','font_size':'18,14,12', 'line_height':'1.3', 'imgSize':'70', 'url':'blog','align':'left' },
    '600x350': { 'x':'2','y':'4','font_size':'14,13,11', 'line_height':'1.3', 'imgSize':'70', 'url':'none','align':'left' },
    //'600x350': { 'x':'2','y':'2','font_size':'16,13,11', 'line_height':'1.5', 'imgSize':'155', 'url':'none','align':'left' },
    '800x100': { 'x':'3','y':'1','font_size':'13,12,10', 'line_height':'1.3', 'imgSize':'80', 'url':'none','align':'left' },
    //'800x250': { 'x':'3','y':'3','font_size':'12,11,10', 'line_height':'1.5', 'imgSize':'60', 'url':'none','align':'left' }
    '800x250': { 'x':'3','y':'2','font_size':'16,13,10', 'line_height':'1.3', 'imgSize':'110', 'url':'none','align':'left' }
};
// __SPEC_END__

// --------------------------------------------------------------------
// Author  : mashimonator   
// Create  : 2009/07/22 
// Update  : 2009/07/22 
// Description : クロスブラウザでDOMContentLoadedのイベントリスナーを提供する   
// URL: http://mashimonator.weblike.jp/blog/2009/07/jsdomcontentloaded.html     
// --------------------------------------------------------------------

var clListener={

	isAlreadyDetect : false,
	isAlreadyExec : false,
	funcList : [],

	//-----------------------------------------
	// DOMContentLoadedイベントで実行する関数を登録する     
	//-----------------------------------------
	add : function( func ) {
		if ( clListener.isAlreadyExec ) {
			func.call();
		} else {
			clListener.funcList.push( function(){ return func.call(); } );
		}
	},

	//-----------------------------------------
	// DOMContentLoadedイベントを検知する       
	//-----------------------------------------
	detectEvent : function() {
		// check
		if ( clListener.isAlreadyDetect ) {
			return;
		} else {
			clListener.isAlreadyDetect = true;
		}
		// detect
		if ( document.addEventListener ) {
			// for Mozilla, Opera and webkit
			document.addEventListener('DOMContentLoaded', function(){
				document.removeEventListener('DOMContentLoaded', arguments.callee, false);
				clListener.exec();
			}, false);
		} else if ( document.attachEvent ) {
			// for IE(iframe)
			document.attachEvent('onreadystatechange', function(){
				if ( document.readyState === 'complete' ) {
					document.detachEvent('onreadystatechange', arguments.callee);
					clListener.exec();
				}
			});
			// for IE
			if ( document.documentElement.doScroll && window == window.top ) (function(){
				if ( clListener.isAlreadyExec ) return;
				try {
					document.documentElement.doScroll('left');
				} catch( error ) {
					setTimeout(arguments.callee, 0);
					return;
				}
				clListener.exec();
			})();
		}
	},

	//-----------------------------------------
	// 登録された関数を実行する     
	//-----------------------------------------
	exec : function() {
		if ( !clListener.isAlreadyExec ) {
			clListener.isAlreadyExec = true;
			if ( clListener.funcList ) {
				var len = clListener.funcList.length;
				for (var i = 0; i < len; i++) {
					clListener.funcList[i].apply();
				}
				clListener.funcList = null;
			}
		}
	}

}
clListener.detectEvent();
// __clListener_END__


// getQueryStrings
function getQueryStrings(){
    var script = document.getElementsByTagName( 'script' );
    var request = script[script.length-1].src;
    try { 
        var query =( request.match(/\?(.+)$/) )[1]; 
    } catch (e){ return 0; }
    // 
    var pairs = query.split(/&/);
    var form={};
    for (var i in pairs){
        var val = pairs[i].split(/=/);
        form[decodeURI(val[0])] = decodeURI(val[1]);
    }
return form;
};

// run getQueryStrings
var form;
if (!clicktx_client){ form = getQueryStrings(); }

if (form){  // 
    clicktx_client = form.u;
    clicktx_adformat = form.type;
    clicktx_round_value=0;
    clicktx_color_border = form.border;
    clicktx_color_bg = form.bgcolor;
    clicktx_color_hover='';
    clicktx_color_link = form.LINK;
    clicktx_color_text = form.TEXT;
    clicktx_color_url = form.URL;
}

// Error Check
if (clicktx_round_value > 3){clicktx_round_value=3;}
if (clicktx_client.search(/^\d{5}$/) == -1 || clicktx_client < 10000){clicktx_client='';}

// global to local
if (typeof clicktx_color_hover === "undefined"){ clicktx_color_hover=''; }
var client = clicktx_client || 10001;
var adformat = clicktx_adformat || '120x250';
var round_value=clicktx_round_value || 0;
var color_border = clicktx_color_border || '4477AA';
var color_bg = clicktx_color_bg || 'EFEFEF';
var color_hover = clicktx_color_hover || '';
var color_link = clicktx_color_link || '0000FF';
var color_text = clicktx_color_text || '0C0C0C';
var color_url = clicktx_color_url || '008800';
var adCount = pinktx_adCount;

// write inline flame 
var wh = adformat.split(/x/);
var ifrname=frameName+'_'+pinktx_spaceCount;
var callback = ifrname;

//document.write(ifrname);
document.write('<IFRAME  id="'+ifrname+'" name="'+ifrname+'" width="'+wh[0]+'" height="'+wh[1]+'" frameBorder="0" allowTransparency="true"  marginHeight="0" scrolling="no" MarginWidth="0" src="" style="margin:0;padding:0;width:'+wh[0]+'px;height: '+wh[1]+'px;"></IFRAME>');

var ifm = frames[ifrname];
ifm.document.open();
ifm.document.writeln('<div>');
ifm.document.writeln('<table border="0" width="100%" height="100%"><tr><td align="center" valign="middle">');
ifm.document.writeln('<img src="'+baseUri+imgPass+'" style="border:0;"/>');
ifm.document.writeln('</td></tr></table>');
ifm.document.writeln('</div>');
ifm.document.close(); 


var sp= clicktx_spec[adformat];
var requestCount = sp.x * sp.y;
pinktx_adCount += requestCount;    // ad total Count This Page  // 


clListener.add(function (){loaded(requestCount, adCount)});
clicktx_client=''; //2010-07-20
//__END_OF_RUN__


// loaded
function loaded(rc,ac){
    var query = 'mode=jsonp&callback='+callback+'&u='+client+'&requestCount='+rc+'&tx_count='+ac;
    var request = baseUri+apiPass+'?'+query;
    var sc = document.createElement('script');  
    sc.charset = 'Shift_JIS';  
    sc.src = request;
    document.getElementsByTagName("head").item(0).appendChild(sc);
}

// ad data call back
this[callback] = function (d){adsPrint(d, ifm, baseUri, wh, adformat, color_border, color_bg, color_hover, color_link, color_text, color_url, round_value);}


// printing ADS
function adsPrint(d, ifm, baseUri, wh, format, c_bo, c_bg, c_h, c_l, c_t, c_u, r_v){
    var p='';
    var sp= clicktx_spec[format];
    var loop=d.length;
    var li_w = parseInt((wh[0] -6 -3*(sp.x-1)) / sp.x);
    var li_h = parseInt((wh[1] -17 -3*sp.y) / sp.y);
    var f_size = sp.font_size.split(/,/);//font-size    
    var h=wh[1]-16;
    var c_logo = logo_color(c_bo);
    
    p+='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
    p+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
    p+='<head>\n';
    p+='<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" />\n';
    p+='<style><!--\n';
    p+='* { font-weight: normal;font-style: normal;font-family: Arial, sans-serif;}\n';
    p+='#space{ margin:0 auto;background-color:#'+c_bo+';width:'+wh[0]+'px;height:'+wh[1]+'px;}\n';
    p+='#contents{ position:relative;top:1px;margin:0 1px;background-color:#'+c_bg+';height:'+h+'px;}\n';
    //ad
    p+='#contents li{ overflow:hidden;margin:auto;display:block;float:left;width:'+li_w+'px;height:'+li_h+'px;}\n';

    var padding_left=2;
    var div_w=li_w-6;
    if (div_w > 160){ padding_left=7;div_w -= 5;}
    p+='#contents li a{ padding-top:2px;padding-left:'+padding_left+'px;display:block;text-decoration:none;text-align:left;}\n';
    // 'hover' is option
    if (color_hover) {c_h='background-color:#'+c_h+';';}
    p+='#contents li a:hover{ cursor:pointer;'+c_h+'}\n';

    if (sp.align != 'left'){p+='#contents li a div{ width:'+div_w+'px;}\n';}//check
    
    p+='#contents li a .title{ font-weight: bold;text-decoration: underline;color:#'+c_l+';font-size:'+f_size[0]+'px;line-height:'+sp.line_height+'em;}\n';
    p+='#contents li a .text{ color:#'+c_t+';font-size:'+f_size[1]+'px;line-height:'+sp.line_height+'em;}\n';
    p+='#contents li a .fqdn{ white-space:nowrap;overflow:hidden;color:#'+c_u+';font-size:'+f_size[2]+'px;display:'+sp.url+';line-height:'+sp.line_height+'em;}\n';

    p+='#copyright{ margin:0 1px;height:15px;background-color:#'+c_bg+';}\n';
    p+='#copyright li{ font-size:10px;float:right;display:block;height:15px;background-color:#'+c_bo+';}\n';
    p+='#left{ }\n';
    p+='div#left_in{ background-color:#'+c_bg+';width:12px;height:15px;}\n';
    p+='#right{ width:12px;}\n';
    p+='#text{ text-align:right;}\n';
    p+='#text a{ position:relative;top:2px;color:#'+c_logo+';}\n';
    var logo_margin=r_v*r_v+3;
    p+='a.logo{ margin-right:'+logo_margin+'px;}\n';
    p+='br{ display:none;}\n';
    p+='--></style>\n';
    p+='</head><body>\n';
    p+='<div id="space">\n';
    //contents
    p+='    <div id="contents">\n';
    var t_w = li_w*sp.x;
    p+='        <table width="'+t_w+'" height="'+h+'" cellpadding="0" cellspacing="0" align="center">\n';
    p+='            <tr><td align="center" valign="middle">\n';
    
    //ad
    var valign=((sp.x == 1) ? 'middle':'top' ); 
    p+='    <!-- ad start -->\n';
    // LOOP
        for (i=0; i<loop; i++){ ad(i); }
    
    p+='            </td></tr>\n';
    p+='        </table>\n';
    p+='    </div><!-- contents -->\n';
    
    //copyright
    p+='    <div id="copyright">\n';
    p+='        <li id="text"><a href="'+copyrightUrl+'" class="logo" target="_top">'+bannerText+'</a></li>\n';
    p+='        <li id="right">&nbsp;</li>\n';
    p+='        <li id="left"><div id="left_in">&nbsp;</div></li>\n';
    p+='    </div><!-- copyright -->\n';
    p+='        <br style="clear:both;" />\n';
    p+='</div><!-- space -->\n';
    p+='</body></html>';
    ifm.document.open();
    ifm.document.writeln(p);
    ifm.document.close();

    // curvy
    curvy(r_v);
    return false;

    function ad(i){
    var imgMargin={60:'0 5px 0 0', 70:'0 5px 0 0', 80:'0 7px 0 0', 110:'0 7px 5px 0', 115:'0 7px 7px 0', 155:'0 5px 7px 0'};
    var imgPass;
    //if (d[i]["img"]){ imgPass= '/tx/users/'+d[i]["no"]+'/img/'+d[i]["img"]+'.'+sp.imgSize;}
    if (d[i]["img"]){ imgPass= '/tx/users/'+d[i]["img"]+'.'+sp.imgSize;}
    else{ imgPass= '/tx/upload/no_image.jpg.'+sp.imgSize;}
    
        p+='<li>\n';
        p+='    <table width="100%" height="100%" cellpadding="0" cellspacing="0" style="word-break:break-all;">\n';
        p+='    <tr><td valign="'+valign+'">\n';
        p+='    <a href="'+d[i]["url"]+'"  target="_top">\n';
            
            if (sp.imgSize){
                p+='<img src="'+baseUri+imgPass+'" border="0" align="'+sp.align+'" style="margin:'+imgMargin[sp.imgSize]+';" width="'+sp.imgSize+'" height="'+sp.imgSize+'" />'; //border:1px solid #6C6C6C; 
            }
            
        p+='        <div class="title">'+d[i]["title"]+'</div>\n';
        p+='        <div class="text">'+d[i]["text"]+'</div>\n';
        p+='        <div class="fqdn">'+d[i]["fqdn"]+'</div>\n';
        p+='    </a>\n';
        p+='    </td></tr></table>\n';
        p+='</li>\n';
    } // ad

    function curvy(r_v){
        if (!r_v){r_v=0;}
        var sc = document.createElement('script');  
        sc.text = 'var round_value = '+r_v+';';
        ifm.document.getElementsByTagName("head")[0].appendChild(sc);
        var sc = document.createElement('script');  
        sc.src = baseUri+verDirPass+'curvy.js';
        ifm.document.getElementsByTagName('head')[0].appendChild(sc);
    }// curvy
    
    function logo_color(n){
        r = '0x'+n.substr(0,2);
        g = '0x'+n.substr(2,2);
        b = '0x'+n.substr(4,2);
        r = Number(r);
        g = Number(g);
        b = Number(b);
        r = r.toString(10);
        g = g.toString(10);
        b = b.toString(10);
        rgb=(Number(r)+Number(g)+Number(b))/3; 
        var c='000000';
        if (rgb<164 && g<192){c='FFFFFF';}
        return c;
    }//logo_color

} // adsPrint


// __END__
})();

 /****************************************************************
  *    著作権表示                                                          *
  *  clicktx ADS JavaScript                                                *
  *                                                              *
  *  Version 1.0.3 (2010.07.20)                                               *
  *  Copyright (c) 2010- clicktx                            *
  *                                                              *
  *  Website: http://www.clicktx.jp/                        *
  *                                                              *
  * 更新履歴                                                             *
  * 2010-07-20  v1.0.3  getQueryStringsの実行をパラメーターが無い場合にのみに制限       
  ****************************************************************/