/*

	Channel Manager Light

*/



var campagna =
{
	'PAYPAL':'Direct Email Marketing',
	'TRADEDOUBLER' : 'Affiliazione',
	'ZANOX' : 'Affiliazione',
	'NL_' : 'Newsletter',
	'KLK' : 'Comparatore',
	'TRVP' : 'Comparatore',
	'CRITEO' : 'Retargeting',
	'ADWMEDIA' : 'Ad Network',
	'KNC' : 'Paid Search',
	'SMA' : 'Social Media Analytics',
	'BWA' : 'Blog Web Analytics'
};

var social =

{
'Facebook' : 'facebook.com',
'Twitter' : 'twitter.com',
'MySpace' : 'myspace.com',
'LinkedIn' : 'linkedin.com',
'Classmates' : 'classmates.com',
'Tagged' : 'tagged.com',
'Hi5' : 'hi5.com',
'Orkut' : 'orkut.com',
'Flixster' : 'flixster.com',
'My Year Book' : 'myyearbook.com',
'NetLog' : 'netlog.com',
'Flickr' : 'flickr.com',
'Badoo' : 'badoo.com',
'Ning' : 'ning.com',
'Dada' : 'dada.net',
'Veoh' : 'veoh.com',
'LastFM' : 'last.fm',
'Xing' : 'xing.com',
'SlideShare' : 'slideshare.net'
};

