function NavisConvertTagToPhoneNumberBasic(t){
	switch (t){
		case "dealsonouterbanksvacationrentals": return("8008539013");
		case "operationweddingday": return("8662160503");
		case "easterncarolinaparent": return("8662256750");
		case "seeyatheredc": return("8662257175");
		case "soul": return("8662548801");
		case "visitncespecial": return("8662609917");
		case "guestquestohio": return("8662815629");
		case "luxurycondominiumsinemeraldisle": return("8662816946");
		case "condominiumsinemeraldisle": return("8662901328");
		case "condominiuminemeraldisle": return("8662902133");
		case "gvnobanner": return("8662964668");
		case "lastminutebeachrentalsnc": return("8663480121");
		case "rentabeach": return("8663480165");
		case "tenkvacationrentals": return("8663480270");
		case "emeraldislebeachhome": return("8663480914");
		case "lowesfoodtogo": return("8663481064");
		case "nccoastres": return("8663483177");
		case "nccoastevents": return("8663483178");
		case "nccoastsales": return("8663484165");
		case "luxurybeachhomesinemeraldisle": return("8663485962");
		case "grandevillasbwfeblast": return("8663487054");
		case "emeraldisledisocuntcodes": return("8663487157");
		case "findemeraldislecoupons": return("8663487159");
		case "luxurylink": return("8663488928");
		case "dscvachomes": return("8663488951");
		case "visitncgiveaway": return("8663489148");
		case "nobannerad": return("8663489925");
		case "craigslist": return("8663560449");
		case "novemberepostcard": return("8664392551");
		case "emeraldislenorthcarolinabeachhome": return("8664924996");
		case "condosinemeraldisle": return("8664986356");
		case "luxurybeachhomeinemeraldisle": return("8665043547");
		case "nowtaking": return("8665199130");
		case "weddingemail": return("8665258299");
		case "outerbanksnccondorentals": return("8665343771");
		case "rentalhomesemeraldislenc": return("8665343790");
		case "vacationrentalsinnorthcarolina": return("8665345790");
		case "vacationhomesonbeachinnorthcarolina": return("8665345795");
		case "rentalbeachhousesnorthcarolina": return("8665347952");
		case "A1Vacations": return("8665348921");
		case "CyberRentals": return("8665348926");
		case "GreatRentals": return("8665348929");
		case "HomeAway": return("8665348934");
		case "Potential Renter for Your Property": return("8665349912");
		case "oceanfrontvacationrentalsinnorthcarolina": return("8665350793");
		case "vacationrentalsemeraldislenc": return("8665355806");
		case "vacationrentalsatemeraldisle": return("8665356043");
		case "northcarolinavacationrental": return("8665357840");
		case "northcarolinaoceanfrontvacationrentals": return("8665357845");
		case "vacationrentalsnorthcarolina": return("8665445273");
		case "northcarolinabeachvacationrental": return("8665468488");
		case "vvacationrentalhousesonnorthcarolinacoast": return("8665469618");
		case "petfriendlyvacationrentalnorthcarolina": return("8665487664");
		case "facebook": return("8665492455");
		case "northcarolinavacationrentals": return("8665495286");
		case "petfriendlytravel": return("8665504703");
		case "vrAgent.com: Property Questions from": return("8665505574");
		case "northcarolinavacationrentalbeach": return("8665508552");
		case "northcarolinavacationhomes": return("8665519642");
		case "findrentalpropertiesinnorthcarolina": return("8665539510");
		case "marthastewartweddings": return("8665581487");
		case "northcarolinabeachvacationrentals": return("8665602189");
		case "northcarolinabeachrental": return("8665608824");
		case "northcarolinabeachhouserentals": return("8665608874");
		case "islandreview": return("8665630478");
		case "beachvacationrentalhomesinnorthcarolina": return("8665645453");
		case "houseforrentinnorthcarolina": return("8665692210");
		case "beachvacationrentalhomeinnorthcarolina": return("8665693537");
		case "atlanticbeachncproperty": return("8665715840");
		case "atlanticbeachhomerentals": return("8665715844");
		case "atlanticbeachncrealty": return("8665718669");
		case "atlanticbeachvacationrentals": return("8665722574");
		case "atlanticbeachncrentals": return("8665724437");
		case "atlanticbeachhouserentals": return("8665724851");
		case "atlanticbeachnorthcarolinarentals": return("8665726726");
		case "condorentalsnorthcarolina": return("8665728753");
		case "atlanticbeachcottage": return("8665728754");
		case "atlanticbeach": return("8665728758");
		case "carolinahomenorthrentalvacation": return("8665728759");
		case "rentalsintheouterbanks": return("8665728768");
		case "janzeronine": return("8665738710");
		case "visitorsnetwork": return("8665743358");
		case "grandevillaseblast": return("8665744367");
		case "petfriendlybeachrentalsattheouterbanks": return("8665745213");
		case "emeraldislerealty": return("8665750823");
		case "emeraldislenorthcarolina": return("8665750833");
		case "emeraldislenc": return("8665750849");
		case "emeraldisle": return("8665750851");
		case "beaufortwine": return("8665782528");
		case "coasthost": return("8665861814");
		case "beaufortcountync": return("8665877096");
		case "atlanticbeachrealty": return("8665877101");
		case "rentemeraldislecottages": return("8665877881");
		case "coastaleventplanner": return("8665888538");
		case "emeraldislebeachhomesforrent": return("8666132899");
		case "emeraldisleluxurybeachhouses": return("8666137481");
		case "usdmepostcard": return("8666156877");
		case "guestquestnc": return("8666156909");
		case "seeyathereohio": return("8666157299");
		case "vrmapr": return("8666209663");
		case "oceanfronthousesinswansboroforrent": return("8666233036");
		case "swansboro": return("8666233056");
		case "zimmermanspring": return("8666239813");
		case "newbernnc": return("8666260146");
		case "atlanticbeachrentals": return("8666260147");
		case "moreheadcityrealty": return("8666260148");
		case "beachhouserentalonatlantic": return("8666260150");
		case "moreheadcitynorthcarolina": return("8666260151");
		case "carolinaliving": return("8666265220");
		case "atlanticbeachnorthcarolina": return("8666269210");
		case "moreheadcity": return("8666269214");
		case "harkersislandnc": return("8666269216");
		case "emeraldislenccottage": return("8666270222");
		case "militaryhomes": return("8666271306");
		case "emeraldislecondosforrent": return("8666272145");
		case "emeraldislecondominiums": return("8666277004");
		case "emeraldisleluxurycottage": return("8666278230");
		case "augustenewsletter": return("8666279183");
		case "octoberenewsletter": return("8666280479");
		case "septemberepostcard": return("8666280542");
		case "travelleisure": return("8666281285");
		case "augustoff": return("8666281287");
		case "virtualcities": return("8666283394");
		case "cottagesinemeraldisle": return("8666296937");
		case "crystalcoastaccomodations": return("8666304552");
		case "crystalcoastbeachrental": return("8666304573");
		case "crystalcoastnc": return("8666304575");
		case "crystalcoastvacationhomerental": return("8666412478");
		case "crystalcoastnorthcarolina": return("8666412480");
		case "crystalcoastrealtors": return("8666412485");
		case "beachrentalsouterbanksnc ": return("8666415485");
		case "crystalcoast": return("8666521550");
		case "emeraldislebeachhomerentals": return("8666521602");
		case "swansboronorthcarolina": return("8666521640");
		case "swansboronc": return("8666577270");
		case "houserentalsouterbanks": return("8666577287");
		case "atlanticbeachemeraldislenorthcarolina": return("8666577289");
		case "homesforrentinnewbernnc": return("8666577290");
		case "newbernnorthcarolina": return("8666577292");
		case "newbern": return("8666583426");
		case "moreheadcityncrealty": return("8666583430");
		case "outerbankshomerentals": return("8666583433");
		case "outerbanksoceanfrontcondorentals": return("8666583440");
		case "moreheadcitync": return("8666583441");
		case "harkersislandrealty": return("8666583445");
		case "emeraldislenorthcarolinacottage": return("8666675361");
		case "bestdealonouterbanksvacationrentals": return("8666682302");
		case "harkersislandnorthcarolina": return("8666682341");
		case "harkersisland": return("8666682350");
		case "cookin": return("8666715889");
		case "outerbanksvacationhomerentals": return("8666725359");
		case "petfriendlyouterbanksvacationrentals": return("8666725607");
		case "outerbankssummerrentals": return("8666725686");
		case "vacationrentals-outerbanks": return("8666725691");
		case "emeraldislebeachnorthcarolina": return("8666725748");
		case "emeraldislegulffrontcondominiums": return("8666731299");
		case "emeraldislebeachhouse": return("8666731314");
		case "outerbanksbeachfrontrentals": return("8666731315");
		case "searchvacationrentalsbypriceouterbanks": return("8666785859");
		case "rentalsouterbanksnc": return("8666786326");
		case "luxuryouterbanksvacationrentals": return("8666786343");
		case "outerbanksvacationsrentals": return("8666786344");
		case "outerbanks3bedroomrentals": return("8666803854");
		case "outerbanksrentalsontheocean": return("8666804457");
		case "vacationrentalsouterbanks": return("8666804458");
		case "outerbanksncvacationrentals": return("8666804460");
		case "beachrentalsnearouterbanks": return("8666804463");
		case "outerbanksnorthcarolinarentals": return("8666804465");
		case "outerbanksbeachhouserentals": return("8666813238");
		case "outerbankshouserentals": return("8666813256");
		case "vacationrentalsintheouterbanks": return("8666813306");
		case "outerbanksvacationrentalsnc": return("8666813307");
		case "outerbanksrentals": return("8666813308");
		case "emeraldislereality": return("8666823527");
		case "yearroundrentalsouterbanks": return("8666823536");
		case "cottagerentalsintheouterbanks": return("8666823538");
		case "petfriendlyouterbanksrentals": return("8666823541");
		case "outerbankslongtermrentals": return("8666823544");
		case "theouterbanksrentals": return("8666826460");
		case "outerbankscottagerentals": return("8666826479");
		case "beachhouserentalsofouterbanksnorthcarolina": return("8666826574");
		case "outerbanksbeachhomerentals": return("8666885913");
		case "outerbanksnchouserentals": return("8666885939");
		case "oceanreefcondoemeraldislenc": return("8666886149");
		case "condorentalsouterbanks": return("8666886154");
		case "outerbankscondorentals": return("8666950898");
		case "emeraldislevacationrental": return("8666950916");
		case "vacationrentalsinouterbanks": return("8666950917");
		case "bedandbreakfastemeraldislenc": return("8666950918");
		case "outerbanksnorthcarolinavacationrentals": return("8666950919");
		case "emeraldislebeachrental": return("8666950921");
		case "outerbanksoceanfrontrentals": return("8666950922");
		case "vacationrentalsouterbanksnc": return("8666950924");
		case "outerbanksbeachrentals": return("8666958015");
		case "outerbanksncrentals": return("8666958017");
		case "beachhouserentalsofemeraldislenorthcarolina": return("8666958023");
		case "bestvacationrentaldealsemeraldisle": return("8666958025");
		case "emeraldislehouserentals": return("8667146976");
		case "emeraldislevacationrentals": return("8667147054");
		case "emeraldislerental": return("8667178923");
		case "housesforrentonemeraldisle": return("8667179308");
		case "emeraldislerentals": return("8667179309");
		case "emeraldislenorthcarolinarealty": return("8667179323");
		case "outerbanksandvacationrentals": return("8667179337");
		case "beaufortncbedandbreakfast": return("8667179374");
		case "lodgingbeaufortnc": return("8667179481");
		case "beaufortnclodgings": return("8667179518");
		case "rentalsinemeraldislenc": return("8667179519");
		case "beaufortnc": return("8667179521");
		case "atlanticbeachncrealy": return("8667179526");
		case "vacationrentalsemeraldislenorthcarolina": return("8667179527");
		case "emeraldislecondominium": return("8667184149");
		case "outerbanksvacationrentals": return("8667257165");
		case "emeraldislecoast": return("8667408546");
		case "vacationrentalcondosemeraldislenorthcarolina": return("8667408548");
		case "budgettravel": return("8667507918");
		case "oprahmagazine": return("8667535840");
		case "southernouterbanksvacationrentalhomes": return("8667790693");
		case "coaster": return("8668032266");
		case "emeraldislebeachhousesforrent": return("8668081743");
		case "carolinacountrytravelguide": return("8669213512");
		case "zimmermanfall": return("8669324303");
		case "ncoif": return("8669345101");
		case "emeraldisleluxurycondos": return("8669351021");
		case "rentemeraldislebeachhouses": return("8669358284");
		case "emeraldisleluxurybeachhouse": return("8669358431");
		case "emeraldislecondominiumrentals": return("8669660217");
		case "emeraldislenccondo": return("8669662351");
		case "emeraldislepurchasecoupons": return("8669662573");
		case "emeraldisleoceanfrontvacationrentals": return("8669662757");
		case "findemeraldislepromotions": return("8669663715");
		case "emeraldisleoceanfrontcondorentals": return("8669664027");
		case "emeraldislenorthcarolinavacation": return("8669664049");
		case "emeraldislebeachhouserentals": return("8669664052");
		case "emeraldislenorthcarolinabeachrental": return("8669664058");
		case "emeraldislencvacationhomes": return("8669664063");
		case "emeraldislecondorentals": return("8669664071");
		case "condorentalsinemeraldislenc": return("8669664072");
		case "beachrentalsinemeraldisle": return("8669664084");
		case "emeraldislecondo": return("8669664085");
		case "emeraldislebeachvacationrentals": return("8669664087");
		case "emeraldislebeachvacation": return("8669664147");
		case "emeraldislebeachrentals": return("8669664155");
		case "emeraldislebeachhouserental": return("8669664159");
		case "emeraldislandvacationrentals": return("8669664240");
		case "condorentalsinemeraldisle": return("8669664294");
		case "condorentalemeraldislenc": return("8669664298");
		case "icw": return("8669664393");
		case "emeraldislevacationrentalsearch": return("8669664591");
		case "emeraldislevacationrentalproperty": return("8669664594");
		case "vacationrentalsonemeraldisle": return("8669664651");
		case "vacationrentalsinemeraldisle": return("8669664715");
		case "emeraldislevacationhomerentals": return("8669664719");
		case "vacationrentalsbyowneremeraldisle": return("8669664724");
		case "emeraldislevacationhomerental": return("8669664730");
		case "vacationrentalsatemeraldislenc": return("8669664740");
		case "emeraldislevacationcondos": return("8669664741");
		case "emeraldislevacationcondorentals": return("8669664749");
		case "vacationrentalinemeraldisle": return("8669664750");
		case "emeraldislevacationcondo": return("8669664751");
		case "emeraldislevacations": return("8669664761");
		case "emeraldislevacationrentalhomes": return("8669664771");
		case "emeraldislevacationproperty": return("8669664802");
		case "emeraldislerentalproperty": return("8669664803");
		case "emeraldislevacationproperties": return("8669664804");
		case "emeraldislerentalhouses": return("8669664809");
		case "emeraldislevacationhouses": return("8669664812");
		case "emeraldislerealtyvacationrentals": return("8669664844");
		case "emeraldislevacationhouserental": return("8669664845");
		case "emeraldislerealtyvacation": return("8669664850");
		case "emeraldislevacationhouse": return("8669664851");
		case "emeraldisleproperties": return("8669664854");
		case "emeraldisleoceanfrontrental": return("8669664861");
		case "emeraldislevacation": return("8669664898");
		case "emeraldislenorthcarolinavacationrentals": return("8669664901");
		case "emeraldislenorthcarolinacondo": return("8669664962");
		case "emeraldislesearch": return("8669664965");
		case "emeraldislencvacationrental": return("8669664970");
		case "emeraldislerentalreservations": return("8669664971");
		case "emeraldislenccondorentals": return("8669664974");
		case "emeraldislecondorental": return("8669664992");
		case "lastminuteemeraldisle": return("8669664993");
		case "emeraldislebeachrentalspecials": return("8669664995");
		case "emeraldislevacationdeals": return("8669665067");
		case "emeraldislerentalspecials": return("8669665069");
		case "emeraldislebeachrentaldeals": return("8669665074");
		case "discountncbeachvacation": return("8669665104");
		case "crystalcoastspecials": return("8669665119");
		case "northcarolinabeachcondorentals": return("8669665129");
		case "northcarolinabeachcondorental": return("8669665242");
		case "indianbeachnchotels": return("8669665260");
		case "grandevillasnc": return("8669665275");
		case "grandevillascondo": return("8669665280");
		case "vacationrentalsinatlanticbeachnc": return("8669665281");
		case "condorentalscarolinabeachnc": return("8669665292");
		case "indianbeachnc": return("8669665298");
		case "atlanticbeachnorthcarolinavacationrentals": return("8669665302");
		case "atlanticbeachncvacationrentals": return("8669665375");
		case "indianbeachcondo": return("8669665381");
		case "atlanticbeachnccondorentals": return("8669665382");
		case "grandevillasindianbeachnc": return("8669665384");
		case "condorentalcarolinabeachnc": return("8669665572");
		case "atlanticbeachnccondorental": return("8669665613");
		case "vacationrentalsinemeraldislenc": return("8669665693");
		case "ncbeachvacationspecials": return("8669665812");
		case "lastminuteouterbanksrentals": return("8669665830");
		case "lastminuteouterbanksrental": return("8669665853");
		case "lastminutencbeachvacation": return("8669665874");
		case "lastminuteemeraldislebeachrental": return("8669665880");
		case "ncbeachspecials": return("8669665881");
		case "ncbeachrentaldiscounts": return("8669665884");
		case "lastminuteouterbanksvacations": return("8669665890");
		case "lastminuteouterbanksvacation": return("8669665892");
		case "rentemeraldislecondo": return("8669666989");
		case "cloudnineeast": return("8669668781");
		case "emeraldislepromtionalcodes": return("8669751878");
		case "beachhomeinemeraldisle": return("8669751894");
		case "emeraldislespecials ": return("8669752078");
		case "emeraldisleprintablecoupons": return("8669760060");
		case "emeraldislespecialoffers": return("8669760238");
		case "emeraldislecoupons": return("8669760250");
		case "emeraldislecouponsavings": return("8669760369");
		case "findemeraldislespecials": return("8669760384");
		case "printemeraldislespecials": return("8669761014");
		case "printemeraldislespecialoffers": return("8669761052");
		case "emeraldislediscountsavings": return("8669761094");
		case "rentemeraldislebeachhome": return("8669761946");
		case "emeraldislerealtyspecials": return("8669761958");
		case "octepost": return("8669762034");
		case "findemeraldislestorespecials": return("8669762068");
		case "emeraldislediscounts": return("8669762113");
		case "croatanhighschool": return("8669762193");
		case "printemeraldislestorespecials": return("8669762347");
		case "pb302": return("8669762481");
		case "rentemeraldislebeachhomes": return("8669762798");
		case "luxurycondominiuminemeraldisle": return("8669763635");
		case "emeraldislediscountsoff": return("8669764302");
		case "findemeraldislespecialoffers": return("8669764390");
		case "printemeraldislepromotions": return("8669764620");
		case "nauticalclub": return("8669765548");
		case "findemeraldislediscounts": return("8669765852");
		case "emeraldislevacationcoupons": return("8669765855");
		case "emeraldislediscountdeals": return("8669765902");
		case "emeraldisleoutletcoupons": return("8669766419");
		case "golfnc": return("8669766516");
		case "petswelcome": return("8669766646");
		case "luxurycottageinemeraldisle": return("8669766985");
		case "emeraldislepromotions": return("8669767244");
		case "emeraldislestorespecials": return("8669767317");
		case "emeraldislestorecoupons": return("8669767380");
		case "emeraldislecottages": return("8669767612");
		case "printemeraldislecoupons": return("8669767805");
		case "printemeraldislediscounts": return("8669768004");
		case "emeraldislerealtysavings": return("8669768010");
		case "emeraldislestorediscounts": return("8669768236");
		case "emeraldislecouponcodes": return("8669768238");
		case "emeraldislerealtydeals": return("8669768260");
		case "emeraldislecouponbooksavings": return("8669768425");
		case "emeraldislerealtydiscounts": return("8669768498");
		case "emeraldislecouponbook": return("8669769461");
		case "emeraldislecottagerentals": return("8669769608");
		case "rentemeraldislecondominium": return("8669769618");
		case "emeraldisleluxurycondominium": return("8669769668");
		case "emeraldislebeachhouses": return("8669769682");
		case "luxurycondosinemeraldisle": return("8772135356");
		case "southernlivinglkm": return("8772138396");
		case "northcarolinabeachwedding": return("8772193884");
		case "weddingrentalsinemeraldisle": return("8772197903");
		case "banner": return("8772309832");
		case "emeraldislebeachhomes": return("8772318670");
		case "winemarket": return("8772418865");
		case "atlanticbeachnc": return("8772525695");
		case "outerbanksweddingvenues": return("8772541267");
		case "outerbankswedding": return("8772559616");
		case "emeraldislewedding ": return("8772593658");
		case "rentemeraldislecottage": return("8772608539");
		case "emeraldisleweddingrentals": return("8772722759");
		case "photoslideshowvideo": return("8772768829");
		case "condoinemeraldisle": return("8772770571");
		case "emeraldislecottage": return("8772795819");
		case "beachrentalsouterbanksnorthcarolina": return("8772843849");
		case "southernouterbanksvacationrentals": return("8772902670");
		case "emeraldisleluxurycondominiums": return("8772902696");
		case "southernouterbanksvacationhomes": return("8772947270");
		case "rentemeraldislebeachhouse": return("8773129758");
		case "southernouterbanksluxuryrentals": return("8773563361");
		case "traveldeal": return("8773563373");
		case "beachhomesinemeraldisle": return("8773781262");
		case "pd305": return("8773920782");
		case "nctravelguide": return("8773920788");
		case "southernouterbanks": return("8774053126");
		case "emeraldislencbeachhome": return("8774620048");
		case "discountsonouterbanksvacationrentals": return("8774808679");
		case "traveladventure": return("8774922795");
		case "beachweddingsinnc": return("8775001602");
		case "visitnc": return("8775034042");
		case "emeraldisleluxurybeachhome": return("8775129791");
		case "emeraldislecottagesforrent": return("8775218758");
		case "cottageinemeraldisle": return("8775339938");
		case "southernouterbanksrentalhouse": return("8775416752");
		case "luxurycottagesinemeraldisle": return("8775570319");
		case "tripinfo": return("8775615930");
		case "ecupirates": return("8775745288");
		case "globe": return("8775924072");
		case "weddingsintheouterbanksnc": return("8776007903");
		case "visitncsweepstakes": return("8776007904");
		case "weddingrentalsinnorthcarolina": return("8776310209");
		case "beachweddingsinnorthcarolina": return("8776476430");
		case "weddingplanninginemeraldisle": return("8777043462");
		case "emeraldisleweddings": return("8777052280");
		case "weddingsintheouterbanks": return("8777308977");
		case "weddingsinemeraldislenorthcarolina": return("8777315077");
		case "weddingsinemeraldisle": return("8777326157");
		case "beachrentalsouterbanks": return("8777438304");
		case "emeraldisleluxurycottages": return("8777618999");
		case "metromagazine": return("8777888829");
		case "outerbanksweddingrentals": return("8777928269");
		case "emeraldisleluxurycondo": return("8778074728");
		case "chmby": return("8778392311");
		case "emeraldisleweddingvenues": return("8778553883");
		case "guestquest": return("8778599325");
		case "chocolatefestival": return("8778744605");
		case "carolinabride": return("8778775716");
		case "emeraldislecondos": return("8778776910");
		case "southernouterbanksaccommodations": return("8778972177");
		case "emeraldisleweddingpackages": return("8778982127");
		case "decemberenewsletter": return("8882063755");
		case "atlanticbeachaccommodations": return("8882369699");
		case "crystalcoastbride": return("8882664133");
		case "emeraldisleluxurybeachhomes": return("8883601437");
		case "shellcove": return("8883647188");
		case "igfamilyreunions": return("8884172592");
		case "virtualcitites": return("8884455902");
		case "igpetfriendly": return("8884556473");
		case "ncseafoodfestival": return("8886581552");
		case "julyepostcard": return("8887143627");
		case "june2010email": return("8888193397");
		case "ourstate": return("8888524288");
		case "mhcmarlins": return("8888548904");
		case "seeyathere": return("8888812281");
		case "zimmermansummer": return("8888826269");
	}
	return("8665866980");
}


