var this_url = parseUri(window.location.href+''); var tmp1 = this_url['domain'].split('.'); subdomain = tmp1[tmp1.length-3]; //spac_writeAd('/site=sanook.com/area=test/position=pos.right/aamsz=160x600/method=JSCRIPT',52); spac_writeAd('/site=sanook.com/area=sanook.'+subdomain+'.gallery/position=pos.right/aamsz=160x600/method=JSCRIPT',52);