var searchEngines =
{
'MSN - Italy':{kw:['q'],tl:['search.msn.it']},
'AltaVista':{kw:['q','r'],tl:['altavista.co']},
'Google - United Kingdom':{kw:['q'],tl:['google.co.uk']},
'Tiscali':{kw:['key'],tl:['tiscali.it']},
'Google - Romania':{kw:['q'],tl:['google.ro']},
'Google - Spain':{kw:['q'],tl:['google.es']},
'Google':{kw:['q'],tl:['google.co','googlesyndication.com']},
'Virgilio':{kw:['qs'],tl:['virgilio.it']},
'Google - Switzerland':{kw:['q'],tl:['google.ch']},
'Google - France':{kw:['q'],tl:['google.fr']},
'Google - Italy':{kw:['q'],tl:['google.it']},
'MSN UK':{kw:['q'],tl:['msn.co.uk']},
'Ask Jeeves':{kw:['ask','q'],tl:['ask.com','ask.co.uk']},
'MSN':{kw:['q'],tl:['msn.com']},
'Libero':{kw:['query'],tl:['libero.it']},
'Google - US':{kw:['q'],tl:['google.com']},
// Forse devo commentare la prossima riga

//'SEM':{i:['DCMP'],}
'Sina - China':{kw:['q'],tl:['google.cn/search?client=aff-sina']},
'National Directory':{kw:['query'],tl:['search.NationalDirectory.com']},
'eerstekeuze.nl':{kw:['Terms'],tl:['http://www.eerstekeuze.nl/']},
'Excite - Netscape':{kw:['general','search'],tl:['excitesearch.netscape.com','searchexcite.netscape.com']},
'Andromeda Search':{kw:['keyword'],tl:['p-search.virtualave.net']},
'So-net':{kw:['MT'],tl:['so-net.search.goo.ne.jp']},
'InfoSeek - Japan':{kw:['query','qt'],tl:['search.m.infoseek.co.jp']},
'Goo (Japan)':{kw:['MT'],tl:['search.mobile.goo.ne.jp']},
'AllSearchEngines':{kw:['query'],tl:['allsearchengines.co.uk']},
'zoeken.nl':{kw:['query'],tl:['http://www.zoeken.nl/']},
'Northern Light':{kw:['qr'],tl:['www.northernlight.com']},
'Biglobe':{kw:['q'],tl:['search.biglobe.ne.jp']},
'track.nl':{kw:['qr'],tl:['http://www.track.nl/']},
'Baidu':{kw:['wd','s'],tl:['http://www.baidu.com']},
'3721.com':{kw:['p'],tl:['http://www.3721.com/']},
'Galaxy':{kw:[''],tl:['galaxy.tradewave.com']},
'Google - Norway (Startsiden)':{kw:['q'],tl:['google.startsiden.no']},
'NetSearch':{kw:['Terms','search'],tl:['netsearchvoyager.com','netsearch.org']},
'au.Anzwers':{kw:['p'],tl:['au.anzwers.yahoo.com']},
'MSN - Latin America':{kw:['q'],tl:['search.latam.msn.com']},
'Searchteria':{kw:['p'],tl:['ad.searchteria.co.jp']},
'FreshEye':{kw:['ord','kw'],tl:['search.fresheye.com']},
'Metacrawler':{kw:['general','/search/web/'],tl:['www.metacrawler.com','search.metacrawler.com']},
'Yahoo! - Austria':{kw:['p'],tl:['at.search.yahoo.com']},
'Yahoo! - Spanish (US : Telemundo)':{kw:['p'],tl:['telemundo.yahoo.com','espanol.search.yahoo.com']},
'Business.com':{kw:['query'],tl:['business.com/search']},
'Yahoo! - Switzerland':{kw:['p'],tl:['ch.search.yahoo.com']},
'Yahoo! - Finland':{kw:['p'],tl:['fi.search.yahoo.com']},
'Dino Online':{kw:['query'],tl:['www.dino-online.de']},
'Internet Times':{kw:['search','query'],tl:['internet-times.com']},
'TheYellowPages':{kw:['search'],tl:['theyellowpages.com']},
'Web-Search':{kw:['q'],tl:['www.web-search.com']},
'Yahoo! - Malaysia':{kw:['p'],tl:['malaysia.yahoo.com','malaysia.search.yahoo.com']},
'WebCrawler':{kw:['searchText','search'],tl:['www.webcrawler.com']},
'Monster Crawler':{kw:['qry'],tl:['monstercrawler.com']},
'Sina - Hong Kong':{kw:['word'],tl:['google.sina.com.hk']},
'Sina - Taiwan':{kw:['kw'],tl:['google.sina.com.tw']},
'YahooJapan - Mobile':{kw:['p'],tl:['mobile.yahoo.co.jp']},
'Livedoor - Mobile':{kw:['q','keyword'],tl:['dir.m.livedoor.com']},
'Blue Window':{kw:['q','qry'],tl:['search.bluewin.ch','search.bluewindow.ch']},
'General Search':{kw:['keyword'],tl:['generalsearch.com']},
'InternetTrash':{kw:['words'],tl:['internettrash.com']},
'MSN - United Kingdom':{kw:['q'],tl:['uk.search.msn.com','msn.co.uk']},
'Yahoo! - Chinese (US)':{kw:['p'],tl:['chinese.yahoo.com']},
'MSN - Singapore':{kw:['q'],tl:['search.msn.com.sg']},
'MSN - Republic of the Phlippines':{kw:['q'],tl:['search.msn.com.ph']},
'MSN - Taiwan':{kw:['q'],tl:['search.msn.com.tw']},
'MSN - Turkey':{kw:['q'],tl:['search.msn.com.tr']},
'MSN - People\'s Republic of China':{kw:['q'],tl:['search.msn.com.cn']},
'MSN - Malaysia':{kw:['q'],tl:['search.msn.com.my']},
'MSN - Hong Kong S.A.R.':{kw:['q'],tl:['search.msn.com.hk']},
'MSN - Brazil':{kw:['q'],tl:['search.msn.com.br']},
'Google @ EZweb':{kw:['query'],tl:['ezsch.ezweb.ne.jp']},
'AltaVista - Netherlands':{kw:['q'],tl:['nl.altavista.com']},
'AltaVista - Spain':{kw:['q','r'],tl:['es.altavista.com']},
'AltaVista - Italy':{kw:['q','r'],tl:['it.altavista.com']},
'AltaVista - Canada':{kw:['q'],tl:['ca.altavista.com']},
'AltaVista - Switzerland':{kw:['q','r'],tl:['ch.altavista.com']},
'AltaVista - France':{kw:['q','r'],tl:['fr.altavista.com']},
'AltaVista - United Kingdom':{kw:['q','r'],tl:['uk.altavista.com']},
'AltaVista - Sweden':{kw:['q','r'],tl:['se.altavista.com']},
'DejaNews':{kw:['QRY'],tl:['www.dejanews.com']},
'Excite':{kw:['/search/web/','qkw'],tl:['msxml.excite.com']},
'Globe Crawler':{kw:['search'],tl:['globecrawler.com']},
'HotBot':{kw:['MT','query'],tl:['hotbot.lycos.com']},
'InfoSeek':{kw:['qt'],tl:['www.infoseek.com','infoseek.go.com']},
'MSN - South Africa':{kw:['q'],tl:['search.msn.co.za']},
'MSN - Isreal':{kw:['q'],tl:['search.msn.co.il']},
'MSN - Japan':{kw:['q'],tl:['search.msn.co.jp']},
'MSN - Canada':{kw:['q'],tl:['sympatico.msn.ca','search.fr.msn.ca']},
'MSN - Korea':{kw:['q','query'],tl:['search.msn.co.kr']},
'Search City':{kw:['search','keyword'],tl:['searchcity.co.uk']},
'Search Viking':{kw:['search'],tl:['searchviking.com']},
'Thunderstone':{kw:['q'],tl:['thunderstone.com']},
'Web Wombat (Au.)':{kw:['I','ix'],tl:['webwombat.com.au']},
'AltaVista - Norway':{kw:['q'],tl:['no.altavista.com']},
'AltaVista - Denmark':{kw:['q'],tl:['dk.altavista.com']},
'MSN - India (English)':{kw:['q'],tl:['search.msn.co.in']},
'MSN - Indonesia (English)':{kw:['q'],tl:['search.msn.co.id']},
'Nifty':{kw:['Text'],tl:['search.nifty.com']},
'ANZWERS':{kw:['query'],tl:['www.anzwers.com']},
'BuyersIndex':{kw:['query'],tl:['buyersindex.com']},
'CNET Search.com':{kw:['q'],tl:['cnet.search.com']},
'Dmoz':{kw:['search'],tl:['search.dmoz.com','dmoz.com']},
'Final Search':{kw:['pattern'],tl:['finalsearch.com']},
'FullWebinfo Directory & Search Engine':{kw:['k','s'],tl:['fullwebinfo.com']},
'Go (Infoseek)':{kw:['qt'],tl:['infoseek.go.com']},
'GoEureka':{kw:['q','key'],tl:['goeureka.com.au']},
'Live.com':{kw:['q'],tl:['search.live.com']},
'QuestFinder':{kw:['s'],tl:['questfinder.com','questfinder.net']},
'SearchHound':{kw:['?'],tl:['searchhound.com']},
'TopFile.com':{kw:['query'],tl:['www.topfile.com']},
'Sina - North America':{kw:['search_key'],tl:['google.sina.com']},
'AOL.com Search':{kw:['query'],tl:['search.aol.com','search.aol.ca']},
'ByteSearch':{kw:['search','q'],tl:['bytesearch.com']},
'ComFind':{kw:[''],tl:['debriefing.com','allbusiness.comfind.com']},
'Dictionary.com':{kw:['term','query'],tl:['Dictionary.com','Dictionary']},  // Siamo fin qua
'ilse.nl':{kw:['search_for'],tl:['search.ilse.nl']},
'Infoseek - Japan':{kw:['qt'],tl:['infoseek.co.jp']},
'InfoSeek':{kw:['qt'],tl:['infoseek.co.uk']},
'Rex Search':{kw:['terms'],tl:['rex-search.com','rex-search.com']},
'Search King':{kw:['searchterm','keyword'],tl:['searchking.com']},
'Searchalot':{kw:['query','q'],tl:['searchalot.com']},
'Web Trawler':{kw:[''],tl:['webtrawler.com']},
'Yahoo! - Asia':{kw:['p'],tl:['asia.yahoo.com','asia.search.yahoo.com']},
'Yahoo! - Kids':{kw:['p'],tl:['kids.yahoo.com','kids.yahoo.com/search']},
'SmartPages.com':{kw:['QueryString'],tl:['smartpages.com']},
'MetaGopher':{kw:['query'],tl:['metagopher.com']},
'Froute':{kw:['k'],tl:['item.froute.jp','search.froute.jp']},
'All The Web':{kw:['query','q'],tl:['alltheweb.com']},
'DirectHit':{kw:['qry','q'],tl:['directhit.com']},
'Excite Canada':{kw:['search','q'],tl:['www.excite.ca','search.excite.ca']},
'Excite - Germany':{kw:['search','q'],tl:['www.excite.de']}
,'Excite - Dutch':{kw:['search'],tl:['nl.excite.com']},
'Google - Australia':{kw:['q'],tl:['google.com.au']},
'Google - Brasil':{kw:['q'],tl:['google.com.br']},
'InfoSpace':{kw:['QKW','qhqn'],tl:['infospace.com']},
'InfoTiger':{kw:['qs'],tl:['infotiger.com']},
'LookSmart':{kw:['key','qt'],tl:['looksmart.com','looksmart.co.uk']},
'Lycos':{kw:['query'],tl:['www.lycos.com','search.lycos.com']},
'Excite - Australia':{kw:['search','key'],tl:['excite.com.au']},
'Metacrawler - Germany':{kw:['qry'],tl:['216.15.219.34','216.15.192.226']},
'MSN - Netherlands':{kw:['q'],tl:['search.msn.nl']},
'MSN - Belgium':{kw:['q'],tl:['search.msn.be']},
'MSN - Germany':{kw:['q'],tl:['search.msn.de']},
'MSN - Austria':{kw:['q'],tl:['search.msn.at']},
'MSN - Spain':{kw:['q'],tl:['search.msn.es']},
'MSN - Italy':{kw:['q'],tl:['search.msn.it']},
'MSN - France':{kw:['q'],tl:['search.msn.fr']},
'MSN - Switzerland':{kw:['q'],tl:['search.msn.ch','fr.ch.msn.com']},
'MSN - Sweden':{kw:['q'],tl:['search.msn.se']},
'RageWorld.com':{kw:['search'],tl:['rageworld.com']},
'ToggleBot!':{kw:['search','query'],tl:['togglebot.com']},
'Web Wombat':{kw:['I','ix'],tl:['webwombat.com']},
'MSN - Norway':{kw:['q'],tl:['search.msn.no']},
'MSN - Denmark':{kw:['q'],tl:['search.msn.dk']},
'Google - Nicaragua':{kw:['q'],tl:['google.com.ni']},
'Google - Antigua and Barbuda':{kw:['q'],tl:['google.com.ag']},
'Google - Anguilla':{kw:['q'],tl:['google.com.ai']},
'Google - Taiwan':{kw:['q'],tl:['google.com.tw']},
'Google - Ukraine':{kw:['q'],tl:['google.com.ua']},
'Google - Namibia':{kw:['q'],tl:['google.com.na']},
'Google - Uruguay':{kw:['q'],tl:['google.com.uy']},
'Google - Ecuador':{kw:['q'],tl:['google.com.ec']},
'Google - Libya':{kw:['q'],tl:['google.com.ly']},
'Google - Norfolk Island':{kw:['q'],tl:['google.com.nf']},
'Google - Tajikistan':{kw:['q'],tl:['google.com.tj']},
'Google - Ethiopia':{kw:['q'],tl:['google.com.et']},
'Google - Malta':{kw:['q'],tl:['google.com.mt']},
'Google - Philippines':{kw:['q'],tl:['google.com.ph']},
'Google - Hong Kong':{kw:['q'],tl:['google.com.hk']},
'Google - Singapore':{kw:['q'],tl:['google.com.sg']},
'Google - Jamaica':{kw:['q'],tl:['google.com.jm']},
'Google - Paraguay':{kw:['q'],tl:['google.com.py']},
'Google - Panama':{kw:['q'],tl:['google.com.pa']},
'Google - Guatemala':{kw:['q'],tl:['google.com.gt']},
'Google - Isle of Gibraltar':{kw:['q'],tl:['google.com.gi']},
'Google - El Salvador':{kw:['q'],tl:['google.com.sv']},
'Google - Colombia':{kw:['q'],tl:['google.com.co']},
'Google - Turkey':{kw:['q'],tl:['google.com.tr']},
'Google - Peru':{kw:['q'],tl:['google.com.pe']},
'Google - Afghanistan':{kw:['q'],tl:['google.com.af']},
'Google - Malaysia':{kw:['q'],tl:['google.com.my']},
'Google - Mexico':{kw:['q'],tl:['google.com.mx']},
'Google - Viet Nam':{kw:['q'],tl:['google.com.vn']},
'Google - Nigeria':{kw:['q'],tl:['google.com.ng']},
'Google - Nepal':{kw:['q'],tl:['google.com.np']},
'Google - Solomon Islands':{kw:['q'],tl:['google.com.sb']},
'Google - Belize':{kw:['q'],tl:['google.com.bz']},
'Google - Puerto Rico':{kw:['q'],tl:['google.com.pr']},
'Google - Oman':{kw:['q'],tl:['google.com.om']},
'Google - Cuba':{kw:['q'],tl:['google.com.cu']},
'Google - Bolivia':{kw:['q'],tl:['google.com.bo']},
'Google - Bahrain':{kw:['q'],tl:['google.com.bh']},
'Google - Bangladesh':{kw:['q'],tl:['google.com.bd']},
'Google - Cambodia':{kw:['q'],tl:['google.com.kh']},
'Google - Argentina':{kw:['q'],tl:['google.com.ar']},
'Google - Brunei':{kw:['q'],tl:['google.com.bn']},
'Google - Fiji':{kw:['q'],tl:['google.com.fj']},
'Google - Saint Vincent and the Grenadine':{kw:['q'],tl:['google.com.vc']},
'Google - Qatar':{kw:['q'],tl:['google.com.qa']},
'MSN - Ireland':{kw:['q'],tl:['search.msn.ie']},
'Google - Pakistan':{kw:['q'],tl:['google.com.pk']},
'Google - Dominican Republic':{kw:['q'],tl:['google.com.do']},
'Google - Saudi Arabia':{kw:['q'],tl:['google.com.sa']},
'Google - Egypt':{kw:['q'],tl:['google.com.eg']},
'Google - Belarus':{kw:['q'],tl:['google.com.by']},
'Biglobe':{kw:['extrakey'],tl:['search.kbg.jp']},
'AltaVista':{kw:['q','r'],tl:['altavista.co']},
'AltaVista - Germany':{kw:['q','r'],tl:['altavista.de']},
'AOL - Germany':{kw:['q'],tl:['suche.aol.de','suche.aolsvc.de']},
'Excite - Japan':{kw:['search','s'],tl:['excite.co.jp']},
'Fansi"tes.com':{kw:['q1'],tl:['fansites.com']},
'FindLink':{kw:[''],tl:['"findlink.com']},
'GoButton':{kw:[''],tl:['gobutton.com']},
'Google - "India':{kw:['q'],tl:['google.co.in']},
'Google - New Zealand':{kw:['q'],tl:['google.co.nz']},
'Google - Costa Rica':{kw:['q'],tl:['go"ogle.co.cr']},
'Google - Japan':{kw:['q'],tl:['google.co.jp']},
'Goo"gle - United Kingdom':{kw:['q'],tl:['google.co.uk']},
'Google - Yugoslavia':{kw:['q'],tl:['google.co.yu']},
'Overture':{kw:['Keywords="'],tl:['overture.com']},
'Hotbot - United Kingdom':{kw:['query'],tl:['hotbot.co.uk']},
'Loquax Open Directory':{kw:['search'],tl:['loquax.co.uk']},
'MSN - Mexico':{kw:['q'],tl:['t1msn.com.mx','search.prodigy.msn.com']},
'Netscape Search':{kw:['query','search'],tl:['netscape.com']},
'Yahoo! - Philippines':{kw:['p'],tl:['ph.yahoo.com','ph.search.yahoo.com']},
'Yahoo! - Thailand':{kw:['p'],tl:['th.yahoo.com','th.search.yahoo.com']},
'Yahoo! - Argentina':{kw:['p'],tl:['ar.yahoo.com','ar.search.yahoo.com']},
'Yahoo! - Indonesia':{kw:['p'],tl:['id.yahoo.com','id.search.yahoo.com']},
'Yahoo! - Hong Kong':{kw:['p'],tl:['hk.yahoo.com','hk.search.yahoo.com']},
'Yahoo! - Russia':{kw:['p'],tl:['ru.yahoo.com','ru.search.yahoo.com']},
'Yahoo! - Canada':{kw:['p'],tl:['ca.yahoo.com','ca.search.yahoo.com']},
'Yahoo! - Taiwan':{kw:['p'],tl:['tw.yahoo.com','tw.search.yahoo.com']},
'Yahoo! - Catalan':{kw:['p'],tl:['ct.yahoo.com','ct.search.yahoo.com']},
'Yahoo! - Canada (French)':{kw:['p'],tl:['qc.yahoo.com','cf.search.yahoo.com']},
'Yahoo! - China':{kw:['p'],tl:['cn.yahoo.com','search.cn.yahoo.com']},
'Yahoo! - India':{kw:['p'],tl:['in.yahoo.com','in.search.yahoo.com']},
'Yahoo! - Brazil':{kw:['p'],tl:['br.yahoo.com','br.search.yahoo.com']},
'Yahoo! - Korea':{kw:['p'],tl:['kr.yahoo.com','kr.search.yahoo.com']},
'Yahoo! - Australia':{kw:['p'],tl:['au.yahoo.com','au.search.yahoo.com']},
'Yahoo! - Mexico':{kw:['p'],tl:['mx.yahoo.com','mx.search.yahoo.com']},
'Yahoo! - Singapore':{kw:['p'],tl:['sg.yahoo.com','sg.search.yahoo.com']},
'Yahoo! - Denmark':{kw:['p'],tl:['dk.yahoo.com','dk.search.yahoo.com']},
'Yahoo! - Germany':{kw:['p'],tl:['de.yahoo.com','de.search.yahoo.com']},
'Yahoo! - UK and Ireland':{kw:['p'],tl:['uk.yahoo.com','uk.search.yahoo.com']},
'Yahoo! - Sweden':{kw:['p'],tl:['se.yahoo.com','se.search.yahoo.com']},
'Yahoo! - Spain':{kw:['p'],tl:['es.yahoo.com','es.search.yahoo.com']},
'Yahoo! - Italy':{kw:['p'],tl:['it.yahoo.com','it.search.yahoo.com']},
'Yahoo! - France':{kw:['p'],tl:['fr.yahoo.com','fr.search.yahoo.com']},
'Yahoo! - Norway':{kw:['p'],tl:['no.yahoo.com','no.search.yahoo.com']},
'Google - Virgin Islands':{kw:['q'],tl:['google.co.vi']},
'Google - Uzbekiston':{kw:['q'],tl:['google.co.uz']},
'Google - Thailand':{kw:['q'],tl:['google.co.th']},
'Google - Israel':{kw:['q'],tl:['google.co.il']},
'Google - Korea':{kw:['q'],tl:['google.co.kr']},
'Yahoo! - Netherlands':{kw:['p'],tl:['nl.yahoo.com','nl.search.yahoo.com']},
'Yahoo! - New Zealand':{kw:['p'],tl:['nz.yahoo.com','nz.search.yahoo.com']},
'Google - Zambia':{kw:['q'],tl:['google.co.zm']},
'Google - South Africa':{kw:['q'],tl:['google.co.za']},
'Google - Zimbabwe':{kw:['q'],tl:['google.co.zw']},
'Yahoo! - Viet Nam':{kw:['p'],tl:['vn.yahoo.com','vn.search.yahoo.com']},
'Google - Uganda':{kw:['q'],tl:['google.co.ug']},
'Google - Indonesia':{kw:['q'],tl:['google.co.id']},
'Google - Morocco':{kw:['q'],tl:['google.co.ma']},
'Google - Lesotho':{kw:['q'],tl:['google.co.ls']},
'Google - Kenya':{kw:['q'],tl:['google.co.ke']},
'Google - Cook Islands':{kw:['q'],tl:['google.co.ck']},
'Google - Botswana':{kw:['q'],tl:['google.co.bw']},
'Google - Venezuela':{kw:['q'],tl:['google.co.ve']},
'BeGuide.com':{kw:['search'],tl:['beguide.com']},
'dog.com':{kw:['search'],tl:['doginfo.com']},
'Dogpile':{kw:['q','/search/web/'],tl:['dogpile.com']},
'Fireball':{kw:['q','query'],tl:['fireball.de']},
'FishHoo!':{kw:['query'],tl:['fishhoo.com']},
'InfoSeek - Germany':{kw:['qt','query'],tl:['infoseek.de']},
'Lycos - United Kingdom':{kw:['query'],tl:['lycos.co.uk']},
'MetaDog.com':{kw:['search','keyword'],tl:['metapro.com','metadog.com']},
'TooCool':{kw:['?'],tl:['toocool.com']},
'Yahoo! - Japan':{kw:['p','va'],tl:['yahoo.co.jp','search.yahoo.co.jp']},
'Cafesta':{kw:['keyword','keywords'],tl:['cafesta.com']},
'Oh! New? Mobile':{kw:['k'],tl:['ohnew.co.jp']},
'Chubba':{kw:['arg'],tl:['chubba.com']},
'CyberBritain.com':{kw:['qry'],tl:['hermia.com','cyberbritain.co.uk']},
'GeoBoz Search':{kw:['search'],tl:['geoboz.com']},
'Go2net Metacrawler':{kw:['general'],tl:['go2net.com']},
'Tiscali':{kw:['key'],tl:['tiscali.it']},
'TooZen':{kw:[''],tl:['toozen.com']},
'WAKWAK':{kw:['MT'],tl:['wakwak.com']},
'Webalta':{kw:['q'],tl:['webalta.ru']},
'MSN LiveSearch Mobile':{kw:['q'],tl:['m.live.com']},
'AOL - United Kingdom':{kw:['query'],tl:['aol.co.uk','search.aol.co.uk']},
'Dazzo!':{kw:['search'],tl:['dazzo.com']},
'Deoji':{kw:['search','k'],tl:['deoji.com']},
'Excite - France':{kw:['search','q'],tl:['excite.fr']},
'Excite.ch':{kw:['search','q'],tl:['excite.ch']},
'Godado':{kw:['Keywords'],tl:['godado.it']},
'Goo (Jp.)':{kw:['MT'],tl:['goo.ne.jp']},
'Google - Poland':{kw:['q'],tl:['google.pl']},
'Google - United Arab Emirates':{kw:['q'],tl:['google.ae']},
'Google - Luxembourg':{kw:['q'],tl:['google.lu']},
'Google - Slovakia':{kw:['q'],tl:['google.sk']},
'Google - Russia':{kw:['q'],tl:['google.ru']},
'Google - Denmark':{kw:['q'],tl:['google.dk']},
'Google - Portugal':{kw:['q'],tl:['google.pt']},
'Google - Romania':{kw:['q'],tl:['google.ro']},
'Google - Finland':{kw:['q'],tl:['google.fi']},
'Google - Latvia':{kw:['q'],tl:['google.lv']},
'Google - Guernsey':{kw:['q'],tl:['google.gg']},
'Google - Ireland':{kw:['q'],tl:['google.ie']},
'Google - Sweden':{kw:['q'],tl:['google.se']},
'Google - Lithuania':{kw:['q'],tl:['google.lt']},
'Google - Canada':{kw:['q'],tl:['google.ca']},
'Google - Spain':{kw:['q'],tl:['google.es']},
'Google Images':{kw:['q'],tl:['images.google.com']},
'Google Images':{kw:['q'],tl:['images.google.com']},
'Google Video':{kw:['q'],tl:['video.google.com']},
'Google':{kw:['q'],tl:['google.co','googlesyndication.com']},
'Google - Germany':{kw:['q'],tl:['google.de']},
'Google - Switzerland':{kw:['q'],tl:['google.ch']},
'Google - China':{kw:['q'],tl:['google.cn']},
'Google - Netherlands':{kw:['q'],tl:['google.nl']},
'Google - Austria':{kw:['q'],tl:['google.at']},
'Google - Belgium':{kw:['q'],tl:['google.be']},
'Google - Chile':{kw:['q'],tl:['google.cl']},
'Google - France':{kw:['q'],tl:['google.fr']},
'Google - Italy':{kw:['q'],tl:['google.it']},
'Nexet Open Directory':{kw:['SEARCH','q'],tl:['nexet.net']},
'Nomade':{kw:['s','MT'],tl:['nomade.fr']},
'Orbit.net':{kw:[''],tl:['orbit.net']},
'Search.ch':{kw:['q'],tl:['search.ch']},
'Yahoo!':{kw:['p'],tl:['yahoo.com','search.yahoo.com']},
'Google - Norway':{kw:['q'],tl:['google.no']},
'Google - Haiti':{kw:['q'],tl:['google.ht']},
'Google - Vanuatu':{kw:['q'],tl:['google.vu']},
'Google - Repulic of Georgia':{kw:['q'],tl:['google.ge']},
'Google - The Gambia':{kw:['q'],tl:['google.gm']},
'Google - Timor-Leste':{kw:['q'],tl:['google.tp']},
'Google - Armenia':{kw:['q'],tl:['google.am']},
'Google - British Virgin Islands':{kw:['q'],tl:['google.vg']},
'Google - American Samoa':{kw:['q'],tl:['google.as']},
'Google - Turkmenistan':{kw:['q'],tl:['google.tm']},
'Google - Trinidad and Tobago':{kw:['q'],tl:['google.tt']},
'Google - Cote D\'Ivoire':{kw:['q'],tl:['google.ci']},
'Google - Seychelles':{kw:['q'],tl:['google.sc']},
'Google - Greece':{kw:['q'],tl:['google.gr']},
'Google - The Bahamas':{kw:['q'],tl:['google.bs']},
'Google - Kyrgyzstan':{kw:['q'],tl:['google.kg']},
'Google - Saint Helena':{kw:['q'],tl:['google.sh']},
'Google - Burundi':{kw:['q'],tl:['google.bi']},
'Google - Tokelau':{kw:['q'],tl:['google.tk']},
'Google - Rep. du Congo':{kw:['q'],tl:['google.cg']},
'Google - Dominica':{kw:['q'],tl:['google.dm']},
'Google - Sao Tome and Principe':{kw:['q'],tl:['google.st']},
'Google - Rwanda':{kw:['q'],tl:['google.rw']},
'Google - Jordan':{kw:['q'],tl:['google.jo']},
'Google - Czech Republic':{kw:['q'],tl:['google.cz']},
'Yandex.ru':{kw:['text'],tl:['yandex.ru']},
'Google - Senegal':{kw:['q'],tl:['google.sn']},
'Google - Jersey':{kw:['q'],tl:['google.je']},
'Google - Honduras':{kw:['q'],tl:['google.hn']},
'Google - Greenland':{kw:['q'],tl:['google.gl']},
'Google - Hungary':{kw:['q'],tl:['google.hu']},
'Google - Island':{kw:['q'],tl:['google.is']},
'Google - Pitcairn Islands':{kw:['q'],tl:['google.pn']},
'Google - Mongolia':{kw:['q'],tl:['google.mn']},
'Google - Malawi':{kw:['q'],tl:['google.mw']},
'Google - Montserrat':{kw:['q'],tl:['google.ms']},
'Google - Liechtenstein':{kw:['q'],tl:['google.li']},
'Google - Micronesia':{kw:['q'],tl:['google.fm']},
'Google - Mauritius':{kw:['q'],tl:['google.mu']},
'Google - Moldova':{kw:['q'],tl:['google.md']},
'Google - Maldives':{kw:['q'],tl:['google.mv']},
'Google - Niue':{kw:['q'],tl:['google.nu']},
'Google - Kazakhstan':{kw:['q'],tl:['google.kz']},
'Google - Kiribati':{kw:['q'],tl:['google.ki']},
'Google - Nauru':{kw:['q'],tl:['google.nr']},
'Google - Laos':{kw:['q'],tl:['google.la']},
'Google - Isle of Man':{kw:['q'],tl:['google.im']},
'Google - Guyana':{kw:['q'],tl:['google.gy']},
'Google - Croatia':{kw:['q'],tl:['google.hr']},
'Google - Slovenia':{kw:['q'],tl:['google.si']},
'Google - Sri Lanka':{kw:['q'],tl:['google.lk']},
'Google - Azerbaijan':{kw:['q'],tl:['google.az']},
'Google - Bulgaria':{kw:['q'],tl:['google.bg']},
'Google - Bosnia-Hercegovina':{kw:['q'],tl:['google.ba']},
'Google - Tonga':{kw:['q'],tl:['google.to']},
'Google - Rep. Dem. du Congo':{kw:['q'],tl:['google.cd']},
'MSN - New Zealand':{kw:['q','mkt=en-nz'],tl:['msn.co.nz']},
'Google - Djibouti':{kw:['q'],tl:['google.dj']},
'Google - Guadeloupe':{kw:['q'],tl:['google.gp']},
'Google - Estonia':{kw:['q'],tl:['google.ee']},
'Google - Samoa':{kw:['q'],tl:['google.ws']},
'Google - San Marino':{kw:['q'],tl:['google.sm']},
'MSN UK':{kw:['q'],tl:['msn.co.uk']},
'Mobagee Search':{kw:['q'],tl:['s.mbga.jp']},
'Lycos - Italy':{kw:['query'],tl:['lycos.it']},
'Lycos - France':{kw:['query'],tl:['lycos.fr']},
'Lycos - Spain':{kw:['query'],tl:['lycos.es']},
'Lycos - Netherlands':{kw:['query'],tl:['lycol.nl']},
'Lycos - Germany':{kw:['query'],tl:['lycol.de','search.lycos.de']},
'Magellan':{kw:['search'],tl:['magellan']},
'myGO':{kw:['qry'],tl:['mygo.com']},
'NBCi':{kw:['keyword','qkw'],tl:['nbci.com']},
'Nate.com':{kw:['query'],tl:['nate.com','search.nate.com']},
'Crooz':{kw:['query'],tl:['crooz.jp']},
'Ask Jeeves':{kw:['ask','q'],tl:['ask.com','ask.co.uk']},
'MSN':{kw:['q'],tl:['msn.com']},
'AOL - France':{kw:['q'],tl:['aol.fr']},
'MetaIQ.com':{kw:['search','qry'],tl:['metaiq']},
'Web.de':{kw:['su'],tl:['web.de']},
'Ask - Japan':{kw:['q'],tl:['ask.jp']},
'Microsoft Bing':{kw:['q'],tl:['bing.com']}

}