function CreateNavisTagCookie(t) {
	CreateNavisTagCookie2(t, "");
}

function CreateNavisTagCookie2(t, dom) {
	var date = new Date();
	date.setTime(date.getTime()+(30*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	var domstr = (dom=="")? "" : "; domain=" + dom;
	document.cookie = "NavisNCKeyword="+t+expires+domstr+"; path=/";
}

function ReadNavisTagCookie() {
	var nameEQ = "NavisNCKeyword=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function GetNavisTagQueryString(){
	var nameEQ = "NCK=";
	//alert(window.location.search.substring(1, window.location.search.length));
	var ca = window.location.search.substring(1, window.location.search.length).split('&');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function GetNavisTagReferrer(){
	var r = document.referrer;
	var rs = r.split('/');
	var rd = rs.length > 2 ? rs[2] : null;
	return rd;
}

function GetNavisTagHash(){
	var nameEQ = "NCK=";
	var h = document.location.hash;
	return (h.substring(1, nameEQ.length + 1) == nameEQ) ? h.substring(nameEQ.length + 1, h.length) : null; 
}

	

function ProcessNavisNCKeyword(){
	ProcessNavisNCKeyword3("", false);
}

function ProcessNavisNCKeyword2(dom){
	ProcessNavisNCKeyword3(dom, false);
}

function ProcessNavisNCKeyword3(dom, referrer){
	ProcessNavisNCKeyword4(dom, true, false, referrer);
}

//dom: domain for the cookie, useful for cookies that persist on multiple subdomains
//querystring:  Should I look in the querystring for the token?
//hash:  Should I look in the hash (the part of the URL after #) for the token?
//referrer:  Should I use the domain of the referrer as the token?
function ProcessNavisNCKeyword4(dom, querystring, hash, referrer){
	var t = null;
	if (t == null && querystring){
		t = GetNavisTagQueryString();
	}
	if (t == null && hash){
		t = GetNavisTagHash();
	}
	if (t == null && referrer){
		t = GetNavisTagReferrer();
	}
	
	if (t != null){
		CreateNavisTagCookie2(t, dom);
	}
}



function FormatPhone(ph, fmt){
	var fs = fmt.split("#");
	var s = "";
	for (var i = 0; i < 10; i++){
		s += fs[i] + ph.substr(i, 1);
	}
	s += fs[10];
	return s;
}

function ShowNavisNCPhoneNumber(){
	ShowNavisNCPhoneNumberFormat("(###) ###-####");
}

function ShowNavisNCPhoneNumberFormat(fmt){
	var ph = NavisConvertTagToPhoneNumberBasic(ReadNavisTagCookie());
	document.write(FormatPhone(ph, fmt));
}

function NavisConvertTagToPhoneNumber(t){
	return FormatPhone(NavisConvertTagToPhoneNumberBasic(t), "(###) ###-####");
}

function NavisSetHiddenKeywordField(id){
	var fld = document.getElementById(id);
	if (fld != null){
		fld.value = ReadNavisTagCookie();
	}
}
function NavisSetHiddenPhoneNumberField(id){
	var fld = document.getElementById(id);
	if (fld != null){
		fld.value = NavisConvertTagToPhoneNumberBasic(ReadNavisTagCookie());
	}
}



function SetNavisP2TalkLink(linkId){
	SetNavisLink(linkId, "P2Talk", "");
}
function SetNavisP2TalkCustomLink(linkId){
	SetNavisLink(linkId, "P2TCust", "");
}
function SetNavisP2ChatLink(linkId){
	SetNavisLink(linkId, "P2ChatIni", "");
}
function SetNavisP2ChatCustomLink(linkId){
	SetNavisLink(linkId, "P2ChatIni", "&cust=1");
}
function SetNavisLink(linkId, page, extra){
	var lnk = document.getElementById(linkId);
	if (lnk != null && (lnk.tagName.toLowerCase() == "a" || lnk.tagName.toLowerCase() == "area")){
		var ph = NavisConvertTagToPhoneNumberBasic(ReadNavisTagCookie());
		var acct = "14330";

		lnk.href = "http://www.navistechnologies.info/p2talk/" + page + ".aspx?account=" + acct + "&dnis=" + ph + extra;
	}
}

function AppendNavisKeywordToLink(linkId){
	var lnk = document.getElementById(linkId);
	if (lnk != null && (lnk.tagName.toLowerCase() == "a" || lnk.tagName.toLowerCase() == "area")){
		var kwd = ReadNavisTagCookie();
		if (kwd != null){
    		lnk.href = lnk.href + (lnk.href.indexOf("?") == -1 ? "?" : "&") + "NCK" + "=" + kwd;
    	}
	}
}

