
setTimeout('at_senseadRun()', 100);

function at_senseadRun()
{
    //alert("at_senseadRun()")
    intCountCycle = intCountCycle + 1
	var ad = document.getElementsByTagName("iframe");
        var strIframeSrc = 'googlesy';
        strIframeSrc = strIframeSrc  + 'ndication.com';

	for ( var i = 0; i < ad.length; i++ ) {
		if ( ad[i].src.indexOf(strIframeSrc) > -1 ) {
			at_trackFrame( ad[i], 'at_senseadClick' );
		}
	}

	if ( ad.length < intNumBlocks && intCountCycle < intNumCycles )
	{
		setTimeout('at_senseadRun()', 500);
	}
	if ( ad.length < intNumBlocks && intCountCycle == intNumCycles )
	{
            //alert("error");
	    my_error_handler("at_senseadRun_error in number of frames");
	}
}

function at_senseadClick( frameObj )
{
    if (!blnDataSent)
    {
        at_debug('at_senseadClick');
	    var data = new Object();

	    if ( at_location != self.location ) {	// posiblity of page redirection with mouse over sensead frame (no click)
		    //at_cancelClick( frameObj );
		    //at_debug('cancelling click - location missmatch');
		    //return;
	    }

	    // link unit ?
	    if ( at_status && at_getUrlVar( frameObj.src, 'format').match(/ads_al/) ) {
		    at_debug("adlinks detected");
		    data['ad_url'] = window.status;
	    }
	    else if ( at_status ) {
	        at_debug('adlinks NOT detected');
	        var strBadStatus = 'http://services.goo';
                strBadStatus = strBadStatus + 'gle.com/feedback/';
		    if ( at_status.substr(0,36) == strBadStatus ) {
			    at_cancelClick( frameObj );
			    my_error_handler("at_senseadClick_strBadStatus");
			    return;
		    }

		    var match = at_status.match(/(\S+)$/);

		    if ( match != null )
			    data['ad_url'] = 'http://'+match[1];
	    }
	    //else if ( at_statusWorking ) {	// posiblity of clicking on blank space of iframe
	    //	at_cancelClick( frameObj );
	    //	at_debug('cancelling click - window.status missing, but working');
	    //	return;
	    //}

	    data['sys'] = "adsense";
	    data['src_title'] = document.title;
	    data['src_url'] = at_location;
	    data['channel'] = at_getUrlVar( frameObj.src, 'channel');
	    data['ad_size'] = frameObj.width+"x"+frameObj.height;
	    data['browser'] = at_browser();

        var name = "testcookie";
        var value = "testvalue";
        var exp = new Date();     //set new date object
        exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 1));     //set it 30 days ahead
        var expires = null
        document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());

        
	    at_storeClick( data );
	}
}