var cm = cml();
/*
if(cm != 0)
{

	document.write(" id: " + cm.id);
	document.write(" referrer: "+ cm.referrer);
	document.write(" channel: "+ cm.channel);
	document.write(" Search Engine: "+ cm.searchEngines );
	document.write(" Search Keyword: " + cm.searchKeyword);

}else{

	document.write("No channel Manager");
}
*/
function get_tld(domain){
var urlTLD;
if(domain == "" || domain == null)
urlTLD = window.location.host;
else urlTLD = domain;

var temp = urlTLD.split(".");
var result = "";
for(var x = 1 ; x<3 ; x++)
{

	result = "." + temp[temp.length - x ] + result;

}

return result;

}


function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}


function set_cookie(nome , valore){
	
	document.cookie=nome+"="+valore+"; domain=" + get_tld() + "; path=/" ;

}

function newVisit(cookieName){
	if(get_cookie(cookieName)  == ""){
	// New Visit Start
	document.cookie=cookieName+"=New; domain=" + get_tld() + "; path=/" ;
	return 1;
	}else{
	
		return 0;
	}
}

function clickQuality(eventoC,cookieConto,eventoV)
{
var primaPagina;
if(newVisit('gvs'))
	{
		primaPagina = 1;
		primaPagina = document.cookie=cookieConto+"="+primaPagina+"; domain=" + get_tld() + "; path=/" ;
		if(s.events == "" || typeof s.events == 'undefined')s.events = eventoV;
			else s.events = s.events + ","+eventoV;
		
	}else{
		primaPagina = get_cookie(cookieConto)
		if(primaPagina == 1){
			primaPagina = 2;
			primaPagina = document.cookie=cookieConto+"="+primaPagina+"; domain=" + get_tld() + "; path=/" ;
			if(s.events == "" || typeof s.events == 'undefined')s.events = eventoC;
			else s.events = s.events + ","+eventoC;
		}
	}
};


function gup( name , domain)
{
	var lookIn;
	if(domain != "" && domain != null)
		lookIn = domain;
	else lookIn = window.location.href;

  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( lookIn );
  if( results == null )
    return "";
  else
    return results[1];
}

function get_domain(ref){


	var url = "";
var urlTemp = ref;//.substring(8,106);
var split = urlTemp.split("/");
url = split[2];
if(url==null)url="";
return url;
}

function cml(){
	
	
	var paidDetect = "cid";
	var internalLink = "webanalytics.it"

	var separatore = " - ";

	var referrer = document.referrer;
	
	var channel = new Object();
	channel.id = "";
	channel.channel = "";
	channel.referrer = referrer;
	channel.searchEngines = "";
	channel.searchKeyword = "";
	channel.socialNetwork = "";
	channel.full = "";
	
	var psd = gup(paidDetect);
	// Debug
	//document.write(" psd: " + psd);
	var esisteChannel = get_cookie('channel');
	if(referrer == "" && psd == "")
	{

		if(newVisit('gvsC')){
	
			channel.channel = 'Direct Load';
			channel.referrer = 'No referrer';
			channel.full = channel.channel + separatore + channel.referrer;
			set_cookie('channel' , channel.channel);
			
			return channel;
		}
		else{
			if(esisteChannel == "")
			{
			// non ho il referrer , ma non è la prima pagina della visita 
			// ???? Cosa è successo ???
			channel.channel = "Errore: Channel Manager non settato";
			channel.referrer = "Lost Data";
			channel.full = channel.channel + separatore + channel.referrer;
			set_cookie('channel' , channel.channel);
			return channel;
			}else return 0;
		}

	}else{
		channel.referrer = get_domain(referrer);
		if(channel.referrer == "")channel.referrer = "No Referrer";
		// Controllo se è un link interno
		var refTLD = get_domain(referrer);
		//var refTLD = referrer;
		// Debug
		//document.write(motore + " refDomain: " + refTLD);
		if(refTLD.indexOf(internalLink) >= 0)
		{
			// Il referrer è una pagina interna
			// Se questa è la prima pagina della visita allora ho perso per qualche motivo il referrer originale
			// devo quindi segnalare il prblema
			
			if(esisteChannel != "")
			return 0;
			else{
			
				channel.channel = "Internal Referrer";
				channel.referrer = referrer;
				channel.full = channel.channel + separatore + channel.referrer;
				set_cookie('channel' , channel.channel);
				return channel;
			}
		}	
		// Sono arrivato da un altro sito
		
		
		
		if(psd != "")
		{
		
			// Sono arrivato da una campagna
			channel.id = psd;
			
			// Cerco quale campagna sono (semplice con ID campagna intero)
			//channel.channel = campagna[psd];
			// Versione Complessa con riconoscimento all'interno del parametro in query string
			
			for(var id in campagna)
			{
				if(psd.indexOf(id) >= 0)
					channel.channel = campagna[id];
			}
			
			
			
			if(channel.channel == "" || channel.channel == null)
				channel.channel = 'Others';
				
			channel.full = channel.id + separatore + channel.channel + separatore + channel.referrer;
			
			if(channel.channel == "Paid Search")
			{
				// Cerco da quale motore di ricerca sono arrivato
				
				for(var motore in searchEngines)
				{
					var dom = searchEngines[motore]['tl'][0];
					var keyparam = searchEngines[motore]['kw'][0];
					// Debug
					//document.write(motore + " keyparam: " + keyparam);
				if(refTLD.indexOf(dom) >= 0)
					{
					channel.searchEngines = motore;
					channel.searchKeyword = gup( keyparam , referrer );
					break;
					}
				}
				if(channel.searchEngines == "")channel.searchEngines = channel.referrer;
				if(channel.searchKeyword == "")channel.searchKeyword = "No Keyword";
				channel.full = channel.searchEngines + separatore + channel.channel + separatore + channel.searchKeyword;
			}
			
			
			set_cookie('channel' , channel.channel);
			
			return channel;
		}else{
			if(channel.referrer == "")channel.referrer = "No referrer";
			// Non sono una campagna a pagamento
			// Forse sono un motore di ricerca
			for(var motore in searchEngines)
				{
					var dom = searchEngines[motore]['tl'][0];
					var keyparam = searchEngines[motore]['kw'][0];
					// Debug
					//document.write(motore + " keyparam: " + keyparam);
				if(refTLD.indexOf(dom) >= 0)
					{
					channel.channel = 'Organic';
					channel.searchEngines = motore;
					channel.searchKeyword = gup( keyparam , referrer );
					channel.full = channel.searchEngines + separatore + channel.channel + separatore + channel.searchKeyword;
					break;
					}
					
				}
				
			for(var snet in social)
			{
			
				var sdom = social[snet];
				if(refTLD.indexOf(sdom) >= 0)
					{
					channel.channel = 'Social Network';
					channel.socialNetwork = snet;
					channel.full = channel.socialNetwork + separatore + channel.channel;
					break;
					}
			
			
			
			}
				
				if(channel.searchKeyword == "")channel.searchKeyword = referrer;
				
				if(channel.channel == ""){
					
					channel.channel = "Referrer";
					channel.full = channel.channel + separatore + channel.referrer;
				}
				
				
				set_cookie('channel' , channel.channel);
				return channel;
		}
	
	
	}


}

