var zipCityList = [{ z: '1000-2499', c: 'København By' }, { z: '1000-2999', c: 'Storkøbenhavn' }, { z: '1050-1499', c: 'København K' }, { z: '1500-1799', c: 'København Vesterbro' }, { z: '1800-1999', c: 'Frederiksberg C' }, { z: '2000', c: 'Frederiksberg' }, { z: '2100', c: 'København Østerbro' }, { z: '2200', c: 'København Nørrebro' }, { z: '2300', c: 'København S' }, { z: '2400', c: 'København NV' }, { z: '2450', c: 'København SV' }, { z: '2500', c: 'Valby' }, { z: '2600', c: 'Glostrup' }, { z: '2605', c: 'Brøndby' }, { z: '2610', c: 'Rødovre' }, { z: '2620', c: 'Albertslund' }, { z: '2625', c: 'Vallensbæk' }, { z: '2630', c: 'Taastrup' }, { z: '2633', c: 'Taastrup' }, { z: '2635', c: 'Ishøj' }, { z: '2640', c: 'Hedehusene' }, { z: '2650', c: 'Hvidovre' }, { z: '2660', c: 'Brøndby Strand' }, { z: '2665', c: 'Vallensbæk Strand' }, { z: '2670', c: 'Greve' }, { z: '2680', c: 'Solrød Strand' }, { z: '2690', c: 'Karlslunde' }, { z: '2700', c: 'Brønshøj' }, { z: '2720', c: 'Vanløse' }, { z: '2730', c: 'Herlev' }, { z: '2740', c: 'Skovlunde' }, { z: '2750', c: 'Ballerup' }, { z: '2760', c: 'Måløv' }, { z: '2765', c: 'Smørum' }, { z: '2770', c: 'Kastrup' }, { z: '2791', c: 'Dragør' }, { z: '2800', c: 'Kongens Lyngby' }, { z: '2820', c: 'Gentofte' }, { z: '2830', c: 'Virum' }, { z: '2840', c: 'Holte' }, { z: '2850', c: 'Nærum' }, { z: '2860', c: 'Søborg' }, { z: '2870', c: 'Dyssegård' }, { z: '2880', c: 'Bagsværd' }, { z: '2900', c: 'Hellerup' }, { z: '2920', c: 'Charlottenlund' }, { z: '2930', c: 'Klampenborg' }, { z: '2942', c: 'Skodsborg' }, { z: '2950', c: 'Vedbæk' }, { z: '2960', c: 'Rungsted Kyst' }, { z: '2970', c: 'Hørsholm' }, { z: '2980', c: 'Kokkedal' }, { z: '2990', c: 'Nivå' }, { z: '3000', c: 'Helsingør' }, { z: '3050', c: 'Humlebæk' }, { z: '3060', c: 'Espergærde' }, { z: '3070', c: 'Snekkersten' }, { z: '3080', c: 'Tikøb' }, { z: '3100', c: 'Hornbæk' }, { z: '3120', c: 'Dronningmølle' }, { z: '3140', c: 'Ålsgårde' }, { z: '3150', c: 'Hellebæk' }, { z: '3200', c: 'Helsinge' }, { z: '3210', c: 'Vejby' }, { z: '3220', c: 'Tisvildeleje' }, { z: '3230', c: 'Græsted' }, { z: '3250', c: 'Gilleleje' }, { z: '3300', c: 'Frederiksværk' }, { z: '3310', c: 'Ølsted' }, { z: '3320', c: 'Skævinge' }, { z: '3330', c: 'Gørløse' }, { z: '3360', c: 'Liseleje' }, { z: '3370', c: 'Melby' }, { z: '3390', c: 'Hundested' }, { z: '3400', c: 'Hillerød' }, { z: '3450', c: 'Allerød' }, { z: '3460', c: 'Birkerød' }, { z: '3480', c: 'Fredensborg' }, { z: '3490', c: 'Kvistgård' }, { z: '3500', c: 'Værløse' }, { z: '3520', c: 'Farum' }, { z: '3540', c: 'Lynge' }, { z: '3550', c: 'Slangerup' }, { z: '3600', c: 'Frederikssund' }, { z: '3630', c: 'Jægerspris' }, { z: '3650', c: 'Ølstykke' }, { z: '3660', c: 'Stenløse' }, { z: '3670', c: 'Veksø Sjælland' }, { z: '3700', c: 'Rønne' }, { z: '3720', c: 'Aakirkeby' }, { z: '3730', c: 'Nexø' }, { z: '3740', c: 'Svaneke' }, { z: '3751', c: 'Østermarie' }, { z: '3760', c: 'Gudhjem' }, { z: '3770', c: 'Allinge' }, { z: '3782', c: 'Klemensker' }, { z: '3790', c: 'Hasle' }, { z: '4000', c: 'Roskilde' }, { z: '4030', c: 'Tune' }, { z: '4040', c: 'Jyllinge' }, { z: '4050', c: 'Skibby' }, { z: '4060', c: 'Kirke Såby' }, { z: '4070', c: 'Kirke Hyllinge' }, { z: '4100', c: 'Ringsted' }, { z: '4105', c: 'Ringsted' }, { z: '4129', c: 'Ringsted' }, { z: '4130', c: 'Viby Sjælland' }, { z: '4140', c: 'Borup' }, { z: '4160', c: 'Herlufmagle' }, { z: '4171', c: 'Glumsø' }, { z: '4173', c: 'Fjenneslev' }, { z: '4174', c: 'Jystrup Midtsj' }, { z: '4180', c: 'Sorø' }, { z: '4190', c: 'Munke Bjergby' }, { z: '4200', c: 'Slagelse' }, { z: '4220', c: 'Korsør' }, { z: '4230', c: 'Skælskør' }, { z: '4241', c: 'Vemmelev' }, { z: '4242', c: 'Boeslunde' }, { z: '4243', c: 'Rude' }, { z: '4250', c: 'Fuglebjerg' }, { z: '4261', c: 'Dalmose' }, { z: '4262', c: 'Sandved' }, { z: '4270', c: 'Høng' }, { z: '4281', c: 'Gørlev' }, { z: '4291', c: 'Ruds Vedby' }, { z: '4293', c: 'Dianalund' }, { z: '4295', c: 'Stenlille' }, { z: '4296', c: 'Nyrup' }, { z: '4300', c: 'Holbæk' }, { z: '4320', c: 'Lejre' }, { z: '4330', c: 'Hvalsø' }, { z: '4340', c: 'Tølløse' }, { z: '4350', c: 'Ugerløse' }, { z: '4360', c: 'Kirke Eskilstrup' }, { z: '4370', c: 'Store Merløse' }, { z: '4390', c: 'Vipperød' }, { z: '4400', c: 'Kalundborg' }, { z: '4420', c: 'Regstrup' }, { z: '4440', c: 'Mørkøv' }, { z: '4450', c: 'Jyderup' }, { z: '4460', c: 'Snertinge' }, { z: '4470', c: 'Svebølle' }, { z: '4480', c: 'Store Fuglede' }, { z: '4490', c: 'Jerslev Sjælland' }, { z: '4500', c: 'Nykøbing Sj' }, { z: '4520', c: 'Svinninge' }, { z: '4532', c: 'Gislinge' }, { z: '4534', c: 'Hørve' }, { z: '4540', c: 'Fårevejle' }, { z: '4550', c: 'Asnæs' }, { z: '4560', c: 'Vig' }, { z: '4571', c: 'Grevinge' }, { z: '4572', c: 'Nørre Asmindrup' }, { z: '4573', c: 'Højby' }, { z: '4581', c: 'Rørvig' }, { z: '4583', c: 'Sjællands Odde' }, { z: '4591', c: 'Føllenslev' }, { z: '4592', c: 'Sejerø' }, { z: '4593', c: 'Eskebjerg' }, { z: '4600', c: 'Køge' }, { z: '4621', c: 'Gadstrup' }, { z: '4622', c: 'Havdrup' }, { z: '4623', c: 'Lille Skensved' }, { z: '4632', c: 'Bjæverskov' }, { z: '4640', c: 'Fakse' }, { z: '4652', c: 'Hårlev' }, { z: '4653', c: 'Karise' }, { z: '4654', c: 'Faxe Ladeplads' }, { z: '4660', c: 'Store Heddinge' }, { z: '4671', c: 'Strøby' }, { z: '4672', c: 'Klippinge' }, { z: '4673', c: 'Rødvig Stevns' }, { z: '4681', c: 'Herfølge' }, { z: '4682', c: 'Tureby' }, { z: '4683', c: 'Rønnede' }, { z: '4684', c: 'Holmegaard ' }, { z: '4690', c: 'Haslev' }, { z: '4700', c: 'Næstved' }, { z: '4720', c: 'Præstø' }, { z: '4733', c: 'Tappernøje' }, { z: '4735', c: 'Mern' }, { z: '4736', c: 'Karrebæksminde' }, { z: '4750', c: 'Lundby' }, { z: '4760', c: 'Vordingborg' }, { z: '4771', c: 'Kalvehave' }, { z: '4772', c: 'Langebæk' }, { z: '4773', c: 'Stensved' }, { z: '4780', c: 'Stege' }, { z: '4791', c: 'Borre' }, { z: '4792', c: 'Askeby' }, { z: '4793', c: 'Bogø By' }, { z: '4800', c: 'Nykøbing F' }, { z: '4840', c: 'Nørre Alslev' }, { z: '4850', c: 'Stubbekøbing' }, { z: '4862', c: 'Guldborg' }, { z: '4863', c: 'Eskilstrup' }, { z: '4871', c: 'Horbelev' }, { z: '4872', c: 'Idestrup' }, { z: '4873', c: 'Væggerløse' }, { z: '4874', c: 'Gedser' }, { z: '4880', c: 'Nysted' }, { z: '4891', c: 'Toreby L' }, { z: '4892', c: 'Kettinge' }, { z: '4894', c: 'Øster Ulslev' }, { z: '4895', c: 'Errindlev' }, { z: '4900', c: 'Nakskov' }, { z: '4912', c: 'Harpelunde' }, { z: '4913', c: 'Horslunde' }, { z: '4920', c: 'Søllested' }, { z: '4930', c: 'Maribo' }, { z: '4941', c: 'Bandholm' }, { z: '4943', c: 'Torrig L' }, { z: '4944', c: 'Fejø' }, { z: '4951', c: 'Nørreballe' }, { z: '4952', c: 'Stokkemarke' }, { z: '4953', c: 'Vesterborg' }, { z: '4960', c: 'Holeby' }, { z: '4970', c: 'Rødby' }, { z: '4983', c: 'Dannemare' }, { z: '4990', c: 'Sakskøbing' }, { z: '5000', c: 'Odense C' }, { z: '5029', c: 'Odense C' }, { z: '5090', c: 'Odense C' }, { z: '5100', c: 'Odense C' }, { z: '5200', c: 'Odense V' }, { z: '5210', c: 'Odense NV' }, { z: '5220', c: 'Odense SØ' }, { z: '5230', c: 'Odense M' }, { z: '5240', c: 'Odense NØ' }, { z: '5250', c: 'Odense SV' }, { z: '5260', c: 'Odense S' }, { z: '5270', c: 'Odense N' }, { z: '5290', c: 'Marslev' }, { z: '5300', c: 'Kerteminde' }, { z: '5320', c: 'Agedrup' }, { z: '5330', c: 'Munkebo' }, { z: '5350', c: 'Rynkeby' }, { z: '5370', c: 'Mesinge' }, { z: '5380', c: 'Dalby' }, { z: '5390', c: 'Martofte' }, { z: '5400', c: 'Bogense' }, { z: '5450', c: 'Otterup' }, { z: '5462', c: 'Morud' }, { z: '5463', c: 'Harndrup' }, { z: '5464', c: 'Brenderup Fyn' }, { z: '5466', c: 'Asperup' }, { z: '5471', c: 'Søndersø' }, { z: '5474', c: 'Veflinge' }, { z: '5485', c: 'Skamby' }, { z: '5491', c: 'Blommenslyst' }, { z: '5492', c: 'Vissenbjerg' }, { z: '5500', c: 'Middelfart' }, { z: '5540', c: 'Ullerslev' }, { z: '5550', c: 'Langeskov' }, { z: '5560', c: 'Aarup' }, { z: '5580', c: 'Nørre Aaby' }, { z: '5591', c: 'Gelsted' }, { z: '5592', c: 'Ejby' }, { z: '5600', c: 'Faaborg' }, { z: '5610', c: 'Assens' }, { z: '5620', c: 'Glamsbjerg' }, { z: '5631', c: 'Ebberup' }, { z: '5642', c: 'Millinge' }, { z: '5672', c: 'Broby' }, { z: '5683', c: 'Haarby' }, { z: '5690', c: 'Tommerup' }, { z: '5700', c: 'Svendborg' }, { z: '5750', c: 'Ringe' }, { z: '5762', c: 'Vester Skerninge' }, { z: '5771', c: 'Stenstrup' }, { z: '5772', c: 'Kværndrup' }, { z: '5792', c: 'Årslev' }, { z: '5800', c: 'Nyborg' }, { z: '5853', c: 'Ørbæk' }, { z: '5854', c: 'Gislev' }, { z: '5856', c: 'Ryslinge' }, { z: '5863', c: 'Ferritslev Fyn' }, { z: '5871', c: 'Frørup' }, { z: '5874', c: 'Hesselager' }, { z: '5881', c: 'Skårup Fyn' }, { z: '5882', c: 'Vejstrup' }, { z: '5883', c: 'Oure' }, { z: '5884', c: 'Gudme' }, { z: '5892', c: 'Gudbjerg Sydfyn' }, { z: '5900', c: 'Rudkøbing' }, { z: '5932', c: 'Humble' }, { z: '5935', c: 'Bagenkop' }, { z: '5953', c: 'Tranekær' }, { z: '5960', c: 'Marstal' }, { z: '5970', c: 'Ærøskøbing' }, { z: '5985', c: 'Søby Ærø' }, { z: '6000', c: 'Kolding' }, { z: '6040', c: 'Egtved' }, { z: '6051', c: 'Almind' }, { z: '6052', c: 'Viuf' }, { z: '6064', c: 'Jordrup' }, { z: '6070', c: 'Christiansfeld' }, { z: '6091', c: 'Bjert' }, { z: '6092', c: 'Sønder Stenderup' }, { z: '6093', c: 'Sjølund' }, { z: '6094', c: 'Hejls' }, { z: '6100', c: 'Haderslev' }, { z: '6200', c: 'Aabenraa' }, { z: '6230', c: 'Rødekro' }, { z: '6240', c: 'Løgumkloster' }, { z: '6261', c: 'Bredebro' }, { z: '6270', c: 'Tønder' }, { z: '6280', c: 'Højer' }, { z: '6300', c: 'Gråsten' }, { z: '6310', c: 'Broager' }, { z: '6320', c: 'Egernsund' }, { z: '6330', c: 'Padborg' }, { z: '6340', c: 'Kruså' }, { z: '6360', c: 'Tinglev' }, { z: '6372', c: 'Bylderup-Bov' }, { z: '6392', c: 'Bolderslev' }, { z: '6400', c: 'Sønderborg' }, { z: '6430', c: 'Nordborg' }, { z: '6440', c: 'Augustenborg' }, { z: '6470', c: 'Sydals' }, { z: '6500', c: 'Vojens' }, { z: '6510', c: 'Gram' }, { z: '6520', c: 'Toftlund' }, { z: '6534', c: 'Agerskov' }, { z: '6535', c: 'Branderup J' }, { z: '6541', c: 'Bevtoft' }, { z: '6560', c: 'Sommersted' }, { z: '6580', c: 'Vamdrup' }, { z: '6600', c: 'Vejen' }, { z: '6621', c: 'Gesten' }, { z: '6622', c: 'Bække' }, { z: '6623', c: 'Vorbasse' }, { z: '6630', c: 'Rødding' }, { z: '6640', c: 'Lunderskov' }, { z: '6650', c: 'Brørup' }, { z: '6660', c: 'Lintrup' }, { z: '6670', c: 'Holsted' }, { z: '6682', c: 'Hovborg' }, { z: '6683', c: 'Føvling' }, { z: '6690', c: 'Gørding' }, { z: '6700', c: 'Esbjerg' }, { z: '6701', c: 'Esbjerg' }, { z: '6705', c: 'Esbjerg Ø' }, { z: '6710', c: 'Esbjerg V' }, { z: '6715', c: 'Esbjerg N' }, { z: '6720', c: 'Fanø' }, { z: '6731', c: 'Tjæreborg' }, { z: '6740', c: 'Bramming' }, { z: '6752', c: 'Glejbjerg' }, { z: '6753', c: 'Agerbæk' }, { z: '6760', c: 'Ribe' }, { z: '6771', c: 'Gredstedbro' }, { z: '6780', c: 'Skærbæk' }, { z: '6792', c: 'Rømø' }, { z: '6800', c: 'Varde' }, { z: '6818', c: 'Årre' }, { z: '6823', c: 'Ansager' }, { z: '6830', c: 'Nørre Nebel' }, { z: '6840', c: 'Oksbøl' }, { z: '6851', c: 'Janderup Vestj' }, { z: '6852', c: 'Billum' }, { z: '6853', c: 'Vejers Strand' }, { z: '6854', c: 'Henne' }, { z: '6855', c: 'Outrup' }, { z: '6857', c: 'Blåvand' }, { z: '6862', c: 'Tistrup' }, { z: '6870', c: 'Ølgod' }, { z: '6880', c: 'Tarm' }, { z: '6893', c: 'Hemmet' }, { z: '6900', c: 'Skjern' }, { z: '6920', c: 'Videbæk' }, { z: '6933', c: 'Kibæk' }, { z: '6940', c: 'Lem St' }, { z: '6950', c: 'Ringkøbing' }, { z: '6960', c: 'Hvide Sande' }, { z: '6971', c: 'Spjald' }, { z: '6973', c: 'Ørnhøj' }, { z: '6980', c: 'Tim' }, { z: '6990', c: 'Ulfborg' }, { z: '7000', c: 'Fredericia' }, { z: '7007', c: 'Fredericia' }, { z: '7029', c: 'Fredericia' }, { z: '7080', c: 'Børkop' }, { z: '7100', c: 'Vejle' }, { z: '7120', c: 'Vejle Øst' }, { z: '7130', c: 'Juelsminde' }, { z: '7140', c: 'Stouby' }, { z: '7150', c: 'Barrit' }, { z: '7160', c: 'Tørring' }, { z: '7171', c: 'Uldum' }, { z: '7173', c: 'Vonge' }, { z: '7182', c: 'Bredsten' }, { z: '7183', c: 'Randbøl' }, { z: '7184', c: 'Vandel' }, { z: '7190', c: 'Billund' }, { z: '7200', c: 'Grindsted' }, { z: '7250', c: 'Hejnsvig' }, { z: '7260', c: 'Sønder Omme' }, { z: '7270', c: 'Stakroge' }, { z: '7280', c: 'Sønder Felding' }, { z: '7300', c: 'Jelling' }, { z: '7321', c: 'Gadbjerg' }, { z: '7323', c: 'Give' }, { z: '7330', c: 'Brande' }, { z: '7361', c: 'Ejstrupholm' }, { z: '7362', c: 'Hampen' }, { z: '7400', c: 'Herning' }, { z: '7401', c: 'Herning' }, { z: '7429', c: 'Herning' }, { z: '7430', c: 'Ikast' }, { z: '7441', c: 'Bording' }, { z: '7442', c: 'Engesvang' }, { z: '7451', c: 'Sunds' }, { z: '7470', c: 'Karup J' }, { z: '7480', c: 'Vildbjerg' }, { z: '7490', c: 'Aulum' }, { z: '7500', c: 'Holstebro' }, { z: '7540', c: 'Haderup' }, { z: '7550', c: 'Sørvad' }, { z: '7560', c: 'Hjerm' }, { z: '7570', c: 'Vemb' }, { z: '7600', c: 'Struer' }, { z: '7620', c: 'Lemvig' }, { z: '7650', c: 'Bøvlingbjerg' }, { z: '7660', c: 'Bækmarksbro' }, { z: '7673', c: 'Harboøre' }, { z: '7680', c: 'Thyborøn' }, { z: '7700', c: 'Thisted' }, { z: '7730', c: 'Hanstholm' }, { z: '7741', c: 'Frøstrup' }, { z: '7742', c: 'Vesløs' }, { z: '7752', c: 'Snedsted' }, { z: '7755', c: 'Bedsted Thy' }, { z: '7760', c: 'Hurup Thy' }, { z: '7770', c: 'Vestervig' }, { z: '7790', c: 'Thyholm' }, { z: '7800', c: 'Skive' }, { z: '7830', c: 'Vinderup' }, { z: '7840', c: 'Højslev' }, { z: '7850', c: 'Stoholm Jyll' }, { z: '7860', c: 'Spøttrup' }, { z: '7870', c: 'Roslev' }, { z: '7884', c: 'Fur' }, { z: '7900', c: 'Nykøbing M' }, { z: '7950', c: 'Erslev' }, { z: '7960', c: 'Karby' }, { z: '7970', c: 'Redsted M' }, { z: '7980', c: 'Vils' }, { z: '7990', c: 'Øster Assels' }, { z: '8000-8210', c: 'Aarhus By' }, { z: '8000', c: 'Aarhus C' }, { z: '8100', c: 'Aarhus C' }, { z: '8200', c: 'Aarhus N' }, { z: '8210', c: 'Aarhus V' }, { z: '8220', c: 'Brabrand' }, { z: '8229', c: 'Risskov Ø' }, { z: '8230', c: 'Åbyhøj' }, { z: '8240', c: 'Risskov' }, { z: '8245', c: 'Risskov Ø' }, { z: '8250', c: 'Egå' }, { z: '8260', c: 'Viby J' }, { z: '8270', c: 'Højbjerg' }, { z: '8300', c: 'Odder' }, { z: '8305', c: 'Samsø' }, { z: '8310', c: 'Tranbjerg J' }, { z: '8320', c: 'Mårslet' }, { z: '8330', c: 'Beder' }, { z: '8340', c: 'Malling' }, { z: '8350', c: 'Hundslund' }, { z: '8355', c: 'Solbjerg' }, { z: '8361', c: 'Hasselager' }, { z: '8362', c: 'Hørning' }, { z: '8370', c: 'Hadsten' }, { z: '8380', c: 'Trige' }, { z: '8381', c: 'Tilst' }, { z: '8382', c: 'Hinnerup' }, { z: '8400', c: 'Ebeltoft' }, { z: '8410', c: 'Rønde' }, { z: '8420', c: 'Knebel' }, { z: '8444', c: 'Balle' }, { z: '8450', c: 'Hammel' }, { z: '8462', c: 'Harlev J' }, { z: '8464', c: 'Galten' }, { z: '8471', c: 'Sabro' }, { z: '8472', c: 'Sporup' }, { z: '8500', c: 'Grenaa' }, { z: '8520', c: 'Lystrup' }, { z: '8530', c: 'Hjortshøj' }, { z: '8541', c: 'Skødstrup' }, { z: '8543', c: 'Hornslet' }, { z: '8544', c: 'Mørke' }, { z: '8550', c: 'Ryomgård' }, { z: '8560', c: 'Kolind' }, { z: '8570', c: 'Trustrup' }, { z: '8581', c: 'Nimtofte' }, { z: '8585', c: 'Glesborg' }, { z: '8586', c: 'Ørum Djurs' }, { z: '8592', c: 'Anholt' }, { z: '8600', c: 'Silkeborg' }, { z: '8620', c: 'Kjellerup' }, { z: '8632', c: 'Lemming' }, { z: '8641', c: 'Sorring' }, { z: '8643', c: 'Ans By' }, { z: '8653', c: 'Them' }, { z: '8654', c: 'Bryrup' }, { z: '8660', c: 'Skanderborg' }, { z: '8670', c: 'Låsby' }, { z: '8680', c: 'Ry' }, { z: '8700', c: 'Horsens' }, { z: '8721', c: 'Daugård' }, { z: '8722', c: 'Hedensted' }, { z: '8723', c: 'Løsning' }, { z: '8732', c: 'Hovedgård' }, { z: '8740', c: 'Brædstrup' }, { z: '8751', c: 'Gedved' }, { z: '8752', c: 'Østbirk' }, { z: '8762', c: 'Flemming' }, { z: '8763', c: 'Rask Mølle' }, { z: '8765', c: 'Klovborg' }, { z: '8766', c: 'Nørre Snede' }, { z: '8781', c: 'Stenderup' }, { z: '8783', c: 'Hornsyld' }, { z: '8800', c: 'Viborg' }, { z: '8830', c: 'Tjele' }, { z: '8831', c: 'Løgstrup' }, { z: '8832', c: 'Skals' }, { z: '8840', c: 'Rødkærsbro' }, { z: '8850', c: 'Bjerringbro' }, { z: '8860', c: 'Ulstrup' }, { z: '8870', c: 'Langå' }, { z: '8881', c: 'Thorsø' }, { z: '8882', c: 'Fårvang' }, { z: '8883', c: 'Gjern' }, { z: '8900-8960', c: 'Randers By' }, { z: '8900', c: 'Randers C' }, { z: '8920', c: 'Randers NV' }, { z: '8930', c: 'Randers NØ' }, { z: '8940', c: 'Randers SV' }, { z: '8960', c: 'Randers SØ' }, { z: '8950', c: 'Ørsted' }, { z: '8961', c: 'Allingåbro' }, { z: '8963', c: 'Auning' }, { z: '8970', c: 'Havndal' }, { z: '8981', c: 'Spentrup' }, { z: '8983', c: 'Gjerlev J' }, { z: '8990', c: 'Fårup' }, { z: '9000', c: 'Aalborg' }, { z: '9020', c: 'Aalborg' }, { z: '9029', c: 'Aalborg' }, { z: '9100', c: 'Aalborg' }, { z: '9200', c: 'Aalborg SV' }, { z: '9210', c: 'Aalborg SØ' }, { z: '9220', c: 'Aalborg Øst' }, { z: '9230', c: 'Svenstrup J' }, { z: '9240', c: 'Nibe' }, { z: '9260', c: 'Gistrup' }, { z: '9270', c: 'Klarup' }, { z: '9280', c: 'Storvorde' }, { z: '9293', c: 'Kongerslev' }, { z: '9300', c: 'Sæby' }, { z: '9310', c: 'Vodskov' }, { z: '9320', c: 'Hjallerup' }, { z: '9330', c: 'Dronninglund' }, { z: '9340', c: 'Asaa' }, { z: '9352', c: 'Dybvad' }, { z: '9362', c: 'Gandrup' }, { z: '9370', c: 'Hals' }, { z: '9380', c: 'Vestbjerg' }, { z: '9381', c: 'Sulsted' }, { z: '9382', c: 'Tylstrup' }, { z: '9400', c: 'Nørresundby' }, { z: '9430', c: 'Vadum' }, { z: '9440', c: 'Aabybro' }, { z: '9460', c: 'Brovst' }, { z: '9480', c: 'Løkken' }, { z: '9490', c: 'Pandrup' }, { z: '9492', c: 'Blokhus' }, { z: '9493', c: 'Saltum' }, { z: '9500', c: 'Hobro' }, { z: '9510', c: 'Arden' }, { z: '9520', c: 'Skørping' }, { z: '9530', c: 'Støvring' }, { z: '9541', c: 'Suldrup' }, { z: '9550', c: 'Mariager' }, { z: '9560', c: 'Hadsund' }, { z: '9574', c: 'Bælum' }, { z: '9575', c: 'Terndrup' }, { z: '9600', c: 'Aars' }, { z: '9610', c: 'Nørager' }, { z: '9620', c: 'Aalestrup' }, { z: '9631', c: 'Gedsted' }, { z: '9632', c: 'Møldrup' }, { z: '9640', c: 'Farsø' }, { z: '9670', c: 'Løgstør' }, { z: '9681', c: 'Ranum' }, { z: '9690', c: 'Fjerritslev' }, { z: '9700', c: 'Brønderslev' }, { z: '9740', c: 'Jerslev J' }, { z: '9750', c: 'Østervrå' }, { z: '9760', c: 'Vrå' }, { z: '9800', c: 'Hjørring' }, { z: '9830', c: 'Tårs' }, { z: '9850', c: 'Hirtshals' }, { z: '9870', c: 'Sindal' }, { z: '9881', c: 'Bindslev' }, { z: '9900', c: 'Frederikshavn' }, { z: '9940', c: 'Læsø' }, { z: '9970', c: 'Strandby' }, { z: '9981', c: 'Jerup' }, { z: '9982', c: 'Ålbæk' }, { z: '9990', c: 'Skagen' }, { z: '9000-9220', c: 'Aalborg By' }, { z: '6700-6715', c: 'Esbjerg By' }, { z: '5900-5953', c: 'Langeland' }, { z: '5960-5985', c: 'Ærø' }, { z: '3700-3790', c: 'Bornholm' }, { z: '4800-4990', c: 'Lolland-Falster' }, { z: '3000-3699', c: 'Nordsjælland' }, { z: '5000-5999', c: 'Fyn' }, { z: '5000-5270', c: 'Odense By'}];

function checkdots(elem) {
	var val = elem.replace('.', '').replace('.', '').replace('.', '');
	if (val == '')
		return;
	val *= 2.0;
	val = val.toFixed(1) / 2.0;
	val = val.toFixed(0);
	var reg = /(-?\d+)(\d{3})/;
	while (reg.test(val)) {
		val = val.replace(reg, '$1.$2')
	}
	return val;
}


// jquery.watermark.min START
/*
Watermark v3.0.6 (June 21, 2010) plugin for jQuery
http://jquery-watermark.googlecode.com/
Copyright (c) 2009-2010 Todd Northrop
http://www.speednet.biz/
Dual licensed under the MIT or GPL Version 2 licenses.
*/
(function (b) { var l = "function", j = "password", d = "maxLength", f = "type", c = true, a = "", e = false, t = "watermark", u, m = t, i = "watermarkClass", q = "watermarkFocus", k = "watermarkSubmit", o = "watermarkMaxLength", h = "watermarkPassword", g = "watermarkText", s = ":data(" + m + ")", n = ":text,:password,:search,textarea", p = ["Page_ClientValidate"], r = e; b.extend(b.expr[":"], { search: function (b) { return "search" === (b.type || a) }, data: function (g, i, h) { var f, d = /^((?:[^=!^$*]|[!^$*](?!=))+)(?:([!^$*]?=)(.*))?$/.exec(h[3]); if (d) { f = b(g).data(d[1]); if (f !== u) { if (d[2]) { f = a + f; switch (d[2]) { case "=": return f == d[3]; case "!=": return f != d[3]; case "^=": return f.slice(0, d[3].length) == d[3]; case "$=": return f.slice(-d[3].length) == d[3]; case "*=": return f.indexOf(d[3]) !== -1 } } return c } } return e } }); b.watermark = { version: "3.0.6", options: { className: t, useNative: c }, hide: function (a) { b(a).filter(s).each(function () { b.watermark._hide(b(this)) }) }, _hide: function (b, n) { var m = b.val() || a, k = b.data(g) || a, l = b.data(o) || 0, j = b.data(i); if (k.length && m == k) { b.val(a); if (b.data(h)) if ((b.attr(f) || a) === "text") { var e = b.data(h) || [], c = b.parent() || []; if (e.length && c.length) { c[0].removeChild(b[0]); c[0].appendChild(e[0]); b = e } } if (l) { b.attr(d, l); b.removeData(o) } if (n) { b.attr("autocomplete", "off"); window.setTimeout(function () { b.select() }, 1) } } j && b.removeClass(j) }, show: function (a) { b(a).filter(s).each(function () { b.watermark._show(b(this)) }) }, _show: function (e) { var t = e.val() || a, k = e.data(g) || a, p = e.attr(f) || a, s = e.data(i); if ((t.length == 0 || t == k) && !e.data(q)) { r = c; if (e.data(h)) if (p === j) { var n = e.data(h) || [], m = e.parent() || []; if (n.length && m.length) { m[0].removeChild(e[0]); m[0].appendChild(n[0]); e = n; e.attr(d, k.length) } } if (p === "text" || p === "search") { var l = e.attr(d) || 0; if (l > 0 && k.length > l) { e.data(o, l); e.attr(d, k.length) } } s && e.addClass(s); e.val(k) } else b.watermark._hide(e) }, hideAll: function () { if (r) { b.watermark.hide(n); r = e } }, showAll: function () { b.watermark.show(n) } }; b.fn.watermark = function (r, o) { var p = "string"; if (!this.length) return this; var s = e, t = typeof r === p; if (typeof o === "object") { s = typeof o.className === p; o = b.extend({}, b.watermark.options, o) } else if (typeof o === p) { s = c; o = b.extend({}, b.watermark.options, { className: o }) } else o = b.watermark.options; if (typeof o.useNative !== l) o.useNative = o.useNative ? function () { return c } : function () { return e }; return this.each(function () { var v = "dragleave", u = "dragenter", x = this, e = b(x); if (!e.is(n)) return; if (e.data(m)) { if (t || s) { b.watermark._hide(e); t && e.data(g, r); s && e.data(i, o.className) } } else { if (o.useNative.call(x, e)) if ((a + e.css("-webkit-appearance")).replace("undefined", a) !== a && (e.attr("tagName") || a) !== "TEXTAREA") { t && e.attr("placeholder", r); return } e.data(g, t ? r : a); e.data(i, o.className); e.data(m, 1); if ((e.attr(f) || a) === j) { var y = e.wrap("<span>").parent(), l = b(y.html().replace(/type=["']?password["']?/i, 'type="text"')); l.data(g, e.data(g)); l.data(i, e.data(i)); l.data(m, 1); l.attr(d, r.length); l.focus(function () { b.watermark._hide(l, c) }).bind(u, function () { b.watermark._hide(l) }).bind("dragend", function () { window.setTimeout(function () { l.blur() }, 1) }); e.blur(function () { b.watermark._show(e) }).bind(v, function () { b.watermark._show(e) }); l.data(h, e); e.data(h, l) } else e.focus(function () { e.data(q, 1); b.watermark._hide(e, c) }).blur(function () { e.data(q, 0); b.watermark._show(e) }).bind(u, function () { b.watermark._hide(e) }).bind(v, function () { b.watermark._show(e) }).bind("dragend", function () { window.setTimeout(function () { b.watermark._show(e) }, 1) }).bind("drop", function (c) { var b = c.originalEvent.dataTransfer.getData("Text"); e.val().replace(b, a) === e.data(g) && e.val(b); e.focus() }); if (x.form) { var p = x.form, w = b(p); if (!w.data(k)) { w.submit(b.watermark.hideAll); if (p.submit) { w.data(k, p.submit); p.submit = function (c, a) { return function () { var d = a.data(k); b.watermark.hideAll(); if (d.apply) d.apply(c, Array.prototype.slice.call(arguments)); else d() } } (p, w) } else { w.data(k, 1); p.submit = function (a) { return function () { b.watermark.hideAll(); delete a.submit; a.submit() } } (p) } } } } b.watermark._show(e) }) }; p.length && b(function () { for (var a, c, d = p.length - 1; d >= 0; d--) { a = p[d]; c = window[a]; if (typeof c === l) window[a] = function (a) { return function () { b.watermark.hideAll(); return a.apply(null, Array.prototype.slice.call(arguments)) } } (c) } }) })(jQuery);


// jquery.cookie START
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
*       used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
*                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
*                             If set to null or omitted, the cookie will be a session cookie and will not be retained
*                             when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
*                        require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function (name, value, options) {
		if (typeof value != 'undefined') { // name and value given, set cookie
				options = options || {};
				if (value === null) {
						value = '';
						options.expires = -1;
				}
				var expires = '';
				if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
						var date;
						if (typeof options.expires == 'number') {
								date = new Date();
								date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
						} else {
								date = options.expires;
						}
						expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
				}
				// CAUTION: Needed to parenthesize options.path and options.domain
				// in the following expressions, otherwise they evaluate to undefined
				// in the packed version for some reason...
				var path = options.path ? '; path=' + (options.path) : '';
				var domain = options.domain ? '; domain=' + (options.domain) : '';
				var secure = options.secure ? '; secure' : '';
				document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		} else { // only name given, get cookie
				var cookieValue = null;
				if (document.cookie && document.cookie != '') {
						var cookies = document.cookie.split(';');
						for (var i = 0; i < cookies.length; i++) {
								var cookie = jQuery.trim(cookies[i]);
								// Does this cookie string begin with the name we want?
								if (cookie.substring(0, name.length + 1) == (name + '=')) {
										cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
										break;
								}
						}
				}
				return cookieValue;
		}
};

// jquery.json-1.3.min START
(function ($) {
		function toIntegersAtLease(n)
		{ return n < 10 ? '0' + n : n; }
		Date.prototype.toJSON = function (date) {
				return this.getUTCFullYear() + '-' +
toIntegersAtLease(this.getUTCMonth()) + '-' +
toIntegersAtLease(this.getUTCDate());
		}; var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g; var meta = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }; $.quoteString = function (string) {
				if (escapeable.test(string)) {
						return '"' + string.replace(escapeable, function (a) {
								var c = meta[a]; if (typeof c === 'string') { return c; }
								c = a.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
						}) + '"';
				}
				return '"' + string + '"';
		}; $.toJSON = function (o, compact) {
				var type = typeof (o); if (type == "undefined")
						return "undefined"; else if (type == "number" || type == "boolean")
						return o + ""; else if (o === null)
						return "null"; if (type == "string")
				{ return $.quoteString(o); }
				if (type == "object" && typeof o.toJSON == "function")
						return o.toJSON(compact); if (type != "function" && typeof (o.length) == "number") {
						var ret = []; for (var i = 0; i < o.length; i++) { ret.push($.toJSON(o[i], compact)); }
						if (compact)
								return "[" + ret.join(",") + "]"; else
								return "[" + ret.join(", ") + "]";
				}
				if (type == "function") { throw new TypeError("Unable to convert object of type 'function' to json."); }
				var ret = []; for (var k in o) {
						var name; type = typeof (k); if (type == "number")
								name = '"' + k + '"'; else if (type == "string")
								name = $.quoteString(k); else
								continue; var val = $.toJSON(o[k], compact); if (typeof (val) != "string") { continue; }
						if (compact)
								ret.push(name + ":" + val); else
								ret.push(name + ": " + val);
				}
				return "{" + ret.join(", ") + "}";
		}; $.compactJSON = function (o)
		{ return $.toJSON(o, true); }; $.evalJSON = function (src)
		{ return eval("(" + src + ")"); }; $.secureEvalJSON = function (src) {
				var filtered = src; filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@'); filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'); filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, ''); if (/^[\],:{}\s]*$/.test(filtered))
						return eval("(" + src + ")"); else
						throw new SyntaxError("Error parsing JSON, source is not valid.");
		};
})(jQuery);


// jquery.qtip-1.0.0-rc3.min START
/*
 * jquery.qtip. The jQuery tooltip plugin
 *
 * Copyright (c) 2009 Craig Thompson
 * http://craigsworks.com
 *
 * Licensed under MIT
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Launch  : February 2009
 * Version : 1.0.0-rc3
 * Released: Tuesday 12th May, 2009 - 00:00
 * Debug: jquery.qtip.debug.js
(function(f) { f.fn.qtip = function(B, u) { var y, t, A, s, x, w, v, z; if (typeof B == "string") { if (typeof f(this).data("qtip") !== "object") { f.fn.qtip.log.error.call(self, 1, f.fn.qtip.constants.NO_TOOLTIP_PRESENT, false) } if (B == "api") { return f(this).data("qtip").interfaces[f(this).data("qtip").current] } else { if (B == "interfaces") { return f(this).data("qtip").interfaces } } } else { if (!B) { B = {} } if (typeof B.content !== "object" || (B.content.jquery && B.content.length > 0)) { B.content = { text: B.content} } if (typeof B.content.title !== "object") { B.content.title = { text: B.content.title} } if (typeof B.position !== "object") { B.position = { corner: B.position} } if (typeof B.position.corner !== "object") { B.position.corner = { target: B.position.corner, tooltip: B.position.corner} } if (typeof B.show !== "object") { B.show = { when: B.show} } if (typeof B.show.when !== "object") { B.show.when = { event: B.show.when} } if (typeof B.show.effect !== "object") { B.show.effect = { type: B.show.effect} } if (typeof B.hide !== "object") { B.hide = { when: B.hide} } if (typeof B.hide.when !== "object") { B.hide.when = { event: B.hide.when} } if (typeof B.hide.effect !== "object") { B.hide.effect = { type: B.hide.effect} } if (typeof B.style !== "object") { B.style = { name: B.style} } B.style = c(B.style); s = f.extend(true, {}, f.fn.qtip.defaults, B); s.style = a.call({ options: s }, s.style); s.user = f.extend(true, {}, B) } return f(this).each(function() { if (typeof B == "string") { w = B.toLowerCase(); A = f(this).qtip("interfaces"); if (typeof A == "object") { if (u === true && w == "destroy") { while (A.length > 0) { A[A.length - 1].destroy() } } else { if (u !== true) { A = [f(this).qtip("api")] } for (y = 0; y < A.length; y++) { if (w == "destroy") { A[y].destroy() } else { if (A[y].status.rendered === true) { if (w == "show") { A[y].show() } else { if (w == "hide") { A[y].hide() } else { if (w == "focus") { A[y].focus() } else { if (w == "disable") { A[y].disable(true) } else { if (w == "enable") { A[y].disable(false) } } } } } } } } } } } else { v = f.extend(true, {}, s); v.hide.effect.length = s.hide.effect.length; v.show.effect.length = s.show.effect.length; if (v.position.container === false) { v.position.container = f(document.body) } if (v.position.target === false) { v.position.target = f(this) } if (v.show.when.target === false) { v.show.when.target = f(this) } if (v.hide.when.target === false) { v.hide.when.target = f(this) } t = f.fn.qtip.interfaces.length; for (y = 0; y < t; y++) { if (typeof f.fn.qtip.interfaces[y] == "undefined") { t = y; break } } x = new d(f(this), v, t); f.fn.qtip.interfaces[t] = x; if (typeof f(this).data("qtip") == "object") { if (typeof f(this).attr("qtip") === "undefined") { f(this).data("qtip").current = f(this).data("qtip").interfaces.length } f(this).data("qtip").interfaces.push(x) } else { f(this).data("qtip", { current: 0, interfaces: [x] }) } if (v.content.prerender === false && v.show.when.event !== false && v.show.ready !== true) { v.show.when.target.bind(v.show.when.event + ".qtip-" + t + "-create", { qtip: t }, function(C) { z = f.fn.qtip.interfaces[C.data.qtip]; z.options.show.when.target.unbind(z.options.show.when.event + ".qtip-" + C.data.qtip + "-create"); z.cache.mouse = { x: C.pageX, y: C.pageY }; p.call(z); z.options.show.when.target.trigger(z.options.show.when.event) }) } else { x.cache.mouse = { x: v.show.when.target.offset().left, y: v.show.when.target.offset().top }; p.call(x) } } }) }; function d(u, t, v) { var s = this; s.id = v; s.options = t; s.status = { animated: false, rendered: false, disabled: false, focused: false }; s.elements = { target: u.addClass(s.options.style.classes.target), tooltip: null, wrapper: null, content: null, contentWrapper: null, title: null, button: null, tip: null, bgiframe: null }; s.cache = { mouse: {}, position: {}, toggle: 0 }; s.timers = {}; f.extend(s, s.options.api, { show: function(y) { var x, z; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "show") } if (s.elements.tooltip.css("display") !== "none") { return s } s.elements.tooltip.stop(true, false); x = s.beforeShow.call(s, y); if (x === false) { return s } function w() { if (s.options.position.type !== "static") { s.focus() } s.onShow.call(s, y); if (f.browser.msie) { s.elements.tooltip.get(0).style.removeAttribute("filter") } } s.cache.toggle = 1; if (s.options.position.type !== "static") { s.updatePosition(y, (s.options.show.effect.length > 0)) } if (typeof s.options.show.solo == "object") { z = f(s.options.show.solo) } else { if (s.options.show.solo === true) { z = f("div.qtip").not(s.elements.tooltip) } } if (z) { z.each(function() { if (f(this).qtip("api").status.rendered === true) { f(this).qtip("api").hide() } }) } if (typeof s.options.show.effect.type == "function") { s.options.show.effect.type.call(s.elements.tooltip, s.options.show.effect.length); s.elements.tooltip.queue(function() { w(); f(this).dequeue() }) } else { switch (s.options.show.effect.type.toLowerCase()) { case "fade": s.elements.tooltip.fadeIn(s.options.show.effect.length, w); break; case "slide": s.elements.tooltip.slideDown(s.options.show.effect.length, function() { w(); if (s.options.position.type !== "static") { s.updatePosition(y, true) } }); break; case "grow": s.elements.tooltip.show(s.options.show.effect.length, w); break; default: s.elements.tooltip.show(null, w); break } s.elements.tooltip.addClass(s.options.style.classes.active) } return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_SHOWN, "show") }, hide: function(y) { var x; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "hide") } else { if (s.elements.tooltip.css("display") === "none") { return s } } clearTimeout(s.timers.show); s.elements.tooltip.stop(true, false); x = s.beforeHide.call(s, y); if (x === false) { return s } function w() { s.onHide.call(s, y) } s.cache.toggle = 0; if (typeof s.options.hide.effect.type == "function") { s.options.hide.effect.type.call(s.elements.tooltip, s.options.hide.effect.length); s.elements.tooltip.queue(function() { w(); f(this).dequeue() }) } else { switch (s.options.hide.effect.type.toLowerCase()) { case "fade": s.elements.tooltip.fadeOut(s.options.hide.effect.length, w); break; case "slide": s.elements.tooltip.slideUp(s.options.hide.effect.length, w); break; case "grow": s.elements.tooltip.hide(s.options.hide.effect.length, w); break; default: s.elements.tooltip.hide(null, w); break } s.elements.tooltip.removeClass(s.options.style.classes.active) } return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_HIDDEN, "hide") }, updatePosition: function(w, x) { var C, G, L, J, H, E, y, I, B, D, K, A, F, z; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updatePosition") } else { if (s.options.position.type == "static") { return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.CANNOT_POSITION_STATIC, "updatePosition") } } G = { position: { left: 0, top: 0 }, dimensions: { height: 0, width: 0 }, corner: s.options.position.corner.target }; L = { position: s.getPosition(), dimensions: s.getDimensions(), corner: s.options.position.corner.tooltip }; if (s.options.position.target !== "mouse") { if (s.options.position.target.get(0).nodeName.toLowerCase() == "area") { J = s.options.position.target.attr("coords").split(","); for (C = 0; C < J.length; C++) { J[C] = parseInt(J[C]) } H = s.options.position.target.parent("map").attr("name"); E = f('img[usemap="#' + H + '"]:first').offset(); G.position = { left: Math.floor(E.left + J[0]), top: Math.floor(E.top + J[1]) }; switch (s.options.position.target.attr("shape").toLowerCase()) { case "rect": G.dimensions = { width: Math.ceil(Math.abs(J[2] - J[0])), height: Math.ceil(Math.abs(J[3] - J[1])) }; break; case "circle": G.dimensions = { width: J[2] + 1, height: J[2] + 1 }; break; case "poly": G.dimensions = { width: J[0], height: J[1] }; for (C = 0; C < J.length; C++) { if (C % 2 == 0) { if (J[C] > G.dimensions.width) { G.dimensions.width = J[C] } if (J[C] < J[0]) { G.position.left = Math.floor(E.left + J[C]) } } else { if (J[C] > G.dimensions.height) { G.dimensions.height = J[C] } if (J[C] < J[1]) { G.position.top = Math.floor(E.top + J[C]) } } } G.dimensions.width = G.dimensions.width - (G.position.left - E.left); G.dimensions.height = G.dimensions.height - (G.position.top - E.top); break; default: return f.fn.qtip.log.error.call(s, 4, f.fn.qtip.constants.INVALID_AREA_SHAPE, "updatePosition"); break } G.dimensions.width -= 2; G.dimensions.height -= 2 } else { if (s.options.position.target.add(document.body).length === 1) { G.position = { left: f(document).scrollLeft(), top: f(document).scrollTop() }; G.dimensions = { height: f(window).height(), width: f(window).width()} } else { if (typeof s.options.position.target.attr("qtip") !== "undefined") { G.position = s.options.position.target.qtip("api").cache.position } else { G.position = s.options.position.target.offset() } G.dimensions = { height: s.options.position.target.outerHeight(), width: s.options.position.target.outerWidth()} } } y = f.extend({}, G.position); if (G.corner.search(/right/i) !== -1) { y.left += G.dimensions.width } if (G.corner.search(/bottom/i) !== -1) { y.top += G.dimensions.height } if (G.corner.search(/((top|bottom)Middle)|center/) !== -1) { y.left += (G.dimensions.width / 2) } if (G.corner.search(/((left|right)Middle)|center/) !== -1) { y.top += (G.dimensions.height / 2) } } else { G.position = y = { left: s.cache.mouse.x, top: s.cache.mouse.y }; G.dimensions = { height: 1, width: 1} } if (L.corner.search(/right/i) !== -1) { y.left -= L.dimensions.width } if (L.corner.search(/bottom/i) !== -1) { y.top -= L.dimensions.height } if (L.corner.search(/((top|bottom)Middle)|center/) !== -1) { y.left -= (L.dimensions.width / 2) } if (L.corner.search(/((left|right)Middle)|center/) !== -1) { y.top -= (L.dimensions.height / 2) } I = (f.browser.msie) ? 1 : 0; B = (f.browser.msie && parseInt(f.browser.version.charAt(0)) === 6) ? 1 : 0; if (s.options.style.border.radius > 0) { if (L.corner.search(/Left/) !== -1) { y.left -= s.options.style.border.radius } else { if (L.corner.search(/Right/) !== -1) { y.left += s.options.style.border.radius } } if (L.corner.search(/Top/) !== -1) { y.top -= s.options.style.border.radius } else { if (L.corner.search(/Bottom/) !== -1) { y.top += s.options.style.border.radius } } } if (I) { if (L.corner.search(/top/) !== -1) { y.top -= I } else { if (L.corner.search(/bottom/) !== -1) { y.top += I } } if (L.corner.search(/left/) !== -1) { y.left -= I } else { if (L.corner.search(/right/) !== -1) { y.left += I } } if (L.corner.search(/leftMiddle|rightMiddle/) !== -1) { y.top -= 1 } } if (s.options.position.adjust.screen === true) { y = o.call(s, y, G, L) } if (s.options.position.target === "mouse" && s.options.position.adjust.mouse === true) { if (s.options.position.adjust.screen === true && s.elements.tip) { K = s.elements.tip.attr("rel") } else { K = s.options.position.corner.tooltip } y.left += (K.search(/right/i) !== -1) ? -6 : 6; y.top += (K.search(/bottom/i) !== -1) ? -6 : 6 } if (!s.elements.bgiframe && f.browser.msie && parseInt(f.browser.version.charAt(0)) == 6) { f("select, object").each(function() { A = f(this).offset(); A.bottom = A.top + f(this).height(); A.right = A.left + f(this).width(); if (y.top + L.dimensions.height >= A.top && y.left + L.dimensions.width >= A.left) { k.call(s) } }) } y.left += s.options.position.adjust.x; y.top += s.options.position.adjust.y; F = s.getPosition(); if (y.left != F.left || y.top != F.top) { z = s.beforePositionUpdate.call(s, w); if (z === false) { return s } s.cache.position = y; if (x === true) { s.status.animated = true; s.elements.tooltip.animate(y, 200, "swing", function() { s.status.animated = false }) } else { s.elements.tooltip.css(y) } s.onPositionUpdate.call(s, w); if (typeof w !== "undefined" && w.type && w.type !== "mousemove") { f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_POSITION_UPDATED, "updatePosition") } } return s }, updateWidth: function(w) { var x; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateWidth") } else { if (w && typeof w !== "number") { return f.fn.qtip.log.error.call(s, 2, "newWidth must be of type number", "updateWidth") } } x = s.elements.contentWrapper.siblings().add(s.elements.tip).add(s.elements.button); if (!w) { if (typeof s.options.style.width.value == "number") { w = s.options.style.width.value } else { s.elements.tooltip.css({ width: "auto" }); x.hide(); if (f.browser.msie) { s.elements.wrapper.add(s.elements.contentWrapper.children()).css({ zoom: "normal" }) } w = s.getDimensions().width + 1; if (!s.options.style.width.value) { if (w > s.options.style.width.max) { w = s.options.style.width.max } if (w < s.options.style.width.min) { w = s.options.style.width.min } } } } if (w % 2 !== 0) { w -= 1 } s.elements.tooltip.width(w); x.show(); if (s.options.style.border.radius) { s.elements.tooltip.find(".qtip-betweenCorners").each(function(y) { f(this).width(w - (s.options.style.border.radius * 2)) }) } if (f.browser.msie) { s.elements.wrapper.add(s.elements.contentWrapper.children()).css({ zoom: "1" }); s.elements.wrapper.width(w); if (s.elements.bgiframe) { s.elements.bgiframe.width(w).height(s.getDimensions.height) } } return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_WIDTH_UPDATED, "updateWidth") }, updateStyle: function(w) { var z, A, x, y, B; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateStyle") } else { if (typeof w !== "string" || !f.fn.qtip.styles[w]) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.STYLE_NOT_DEFINED, "updateStyle") } } s.options.style = a.call(s, f.fn.qtip.styles[w], s.options.user.style); s.elements.content.css(q(s.options.style)); if (s.options.content.title.text !== false) { s.elements.title.css(q(s.options.style.title, true)) } s.elements.contentWrapper.css({ borderColor: s.options.style.border.color }); if (s.options.style.tip.corner !== false) { if (f("<canvas>").get(0).getContext) { z = s.elements.tooltip.find(".qtip-tip canvas:first"); x = z.get(0).getContext("2d"); x.clearRect(0, 0, 300, 300); y = z.parent("div[rel]:first").attr("rel"); B = b(y, s.options.style.tip.size.width, s.options.style.tip.size.height); h.call(s, z, B, s.options.style.tip.color || s.options.style.border.color) } else { if (f.browser.msie) { z = s.elements.tooltip.find('.qtip-tip [nodeName="shape"]'); z.attr("fillcolor", s.options.style.tip.color || s.options.style.border.color) } } } if (s.options.style.border.radius > 0) { s.elements.tooltip.find(".qtip-betweenCorners").css({ backgroundColor: s.options.style.border.color }); if (f("<canvas>").get(0).getContext) { A = g(s.options.style.border.radius); s.elements.tooltip.find(".qtip-wrapper canvas").each(function() { x = f(this).get(0).getContext("2d"); x.clearRect(0, 0, 300, 300); y = f(this).parent("div[rel]:first").attr("rel"); r.call(s, f(this), A[y], s.options.style.border.radius, s.options.style.border.color) }) } else { if (f.browser.msie) { s.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function() { f(this).attr("fillcolor", s.options.style.border.color) }) } } } return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_STYLE_UPDATED, "updateStyle") }, updateContent: function(A, y) { var z, x, w; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateContent") } else { if (!A) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.NO_CONTENT_PROVIDED, "updateContent") } } z = s.beforeContentUpdate.call(s, A); if (typeof z == "string") { A = z } else { if (z === false) { return } } if (f.browser.msie) { s.elements.contentWrapper.children().css({ zoom: "normal" }) } if (A.jquery && A.length > 0) { A.clone(true).appendTo(s.elements.content).show() } else { s.elements.content.html(A) } x = s.elements.content.find("img[complete=false]"); if (x.length > 0) { w = 0; x.each(function(C) { f('<img src="' + f(this).attr("src") + '" />').load(function() { if (++w == x.length) { B() } }) }) } else { B() } function B() { s.updateWidth(); if (y !== false) { if (s.options.position.type !== "static") { s.updatePosition(s.elements.tooltip.is(":visible"), true) } if (s.options.style.tip.corner !== false) { n.call(s) } } } s.onContentUpdate.call(s); return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_CONTENT_UPDATED, "loadContent") }, loadContent: function(w, z, A) { var y; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "loadContent") } y = s.beforeContentLoad.call(s); if (y === false) { return s } if (A == "post") { f.post(w, z, x) } else { f.get(w, z, x) } function x(B) { s.onContentLoad.call(s); f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_CONTENT_LOADED, "loadContent"); s.updateContent(B) } return s }, updateTitle: function(w) { if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "updateTitle") } else { if (!w) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.NO_CONTENT_PROVIDED, "updateTitle") } } returned = s.beforeTitleUpdate.call(s); if (returned === false) { return s } if (s.elements.button) { s.elements.button = s.elements.button.clone(true) } s.elements.title.html(w); if (s.elements.button) { s.elements.title.prepend(s.elements.button) } s.onTitleUpdate.call(s); return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_TITLE_UPDATED, "updateTitle") }, focus: function(A) { var y, x, w, z; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "focus") } else { if (s.options.position.type == "static") { return f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.CANNOT_FOCUS_STATIC, "focus") } } y = parseInt(s.elements.tooltip.css("z-index")); x = 6000 + f("div.qtip[qtip]").length - 1; if (!s.status.focused && y !== x) { z = s.beforeFocus.call(s, A); if (z === false) { return s } f("div.qtip[qtip]").not(s.elements.tooltip).each(function() { if (f(this).qtip("api").status.rendered === true) { w = parseInt(f(this).css("z-index")); if (typeof w == "number" && w > -1) { f(this).css({ zIndex: parseInt(f(this).css("z-index")) - 1 }) } f(this).qtip("api").status.focused = false } }); s.elements.tooltip.css({ zIndex: x }); s.status.focused = true; s.onFocus.call(s, A); f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_FOCUSED, "focus") } return s }, disable: function(w) { if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "disable") } if (w) { if (!s.status.disabled) { s.status.disabled = true; f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_DISABLED, "disable") } else { f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED, "disable") } } else { if (s.status.disabled) { s.status.disabled = false; f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_ENABLED, "disable") } else { f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED, "disable") } } return s }, destroy: function() { var w, x, y; x = s.beforeDestroy.call(s); if (x === false) { return s } if (s.status.rendered) { s.options.show.when.target.unbind("mousemove.qtip", s.updatePosition); s.options.show.when.target.unbind("mouseout.qtip", s.hide); s.options.show.when.target.unbind(s.options.show.when.event + ".qtip"); s.options.hide.when.target.unbind(s.options.hide.when.event + ".qtip"); s.elements.tooltip.unbind(s.options.hide.when.event + ".qtip"); s.elements.tooltip.unbind("mouseover.qtip", s.focus); s.elements.tooltip.remove() } else { s.options.show.when.target.unbind(s.options.show.when.event + ".qtip-create") } if (typeof s.elements.target.data("qtip") == "object") { y = s.elements.target.data("qtip").interfaces; if (typeof y == "object" && y.length > 0) { for (w = 0; w < y.length - 1; w++) { if (y[w].id == s.id) { y.splice(w, 1) } } } } delete f.fn.qtip.interfaces[s.id]; if (typeof y == "object" && y.length > 0) { s.elements.target.data("qtip").current = y.length - 1 } else { s.elements.target.removeData("qtip") } s.onDestroy.call(s); f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_DESTROYED, "destroy"); return s.elements.target }, getPosition: function() { var w, x; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "getPosition") } w = (s.elements.tooltip.css("display") !== "none") ? false : true; if (w) { s.elements.tooltip.css({ visiblity: "hidden" }).show() } x = s.elements.tooltip.offset(); if (w) { s.elements.tooltip.css({ visiblity: "visible" }).hide() } return x }, getDimensions: function() { var w, x; if (!s.status.rendered) { return f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.TOOLTIP_NOT_RENDERED, "getDimensions") } w = (!s.elements.tooltip.is(":visible")) ? true : false; if (w) { s.elements.tooltip.css({ visiblity: "hidden" }).show() } x = { height: s.elements.tooltip.outerHeight(), width: s.elements.tooltip.outerWidth() }; if (w) { s.elements.tooltip.css({ visiblity: "visible" }).hide() } return x } }) } function p() { var s, w, u, t, v, y, x; s = this; s.beforeRender.call(s); s.status.rendered = true; s.elements.tooltip = '<div qtip="' + s.id + '" class="qtip ' + (s.options.style.classes.tooltip || s.options.style) + '"style="display:none; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0;position:' + s.options.position.type + ';">  <div class="qtip-wrapper" style="position:relative; overflow:hidden; text-align:left;">    <div class="qtip-contentWrapper" style="overflow:hidden;">       <div class="qtip-content ' + s.options.style.classes.content + '"></div></div></div></div>'; s.elements.tooltip = f(s.elements.tooltip); s.elements.tooltip.appendTo(s.options.position.container); s.elements.tooltip.data("qtip", { current: 0, interfaces: [s] }); s.elements.wrapper = s.elements.tooltip.children("div:first"); s.elements.contentWrapper = s.elements.wrapper.children("div:first").css({ background: s.options.style.background }); s.elements.content = s.elements.contentWrapper.children("div:first").css(q(s.options.style)); if (f.browser.msie) { s.elements.wrapper.add(s.elements.content).css({ zoom: 1 }) } if (s.options.hide.when.event == "unfocus") { s.elements.tooltip.attr("unfocus", true) } if (typeof s.options.style.width.value == "number") { s.updateWidth() } if (f("<canvas>").get(0).getContext || f.browser.msie) { if (s.options.style.border.radius > 0) { m.call(s) } else { s.elements.contentWrapper.css({ border: s.options.style.border.width + "px solid " + s.options.style.border.color }) } if (s.options.style.tip.corner !== false) { e.call(s) } } else { s.elements.contentWrapper.css({ border: s.options.style.border.width + "px solid " + s.options.style.border.color }); s.options.style.border.radius = 0; s.options.style.tip.corner = false; f.fn.qtip.log.error.call(s, 2, f.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED, "render") } if ((typeof s.options.content.text == "string" && s.options.content.text.length > 0) || (s.options.content.text.jquery && s.options.content.text.length > 0)) { u = s.options.content.text } else { if (typeof s.elements.target.attr("title") == "string" && s.elements.target.attr("title").length > 0) { u = s.elements.target.attr("title").replace("\\n", "<br />"); s.elements.target.attr("title", "") } else { if (typeof s.elements.target.attr("alt") == "string" && s.elements.target.attr("alt").length > 0) { u = s.elements.target.attr("alt").replace("\\n", "<br />"); s.elements.target.attr("alt", "") } else { u = " "; f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.NO_VALID_CONTENT, "render") } } } if (s.options.content.title.text !== false) { j.call(s) } s.updateContent(u); l.call(s); if (s.options.show.ready === true) { s.show() } if (s.options.content.url !== false) { t = s.options.content.url; v = s.options.content.data; y = s.options.content.method || "get"; s.loadContent(t, v, y) } s.onRender.call(s); f.fn.qtip.log.error.call(s, 1, f.fn.qtip.constants.EVENT_RENDERED, "render") } function m() { var F, z, t, B, x, E, u, G, D, y, w, C, A, s, v; F = this; F.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove(); t = F.options.style.border.width; B = F.options.style.border.radius; x = F.options.style.border.color || F.options.style.tip.color; E = g(B); u = {}; for (z in E) { u[z] = '<div rel="' + z + '" style="' + ((z.search(/Left/) !== -1) ? "left" : "right") + ":0; position:absolute; height:" + B + "px; width:" + B + 'px; overflow:hidden; line-height:0.1px; font-size:1px">'; if (f("<canvas>").get(0).getContext) { u[z] += '<canvas height="' + B + '" width="' + B + '" style="vertical-align: top"></canvas>' } else { if (f.browser.msie) { G = B * 2 + 3; u[z] += '<v:arc stroked="false" fillcolor="' + x + '" startangle="' + E[z][0] + '" endangle="' + E[z][1] + '" style="width:' + G + "px; height:" + G + "px; margin-top:" + ((z.search(/bottom/) !== -1) ? -2 : -1) + "px; margin-left:" + ((z.search(/Right/) !== -1) ? E[z][2] - 3.5 : -1) + 'px; vertical-align:top; display:inline-block; behavior:url(#default#VML)"></v:arc>' } } u[z] += "</div>" } D = F.getDimensions().width - (Math.max(t, B) * 2); y = '<div class="qtip-betweenCorners" style="height:' + B + "px; width:" + D + "px; overflow:hidden; background-color:" + x + '; line-height:0.1px; font-size:1px;">'; w = '<div class="qtip-borderTop" dir="ltr" style="height:' + B + "px; margin-left:" + B + 'px; line-height:0.1px; font-size:1px; padding:0;">' + u.topLeft + u.topRight + y; F.elements.wrapper.prepend(w); C = '<div class="qtip-borderBottom" dir="ltr" style="height:' + B + "px; margin-left:" + B + 'px; line-height:0.1px; font-size:1px; padding:0;">' + u.bottomLeft + u.bottomRight + y; F.elements.wrapper.append(C); if (f("<canvas>").get(0).getContext) { F.elements.wrapper.find("canvas").each(function() { A = E[f(this).parent("[rel]:first").attr("rel")]; r.call(F, f(this), A, B, x) }) } else { if (f.browser.msie) { F.elements.tooltip.append('<v:image style="behavior:url(#default#VML);"></v:image>') } } s = Math.max(B, (B + (t - B))); v = Math.max(t - B, 0); F.elements.contentWrapper.css({ border: "0px solid " + x, borderWidth: v + "px " + s + "px" }) } function r(u, w, s, t) { var v = u.get(0).getContext("2d"); v.fillStyle = t; v.beginPath(); v.arc(w[0], w[1], s, 0, Math.PI * 2, false); v.fill() } function e(v) { var t, s, x, u, w; t = this; if (t.elements.tip !== null) { t.elements.tip.remove() } s = t.options.style.tip.color || t.options.style.border.color; if (t.options.style.tip.corner === false) { return } else { if (!v) { v = t.options.style.tip.corner } } x = b(v, t.options.style.tip.size.width, t.options.style.tip.size.height); t.elements.tip = '<div class="' + t.options.style.classes.tip + '" dir="ltr" rel="' + v + '" style="position:absolute; height:' + t.options.style.tip.size.height + "px; width:" + t.options.style.tip.size.width + 'px; margin:0 auto; line-height:0.1px; font-size:1px;">'; if (f("<canvas>").get(0).getContext) { t.elements.tip += '<canvas height="' + t.options.style.tip.size.height + '" width="' + t.options.style.tip.size.width + '"></canvas>' } else { if (f.browser.msie) { u = t.options.style.tip.size.width + "," + t.options.style.tip.size.height; w = "m" + x[0][0] + "," + x[0][1]; w += " l" + x[1][0] + "," + x[1][1]; w += " " + x[2][0] + "," + x[2][1]; w += " xe"; t.elements.tip += '<v:shape fillcolor="' + s + '" stroked="false" filled="true" path="' + w + '" coordsize="' + u + '" style="width:' + t.options.style.tip.size.width + "px; height:" + t.options.style.tip.size.height + "px; line-height:0.1px; display:inline-block; behavior:url(#default#VML); vertical-align:" + ((v.search(/top/) !== -1) ? "bottom" : "top") + '"></v:shape>'; t.elements.tip += '<v:image style="behavior:url(#default#VML);"></v:image>'; t.elements.contentWrapper.css("position", "relative") } } t.elements.tooltip.prepend(t.elements.tip + "</div>"); t.elements.tip = t.elements.tooltip.find("." + t.options.style.classes.tip).eq(0); if (f("<canvas>").get(0).getContext) { h.call(t, t.elements.tip.find("canvas:first"), x, s) } if (v.search(/top/) !== -1 && f.browser.msie && parseInt(f.browser.version.charAt(0)) === 6) { t.elements.tip.css({ marginTop: -4 }) } n.call(t, v) } function h(t, v, s) { var u = t.get(0).getContext("2d"); u.fillStyle = s; u.beginPath(); u.moveTo(v[0][0], v[0][1]); u.lineTo(v[1][0], v[1][1]); u.lineTo(v[2][0], v[2][1]); u.fill() } function n(u) { var t, w, s, x, v; t = this; if (t.options.style.tip.corner === false || !t.elements.tip) { return } if (!u) { u = t.elements.tip.attr("rel") } w = positionAdjust = (f.browser.msie) ? 1 : 0; t.elements.tip.css(u.match(/left|right|top|bottom/)[0], 0); if (u.search(/top|bottom/) !== -1) { if (f.browser.msie) { if (parseInt(f.browser.version.charAt(0)) === 6) { positionAdjust = (u.search(/top/) !== -1) ? -3 : 1 } else { positionAdjust = (u.search(/top/) !== -1) ? 1 : 2 } } if (u.search(/Middle/) !== -1) { t.elements.tip.css({ left: "50%", marginLeft: -(t.options.style.tip.size.width / 2) }) } else { if (u.search(/Left/) !== -1) { t.elements.tip.css({ left: t.options.style.border.radius - w }) } else { if (u.search(/Right/) !== -1) { t.elements.tip.css({ right: t.options.style.border.radius + w }) } } } if (u.search(/top/) !== -1) { t.elements.tip.css({ top: -positionAdjust }) } else { t.elements.tip.css({ bottom: positionAdjust }) } } else { if (u.search(/left|right/) !== -1) { if (f.browser.msie) { positionAdjust = (parseInt(f.browser.version.charAt(0)) === 6) ? 1 : ((u.search(/left/) !== -1) ? 1 : 2) } if (u.search(/Middle/) !== -1) { t.elements.tip.css({ top: "50%", marginTop: -(t.options.style.tip.size.height / 2) }) } else { if (u.search(/Top/) !== -1) { t.elements.tip.css({ top: t.options.style.border.radius - w }) } else { if (u.search(/Bottom/) !== -1) { t.elements.tip.css({ bottom: t.options.style.border.radius + w }) } } } if (u.search(/left/) !== -1) { t.elements.tip.css({ left: -positionAdjust }) } else { t.elements.tip.css({ right: positionAdjust }) } } } s = "padding-" + u.match(/left|right|top|bottom/)[0]; x = t.options.style.tip.size[(s.search(/left|right/) !== -1) ? "width" : "height"]; t.elements.tooltip.css("padding", 0); t.elements.tooltip.css(s, x); if (f.browser.msie && parseInt(f.browser.version.charAt(0)) == 6) { v = parseInt(t.elements.tip.css("margin-top")) || 0; v += parseInt(t.elements.content.css("margin-top")) || 0; t.elements.tip.css({ marginTop: v }) } } function j() { var s = this; if (s.elements.title !== null) { s.elements.title.remove() } s.elements.title = f('<div class="' + s.options.style.classes.title + '">').css(q(s.options.style.title, true)).css({ zoom: (f.browser.msie) ? 1 : 0 }).prependTo(s.elements.contentWrapper); if (s.options.content.title.text) { s.updateTitle.call(s, s.options.content.title.text) } if (s.options.content.title.button !== false && typeof s.options.content.title.button == "string") { s.elements.button = f('<a class="' + s.options.style.classes.button + '" style="float:right; position: relative"></a>').css(q(s.options.style.button, true)).html(s.options.content.title.button).prependTo(s.elements.title).click(function(t) { if (!s.status.disabled) { s.hide(t) } }) } } function l() { var t, v, u, s; t = this; v = t.options.show.when.target; u = t.options.hide.when.target; if (t.options.hide.fixed) { u = u.add(t.elements.tooltip) } if (t.options.hide.when.event == "inactive") { s = ["click", "dblclick", "mousedown", "mouseup", "mousemove", "mouseout", "mouseenter", "mouseleave", "mouseover"]; function y(z) { if (t.status.disabled === true) { return } clearTimeout(t.timers.inactive); t.timers.inactive = setTimeout(function() { f(s).each(function() { u.unbind(this + ".qtip-inactive"); t.elements.content.unbind(this + ".qtip-inactive") }); t.hide(z) }, t.options.hide.delay) } } else { if (t.options.hide.fixed === true) { t.elements.tooltip.bind("mouseover.qtip", function() { if (t.status.disabled === true) { return } clearTimeout(t.timers.hide) }) } } function x(z) { if (t.status.disabled === true) { return } if (t.options.hide.when.event == "inactive") { f(s).each(function() { u.bind(this + ".qtip-inactive", y); t.elements.content.bind(this + ".qtip-inactive", y) }); y() } clearTimeout(t.timers.show); clearTimeout(t.timers.hide); t.timers.show = setTimeout(function() { t.show(z) }, t.options.show.delay) } function w(z) { if (t.status.disabled === true) { return } if (t.options.hide.fixed === true && t.options.hide.when.event.search(/mouse(out|leave)/i) !== -1 && f(z.relatedTarget).parents("div.qtip[qtip]").length > 0) { z.stopPropagation(); z.preventDefault(); clearTimeout(t.timers.hide); return false } clearTimeout(t.timers.show); clearTimeout(t.timers.hide); t.elements.tooltip.stop(true, true); t.timers.hide = setTimeout(function() { t.hide(z) }, t.options.hide.delay) } if ((t.options.show.when.target.add(t.options.hide.when.target).length === 1 && t.options.show.when.event == t.options.hide.when.event && t.options.hide.when.event !== "inactive") || t.options.hide.when.event == "unfocus") { t.cache.toggle = 0; v.bind(t.options.show.when.event + ".qtip", function(z) { if (t.cache.toggle == 0) { x(z) } else { w(z) } }) } else { v.bind(t.options.show.when.event + ".qtip", x); if (t.options.hide.when.event !== "inactive") { u.bind(t.options.hide.when.event + ".qtip", w) } } if (t.options.position.type.search(/(fixed|absolute)/) !== -1) { t.elements.tooltip.bind("mouseover.qtip", t.focus) } if (t.options.position.target === "mouse" && t.options.position.type !== "static") { v.bind("mousemove.qtip", function(z) { t.cache.mouse = { x: z.pageX, y: z.pageY }; if (t.status.disabled === false && t.options.position.adjust.mouse === true && t.options.position.type !== "static" && t.elements.tooltip.css("display") !== "none") { t.updatePosition(z) } }) } } function o(u, v, A) { var z, s, x, y, t, w; z = this; if (A.corner == "center") { return v.position } s = f.extend({}, u); y = { x: false, y: false }; t = { left: (s.left < f.fn.qtip.cache.screen.scroll.left), right: (s.left + A.dimensions.width + 2 >= f.fn.qtip.cache.screen.width + f.fn.qtip.cache.screen.scroll.left), top: (s.top < f.fn.qtip.cache.screen.scroll.top), bottom: (s.top + A.dimensions.height + 2 >= f.fn.qtip.cache.screen.height + f.fn.qtip.cache.screen.scroll.top) }; x = { left: (t.left && (A.corner.search(/right/i) != -1 || (A.corner.search(/right/i) == -1 && !t.right))), right: (t.right && (A.corner.search(/left/i) != -1 || (A.corner.search(/left/i) == -1 && !t.left))), top: (t.top && A.corner.search(/top/i) == -1), bottom: (t.bottom && A.corner.search(/bottom/i) == -1) }; if (x.left) { if (z.options.position.target !== "mouse") { s.left = v.position.left + v.dimensions.width } else { s.left = z.cache.mouse.x } y.x = "Left" } else { if (x.right) { if (z.options.position.target !== "mouse") { s.left = v.position.left - A.dimensions.width } else { s.left = z.cache.mouse.x - A.dimensions.width } y.x = "Right" } } if (x.top) { if (z.options.position.target !== "mouse") { s.top = v.position.top + v.dimensions.height } else { s.top = z.cache.mouse.y } y.y = "top" } else { if (x.bottom) { if (z.options.position.target !== "mouse") { s.top = v.position.top - A.dimensions.height } else { s.top = z.cache.mouse.y - A.dimensions.height } y.y = "bottom" } } if (s.left < 0) { s.left = u.left; y.x = false } if (s.top < 0) { s.top = u.top; y.y = false } if (z.options.style.tip.corner !== false) { s.corner = new String(A.corner); if (y.x !== false) { s.corner = s.corner.replace(/Left|Right|Middle/, y.x) } if (y.y !== false) { s.corner = s.corner.replace(/top|bottom/, y.y) } if (s.corner !== z.elements.tip.attr("rel")) { e.call(z, s.corner) } } return s } function q(u, t) { var v, s; v = f.extend(true, {}, u); for (s in v) { if (t === true && s.search(/(tip|classes)/i) !== -1) { delete v[s] } else { if (!t && s.search(/(width|border|tip|title|classes|user)/i) !== -1) { delete v[s] } } } return v } function c(s) { if (typeof s.tip !== "object") { s.tip = { corner: s.tip} } if (typeof s.tip.size !== "object") { s.tip.size = { width: s.tip.size, height: s.tip.size} } if (typeof s.border !== "object") { s.border = { width: s.border} } if (typeof s.width !== "object") { s.width = { value: s.width} } if (typeof s.width.max == "string") { s.width.max = parseInt(s.width.max.replace(/([0-9]+)/i, "$1")) } if (typeof s.width.min == "string") { s.width.min = parseInt(s.width.min.replace(/([0-9]+)/i, "$1")) } if (typeof s.tip.size.x == "number") { s.tip.size.width = s.tip.size.x; delete s.tip.size.x } if (typeof s.tip.size.y == "number") { s.tip.size.height = s.tip.size.y; delete s.tip.size.y } return s } function a() { var s, t, u, x, v, w; s = this; u = [true, {}]; for (t = 0; t < arguments.length; t++) { u.push(arguments[t]) } x = [f.extend.apply(f, u)]; while (typeof x[0].name == "string") { x.unshift(c(f.fn.qtip.styles[x[0].name])) } x.unshift(true, { classes: { tooltip: "qtip-" + (arguments[0].name || "defaults")} }, f.fn.qtip.styles.defaults); v = f.extend.apply(f, x); w = (f.browser.msie) ? 1 : 0; v.tip.size.width += w; v.tip.size.height += w; if (v.tip.size.width % 2 > 0) { v.tip.size.width += 1 } if (v.tip.size.height % 2 > 0) { v.tip.size.height += 1 } if (v.tip.corner === true) { v.tip.corner = (s.options.position.corner.tooltip === "center") ? false : s.options.position.corner.tooltip } return v } function b(v, u, t) { var s = { bottomRight: [[0, 0], [u, t], [u, 0]], bottomLeft: [[0, 0], [u, 0], [0, t]], topRight: [[0, t], [u, 0], [u, t]], topLeft: [[0, 0], [0, t], [u, t]], topMiddle: [[0, t], [u / 2, 0], [u, t]], bottomMiddle: [[0, 0], [u, 0], [u / 2, t]], rightMiddle: [[0, 0], [u, t / 2], [0, t]], leftMiddle: [[u, 0], [u, t], [0, t / 2]] }; s.leftTop = s.bottomRight; s.rightTop = s.bottomLeft; s.leftBottom = s.topRight; s.rightBottom = s.topLeft; return s[v] } function g(s) { var t; if (f("<canvas>").get(0).getContext) { t = { topLeft: [s, s], topRight: [0, s], bottomLeft: [s, 0], bottomRight: [0, 0]} } else { if (f.browser.msie) { t = { topLeft: [-90, 90, 0], topRight: [-90, 90, -s], bottomLeft: [90, 270, 0], bottomRight: [90, 270, -s]} } } return t } function k() { var s, t, u; s = this; u = s.getDimensions(); t = '<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:false" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=\'0\'); border: 1px solid red; height:' + u.height + "px; width:" + u.width + 'px" />'; s.elements.bgiframe = s.elements.wrapper.prepend(t).children(".qtip-bgiframe:first") } f(document).ready(function() { f.fn.qtip.cache = { screen: { scroll: { left: f(window).scrollLeft(), top: f(window).scrollTop() }, width: f(window).width(), height: f(window).height()} }; var s; f(window).bind("resize scroll", function(t) { clearTimeout(s); s = setTimeout(function() { if (t.type === "scroll") { f.fn.qtip.cache.screen.scroll = { left: f(window).scrollLeft(), top: f(window).scrollTop()} } else { f.fn.qtip.cache.screen.width = f(window).width(); f.fn.qtip.cache.screen.height = f(window).height() } for (i = 0; i < f.fn.qtip.interfaces.length; i++) { var u = f.fn.qtip.interfaces[i]; if (u.status.rendered === true && (u.options.position.type !== "static" || u.options.position.adjust.scroll && t.type === "scroll" || u.options.position.adjust.resize && t.type === "resize")) { u.updatePosition(t, true) } } }, 100) }); f(document).bind("mousedown.qtip", function(t) { if (f(t.target).parents("div.qtip").length === 0) { f(".qtip[unfocus]").each(function() { var u = f(this).qtip("api"); if (f(this).is(":visible") && !u.status.disabled && f(t.target).add(u.elements.target).length > 1) { u.hide(t) } }) } }) }); f.fn.qtip.interfaces = []; f.fn.qtip.log = { error: function() { return this } }; f.fn.qtip.constants = {}; f.fn.qtip.defaults = { content: { prerender: false, text: false, url: false, data: null, title: { text: false, button: false} }, position: { target: false, corner: { target: "bottomRight", tooltip: "topLeft" }, adjust: { x: 0, y: 0, mouse: true, screen: false, scroll: true, resize: true }, type: "absolute", container: false }, show: { when: { target: false, event: "mouseover" }, effect: { type: "fade", length: 100 }, delay: 140, solo: false, ready: false }, hide: { when: { target: false, event: "mouseout" }, effect: { type: "fade", length: 100 }, delay: 0, fixed: false }, api: { beforeRender: function() { }, onRender: function() { }, beforePositionUpdate: function() { }, onPositionUpdate: function() { }, beforeShow: function() { }, onShow: function() { }, beforeHide: function() { }, onHide: function() { }, beforeContentUpdate: function() { }, onContentUpdate: function() { }, beforeContentLoad: function() { }, onContentLoad: function() { }, beforeTitleUpdate: function() { }, onTitleUpdate: function() { }, beforeDestroy: function() { }, onDestroy: function() { }, beforeFocus: function() { }, onFocus: function() { } } }; f.fn.qtip.styles = { defaults: { background: "white", color: "#111", overflow: "hidden", textAlign: "left", width: { min: 0, max: 250 }, padding: "5px 9px", border: { width: 1, radius: 0, color: "#d3d3d3" }, tip: { corner: false, color: false, size: { width: 13, height: 13 }, opacity: 1 }, title: { background: "#e1e1e1", fontWeight: "bold", padding: "7px 12px" }, button: { cursor: "pointer" }, classes: { target: "", tip: "qtip-tip", title: "qtip-title", button: "qtip-button", content: "qtip-content", active: "qtip-active"} }, cream: { border: { width: 3, radius: 0, color: "#F9E98E" }, title: { background: "#F0DE7D", color: "#A27D35" }, background: "#FBF7AA", color: "#A27D35", classes: { tooltip: "qtip-cream"} }, boliga: { border: { width: 1, radius: 1, color: "#ccc269" }, title: { background: "#fff494", color: "#000" }, background: "#fff494", color: "000", classes: { tooltip: "qtip-boliga" }, tip: { size: {x:4, y:6} } }, light: { border: { width: 3, radius: 0, color: "#E2E2E2" }, title: { background: "#f1f1f1", color: "#454545" }, background: "white", color: "#454545", classes: { tooltip: "qtip-light"} }, dark: { border: { width: 3, radius: 0, color: "#303030" }, title: { background: "#404040", color: "#f3f3f3" }, background: "#505050", color: "#f3f3f3", classes: { tooltip: "qtip-dark"} }, red: { border: { width: 3, radius: 0, color: "#CE6F6F" }, title: { background: "#f28279", color: "#9C2F2F" }, background: "#F79992", color: "#9C2F2F", classes: { tooltip: "qtip-red"} }, green: { border: { width: 3, radius: 0, color: "#A9DB66" }, title: { background: "#b9db8c", color: "#58792E" }, background: "#CDE6AC", color: "#58792E", classes: { tooltip: "qtip-green"} }, blue: { border: { width: 3, radius: 0, color: "#ADD9ED" }, title: { background: "#D0E9F5", color: "#5E99BD" }, background: "#E5F6FE", color: "#4D9FBF", classes: { tooltip: "qtip-blue"}}} })(jQuery);
 */


 /*
* qTip2 - Pretty pwoerful tooltips
* http://craigsworks.com/projects/qtip2/
*
* Version: 2.0.0pre
* Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com
*
* Dual licensed under MIT or GPLv2 licenses
*   http://en.wikipedia.org/wiki/MIT_License
*   http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Thu Dec 9 04:00:53 2010 +0000
*/

"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
/*global window: false, jQuery: false */

// Munge the primitives - Paul Irish tip
var TRUE = true,
	FALSE = false,
	NULL = null;

(function($, window, undefined) {

// Option object sanitizer
function sanitizeOptions(opts)
{
	var content;

	if(!opts) { return FALSE; }

	if('object' !== typeof opts.metadata) {
		opts.metadata = {
			type: opts.metadata
		};
	}

	if('content' in opts) {
		if('object' !== typeof opts.content || opts.content.jquery) {
			opts.content = {
				text: opts.content
			};
		}

		content = opts.content.text || FALSE;
		if(!$.isFunction(content) && ((!content && !content.attr) || content.length < 1 || ('object' === typeof content && !content.jquery))) {
			content = opts.content.text = FALSE;
		}

		if('title' in opts.content && 'object' !== typeof opts.content.title) {
			opts.content.title = {
				text: opts.content.title
			};
		}
	}

	if('position' in opts) {
		if('object' !== typeof opts.position) {
			opts.position = {
				my: opts.position,
				at: opts.position
			};
		}

		if('object' !== typeof opts.position.adjust) {
			opts.position.adjust = {};
		}

		if('undefined' !== typeof opts.position.adjust.screen) {
			opts.position.adjust.screen = !!opts.position.adjust.screen;
		}
	}

	if('show' in opts) {
		if('object' !== typeof opts.show) {
			opts.show = {
				event: opts.show
			};
		}

		if('object' !== typeof opts.show) {
			if(opts.show.jquery) {
				opts.show = { target: opts.show };
			}
			else {
				opts.show = { event: opts.show };
			}
		}
	}

	if('hide' in opts) {
		if('object' !== typeof opts.hide) {
			if(opts.hide.jquery) {
				opts.hide = { target: opts.hide };
			}
			else {
				opts.hide = { event: opts.hide };
			}
		}
	}

	if('style' in opts && 'object' !== typeof opts.style) {
		opts.style = {
			classes: opts.style
		};
	}

	// Sanitize plugin options
	$.each($.fn.qtip.plugins, function() {
		if(this.sanitize) { this.sanitize(opts); }
	});

	return opts;
}

/*
* Core plugin implementation
*/
function QTip(target, options, id)
{
	// Declare this reference
	var self = this,

	// Shortcut vars
	uitooltip = 'ui-tooltip',
	selector = '.qtip.'+uitooltip;

	// Setup class attributes
	self.id = id;
	self.rendered = FALSE;
	self.elements = { target: target };
	self.cache = { event: {}, target: NULL, disabled: FALSE };
	self.timers = { img: [] };
	self.options = options;
	self.plugins = {};

	/*
	* Private core functions
	*/
	function convertNotation(notation)
	{
		var i, obj,

		// Split notation into array
		actual = notation.split('.'),

		// Locate required option
		option = options[ actual[0] ];

		// Loop through
		for(i = 1; i < actual.length; i+=1) {
			obj = option[ actual[i] ];
			if(typeof obj === 'object' && !obj.jquery && !obj.precedance) {
				option = option[ actual[i] ];
			}
			else { break; }
		}

		return actual[i] !== undefined ? [option, actual[i] ] : [options, actual[0]];
	}

	function offset(jElem) {
		var elem = jElem[0],
			pos = { left: 0, top: 0 },
			absolute = !options.position.adjust.container;

		if(elem.offsetParent) {
			do {
				pos.left += elem.offsetLeft;
				pos.top += elem.offsetTop;
			}
			while(elem = absolute ? elem.offsetParent : 0);
		}

		return pos;
	}

	function calculate(detail, fluid)
	{
		var tooltip = self.elements.tooltip,
			accessible = uitooltip + '-accessible ' + (fluid ? uitooltip + '-accessible-fluid' : ''),
			show = !tooltip.is(':visible'),
			returned = FALSE;

		// Make sure tooltip is rendered and if not, return
		if(!self.rendered) { return FALSE; }

		// Show and hide tooltip to make sure properties are returned correctly
		if(show) { tooltip.addClass(accessible); }
		switch(detail)
		{
			case 'dimensions':
				// Find initial dimensions
				returned = {
					height: tooltip.outerHeight(),
					width: tooltip.outerWidth()
				};
			break;

			case 'position':
				returned = offset(tooltip);
			break;
		}
		if(show) { tooltip.removeClass(accessible); }

		return returned;
	}

	function removeTitle()
	{
		var elems = self.elements;

		if(elems.title) {
			elems.titlebar.remove();
			elems.titlebar = elems.title = elems.button = NULL;
			elems.tooltip.removeAttr('aria-labelledby');
		}
	}

	function createButton()
	{
		var elems = self.elements,
			button = options.content.title.button;

		if(elems.button) { elems.button.remove(); }

		// Use custom button if one was supplied by user, else use default
		if(button.jquery) {
			elems.button = button;
		}
		else if('string' === typeof button) {
			elems.button = $('<a />', { 'html': button });
		}
		else {
			elems.button = $('<a />', {
				'class': 'ui-state-default',
				'text': 'Close tooltip',
				'title': 'Close tooltip',
				'css': { 'text-indent': '-10000em' }
			})
			.prepend(
				$('<span />', { 'class': (options.style.widget ? 'ui' : uitooltip) + '-icon ui-icon-close' })
			);
		}

		// Create button and setup attributes
		elems.button
			.prependTo(elems.titlebar)
			.attr('role', 'button')
			.addClass(uitooltip + '-close')
			.hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); })
			.click(function() {
				if(!elems.tooltip.hasClass('ui-state-disabled')) { self.hide(); }
				return FALSE;
			})
			.bind('mousedown keydown mouseup keyup mouseout', function(event) {
				$(this).toggleClass('ui-state-active ui-state-focus', (/down$/i).test(event.type));
			});

		// Redraw the tooltip when we're done
		self.redraw();
	}

	function createTitle()
	{
		var elems = self.elements;

		// Destroy previous title element, if present
		if(elems.titlebar) { removeTitle(); }

		// Create title bar and title elements
		elems.titlebar = $('<div />', {
			'class': uitooltip + '-titlebar ' + (options.style.widget ? 'ui-widget-header' : '')
		})
		.append(
			elems.title = $('<div />', {
				'id': uitooltip + '-'+id+'-title',
				'class': uitooltip + '-title',
				'html': options.content.title.text
			})
		)
		.prependTo(elems.wrapper);

		// Create button if enabled
		if(options.content.title.button) { createButton(); }

		// Redraw the tooltip dimensions if it's rendered
		else if(self.rendered === TRUE){ self.redraw(); } 
	}

	function updateButton(button)
	{
		var elem = self.elements.button,
			title = self.elements.title;

		// Make sure tooltip is rendered and if not, return
		if(!self.rendered) { return FALSE; }

		if(!button) {
			elem.remove();
		}
		else {
			if(!title) {
				createTitle();
			}
			createButton();
		}
	}

	function updateTitle(content)
	{
		// Make sure tooltip is rendered and if not, return
		if(!self.rendered) { return FALSE; }

		// If title isn't already created, create it now
		if(!self.elements.title && content) {
			createTitle();
			self.reposition();
		}
		else if(!content) {
			removeTitle();
		}
		else {
			// Set the new content
			self.elements.title.html(content);
		}
	}

	function updateContent(content)
	{
		var elements = self.elements;

		// Make sure tooltip is rendered and content is defined. If not return
		if(!self.rendered || !content) { return FALSE; }

		// Use function to parse content
		if($.isFunction(content)) {
			content = content.call(target);
		}

		// Append new content if its a DOM array and show it if hidden
		if(content.jquery && content.length > 0) {
			elements.content.empty().append(content.css({ display: 'block' }));
		}

		// Content is a regular string, insert the new content
		else {
			elements.content.html(content);
		}

		// Insert into 'fx' queue our image dimension checker which will halt the showing of the tooltip until image dimensions can be detected
		elements.tooltip.queue('fx', function(next) {
			// Find all content images without dimensions
			var images = $('img:not([height]):not([width])', self.elements.content);

			// Update tooltip width and position when all images are loaded
			function imageLoad(img) {
				// Remove the image from the array
				images = images.not(img);

				// If queue is empty, update tooltip and continue the queue
				if(images.length === 0) {
					self.redraw();
					if(self.rendered === TRUE) {
						self.reposition(self.cache.event);
					}

					next();
				}
			}

			// Apply the callback to img events and height checker method to ensure queue continues no matter what!
			images.each(function(i, elem) {
				// Apply the imageLoad to regular events to make sure the queue continues
				var events = ['abort','error','load','unload',''].join('.qtip-image ');
				$(this).bind(events, function() {
					clearTimeout(self.timers.img[i]);
					imageLoad(this);
				});

				// Apply a recursive method that polls the image for dimensions every 20ms
				(function timer(){
					// When the dimensions are found, remove the image from the queue
					if(elem.height) {
						return imageLoad(elem);
					}

					self.timers.img[i] = setTimeout(timer, 20);
				}());

				return TRUE;
			});

			// If no images were found, continue with queue
			if(images.length === 0) { imageLoad(images);  }
		});

		return self;
	}

	function assignEvents(show, hide, tooltip, doc)
	{
		var namespace = '.qtip-'+id,
			targets = {
				show: options.show.target,
				hide: options.hide.target,
				tooltip: self.elements.tooltip
			},
			events = { show: String(options.show.event).split(' '), hide: String(options.hide.event).split(' ') },
			IE6 = $.browser.msie && (/^6\.[0-9]/).test($.browser.version);

		// Define show event method
		function showMethod(event)
		{
			if(targets.tooltip.hasClass('ui-state-disabled')) { return FALSE; }

			// If set, hide tooltip when inactive for delay period
			targets.show.trigger('qtip-'+id+'-inactive');

			// Clear hide timers
			clearTimeout(self.timers.show);
			clearTimeout(self.timers.hide);

			// Start show timer
			var callback = function(){ self.show(event); };
			if(options.show.delay > 0) {
				self.timers.show = setTimeout(callback, options.show.delay);
			}
			else{ callback(); }
		}

		// Define hide method
		function hideMethod(event)
		{
			if(targets.tooltip.hasClass('ui-state-disabled')) { return FALSE; }

			// Check if new target was actually the tooltip element
			var ontoTooltip = $(event.relatedTarget || event.target).parents(selector)[0] == targets.tooltip[0];

			// Clear timers and stop animation queue
			clearTimeout(self.timers.show);
			clearTimeout(self.timers.hide);

			// Prevent hiding if tooltip is fixed and event target is the tooltip. Or if mouse positioning is enabled and cursor momentarily overlaps
			if(options.hide.fixed && ((options.position.target === 'mouse' && ontoTooltip) || ((/mouse(out|leave|move)/).test(event.type) && ontoTooltip)))
			{
				// Prevent default and popagation
				event.stopPropagation();
				event.preventDefault();
				return FALSE;
			}

			// If tooltip has displayed, start hide timer
			targets.tooltip.stop(1, 1);

			if(options.hide.delay > 0) {
				self.timers.hide = setTimeout(function(){ self.hide(event); }, options.hide.delay);
			}
			else{ self.hide(event); }
		}

		// Define inactive method
		function inactiveMethod(event)
		{
			if(targets.tooltip.hasClass('ui-state-disabled')) { return FALSE; }

			// Clear timer
			clearTimeout(self.timers.inactive);
			self.timers.inactive = setTimeout(function(){ self.hide(event); }, options.hide.inactive);
		}

		function repositionMethod(event) {
			// Only update position if tooltip is visible
			if(self.elements.tooltip.is(':visible')) { self.reposition(event); }
		}

		// Catch remove events on target element to destroy tooltip
		target.bind('remove.qtip', function(){ self.destroy(); });

		// Check if the tooltip is 'fixed'
		if(tooltip && options.hide.fixed)
		{
			// Add tooltip as a hide target
			targets.hide = targets.hide.add(targets.tooltip);

			// Clear hide timer on tooltip hover to prevent it from closing
			targets.tooltip.bind('mouseover'+namespace, function() {
				if(!targets.tooltip.hasClass('ui-state-disabled')) {
					clearTimeout(self.timers.hide);
				}
			});
		}

		// Assign hide events
		if(hide) {
			// Check if the tooltip hides when inactive
			if('number' === typeof options.hide.inactive)
			{
				// Bind inactive method to target as a custom event
				targets.show.bind('qtip-'+id+'-inactive', inactiveMethod);

				// Define events which reset the 'inactive' event handler
				$.each($.fn.qtip.inactiveEvents, function(index, type){
					targets.hide.add(self.elements.tooltip).bind(type+namespace+'-inactive', inactiveMethod);
				});
			}

			// Apply hide events
			$.each(events.hide, function(index, type) {
				var showIndex = $.inArray(type, events.show);

				// Both events and targets are identical, apply events using a toggle
				if((showIndex > -1 && $(targets.hide).add(targets.show).length === $(targets.hide).length) || type === 'unfocus')
				{
					targets.show.bind(type+namespace, function(event)
					{
						if(targets.tooltip.is(':visible')) { hideMethod(event); }
						else{ showMethod(event); }
					});

					// Don't bind the event again
					delete events.show[ showIndex ];
				}

				// Events are not identical, bind normally
				else{ targets.hide.bind(type+namespace, hideMethod); }
			});
		}

		// Apply show events
		if(show) {
			$.each(events.show, function(index, type) {
				targets.show.bind(type+namespace, showMethod);
			});

			// Focus the tooltip on mouseover
			targets.tooltip.bind('mouseover'+namespace, function(){ self.focus(); });
		}

		// Apply document events
		if(doc) {
			// Adjust positions of the tooltip on window resize if enabled
			if(options.position.adjust.resize || options.position.adjust.screen) {
				$(window).bind('resize'+namespace, repositionMethod);
			}

			// Adjust tooltip position on scroll if screen adjustment is enabled
			if(options.position.adjust.screen || (IE6 && targets.tooltip.css('position') === 'fixed')) {
				$(document).bind('scroll'+namespace, repositionMethod);
			}

			// Hide tooltip on document mousedown if unfocus events are enabled
			if((/unfocus/i).test(options.hide.event)) {
				$(document).bind('mousedown'+namespace, function(event) {
					var tooltip = self.elements.tooltip;

					if($(event.target).parents(selector).length === 0 && $(event.target).add(target).length > 1 &&
					tooltip.is(':visible') && !tooltip.hasClass('ui-state-disabled')) {
						self.hide();
					}
				});
			}

			// If mouse is the target, update tooltip position on document mousemove			
			if(options.position.target === 'mouse') {
				$(document).bind('mousemove'+namespace, function(event) {					
					// Update the tooltip position only if the tooltip is visible and adjustment is enabled
					if(options.position.adjust.mouse && !targets.tooltip.hasClass('ui-state-disabled') && targets.tooltip.is(':visible')) {
						self.reposition(event || $.fn.qtip.mouse);
					}
				});
			}
		}
	}

	function unassignEvents(show, hide, tooltip, doc)
	{
		doc = parseInt(doc, 10) !== 0;
		var namespace = '.qtip-'+id,
			targets = {
				show: show ? options.show.target : $('<div/>'),
				hide: hide ? options.hide.target : $('<div/>'),
				tooltip: tooltip ? self.elements.tooltip : $('<div/>')
			},
			events = { show: String(options.show.event).split(' '), hide: String(options.hide.event).split(' ') };

		// Check if tooltip is rendered
		if(self.rendered)
		{
			// Remove show events
			$.each(events.show, function(index, type){ targets.show.unbind(type+namespace); });
			targets.show.unbind('mousemove'+namespace)
				.unbind('mouseout'+namespace)
				.unbind('qtip-'+id+'-inactive');

			// Remove hide events
			$.each(events.hide, function(index, type) {
				targets.hide.add(targets.tooltip).unbind(type+namespace);
			});
			$.each($.fn.qtip.inactiveEvents, function(index, type){
				targets.hide.add(tooltip ? self.elements.content : NULL).unbind(type+namespace+'-inactive');
			});
			targets.hide.unbind('mouseout'+namespace);

			// Remove tooltip events
			targets.tooltip.unbind('mouseover'+namespace);

			// Remove document events
			if(doc) {
				$(window).unbind('resize'+namespace);
				$(document).unbind('mousedown'+namespace+' mousemove'+namespace);
			}
		}

		// Tooltip isn't yet rendered, remove render event
		else if(show) { targets.show.unbind(events.show+namespace+'-create'); }
	}

	/*
	* Public API methods
	*/
	$.extend(self, {
		render: function(show)
		{
			var elements = self.elements, callback = $.Event('tooltiprender');

			// If tooltip has already been rendered, exit
			if(self.rendered) { return FALSE; }

			// Call API method and set rendered status
			self.rendered = show ? -2 : -1; // -1: rendering	 -2: rendering and show when done

			// Create initial tooltip elements
			elements.tooltip = $('<div/>')
				.attr({
					'id': uitooltip + '-'+id,
					'role': 'tooltip',
					'class': uitooltip + ' qtip ui-tooltip-accessible ui-helper-reset ' + options.style.classes
				})
				.css('z-index', $.fn.qtip.zindex + $(selector).length)
				.toggleClass('ui-widget', options.style.widget)
				.toggleClass('ui-state-disabled', self.cache.disabled)
				.data('qtip', self)
				.appendTo(options.position.container);

			// Append to container element
			elements.wrapper = $('<div />', { 'class': uitooltip + '-wrapper' }).appendTo(elements.tooltip);
			elements.content = $('<div />', {
					'class': uitooltip + '-content ' + (options.style.widget ? 'ui-widget-content' : ''),
					'id': uitooltip + '-' + id + '-content'
				})
				.appendTo(elements.wrapper);

			// Setup content and title (if enabled)
			if(options.content.title.text) {
				createTitle();
			}
			updateContent(options.content.text);

			// Initialize 'render' plugins
			$.each($.fn.qtip.plugins, function() {
				if(this.initialize === 'render') { this(self); }
			});

			// Set rendered status to TRUE
			self.rendered = TRUE;

			// Assign events
			assignEvents(1, 1, 1, 1);
			$.each(options.events, function(name, callback) {
				if(callback) { elements.tooltip.bind('tooltip'+name, callback); }
			});

			/* Queue this part of the render process in our fx queue so we can
			 * load images before the tooltip renders fully.
			 *
			 * See: updateContent method
			*/
			elements.tooltip.queue('fx', function(next) {
				// Update tooltip position and show tooltip if needed
				if(options.show.ready || show) {
					elements.tooltip.hide();
					self.show(self.cache.event);
				}

				// Remove accessible class
				elements.tooltip.removeClass('ui-tooltip-accessible');

				// Trigger tooltiprender event and pass original triggering event as original
				callback.originalEvent = self.cache.event;
				elements.tooltip.trigger(callback, [self.hash()]);

				next(); // Move on
			});

			return self;
		},

		get: function(notation)
		{
			var result, o;

			switch(notation.toLowerCase())
			{
				case 'offset':
					result = calculate('position');
				break;

				case 'dimensions':
					result = calculate('dimensions');
				break;

				default:
					o = convertNotation(notation.toLowerCase());
					result = (o[0].precedance) ? o[0].string() : (o[0].jquery) ? o[0] : o[0][ o[1] ];
				break;
			}

			return result;
		},

		set: function(notation, value)
		{
			notation = notation.toLowerCase();
			var option = convertNotation(notation),
				elems = self.elements,
				tooltip = elems.tooltip,
				previous,
				category, rule,
				checks = {
					builtin: {
						// Core checks
						'id': function(obj, opt, val, prev) {
							var id = value === TRUE ? $.fn.qtip.nextid : value,
								idStr = uitooltip + '-' + id;

							if(id !== FALSE && id.length > 0 && !$('#ui-tooltip-'+id).length) {
								tooltip[0].id = idStr;
								elems.content[0].id = idStr + '-content';
								elems.title[0].id = idStr + '-title';
							}
						},

						// Content checks
						'^content.text': function(){ updateContent(value); },
						'^content.title.text': function(){ updateTitle(value); },
						'^content.title.button': function(){ updateButton(value); },

						// Position checks
						'^position.(my|at)$': function(){
							// Parse new corner value into Corner objecct
							var corner = (/my$/i).test(notation) ? 'my' : 'at';

							if('string' === typeof value) {
								options.position[corner] = new $.fn.qtip.plugins.Corner(value);
							}
						},
						'^position.(my|at|adjust|target)': function(){ if(self.rendered) { self.reposition(); } },
						'^position.container$': function(){
							if(self.rendered === TRUE) { 
								tooltip.appendTo(value); 
								self.reposition();
							}
						},

						// Show & hide checks
						'^(show|hide).(event|target|fixed|delay|inactive)': function(obj, opt, val, prev) {
							var args = notation.search(/fixed/i) > -1 ? [0, [0,1,1,1]] : [notation.substr(0,3), notation.charAt(0) === 's' ? [1,0,0,0] : [0,1,0,0]];

							if(args[0]) { obj[opt] = prev; }
							unassignEvents.apply(self, args[1]);

							if(args[0]) { obj[opt] = val; }
							assignEvents.apply(self, args[1]);
						},
						'^show.ready$': function() { if(self.rendered === FALSE) { self.show(); } },

						// Style checks
						'^style.classes$': function() { self.elements.tooltip.attr('class', uitooltip + ' qtip ui-helper-reset ' + value); },
						'^style.widget$': function() {
							var trigger = !!value;
							
							tooltip.toggleClass('ui-widget', trigger);
							elems.titlebar.toggleClass('ui-widget-header', trigger);
							elems.content.toggleClass('ui-widget-content', trigger);
							elems.button.children('span').toggleClass(uitooltip+'-icon', !trigger).toggleClass('ui-icon', trigger);
						},

						// Events check
						'^events.(render|show|move|hide|focus|blur)': function(obj, opt, val, prev) {
							elems.tooltip[($.isFunction(value) ? '' : 'un') + 'bind']('tooltip'+opt, val);
						}
					}
				};

			// Merge active plugin checks
			$.each(self.plugins, function(name) {
				if('object' === typeof this.checks) {
					checks[name] = this.checks;
				}
			});

			// Set new option value
			previous = option[0][ option[1] ];
			option[0][ option[1] ] = value.nodeType ? $(value) : value;

			// Re-sanitize options
			sanitizeOptions(options);

			// Execute any valid callbacks
			for(category in checks) {
				for(rule in checks[category]) {
					if((new RegExp(rule, 'i')).test(notation)) {
						checks[category][rule].call(self, option[0], option[1], value, previous);
					}
				}
			}

			return self;
		},

		toggle: function(state, event)
		{
			if(self.rendered === FALSE) { return FALSE; }

			var type = state ? 'show' : 'hide',
				tooltip = self.elements.tooltip,
				opts = options[type],
				visible = tooltip.is(':visible'),
				callback, ieStyle;

			// Detect state if valid one isn't provided
			if((typeof state).search('boolean|number')) { state = !tooltip.is(':visible'); }

			// Define after callback
			function after()
			{
				var elem = $(this),
					attr = state ? 'attr' : 'removeAttr',
					opacity = (/^1|0$/).test(elem.css('opacity'));

				// Apply ARIA attributes when tooltip is shown
				if(self.elements.title){ target[attr]('aria-labelledby', uitooltip + '-'+id+'-title'); }
				target[attr]('aria-describedby', uitooltip + '-'+id+'-content');

				// Prevent antialias from disappearing in IE7 by removing filter and opacity attribute
				if(state) {
					if($.browser.msie && this.style && opacity) { 
						ieStyle = this.style;
						ieStyle.removeAttribute('filter');
						ieStyle.removeAttribute('opacity');
					}
				}
				else if(opacity) {
					elem.hide();
				}
			}

			// Return if element is already in correct state
			if((!visible && !state) || tooltip.is(':animated')) { return self; }

			// Try to prevent flickering when tooltip overlaps show element
			if(event) {
				if(self.cache.event && (/over|enter/).test(event.type) && (/out|leave/).test(self.cache.event.type) &&
					$(event.target).add(options.show.target).length < 2 && $(event.relatedTarget).parents(selector).length > 0){
					return self;
				}

				// Cache event
				self.cache.event = $.extend({}, event);
			}

			// Call API methods
			callback = $.Event('tooltip'+type); 
			callback.originalEvent = event ? self.cache.event : NULL;
			tooltip.trigger(callback, [self.hash(), 90]);
			if(callback.isDefaultPrevented()){ return self; }

			// Execute state specific properties
			if(state) {
				self.focus(); // Focus the tooltip before show to prevent visual stacking
				self.reposition(event); // Update tooltip position

				// Hide other tooltips if tooltip is solo
				if(opts.solo) { $(selector).qtip('hide'); }
			}
			else {
				// Clear show timer
				clearTimeout(self.timers.show);
			}

			// Set ARIA hidden status attribute
			tooltip.attr('aria-hidden', Boolean(!state));

			// Clear animation queue
			tooltip.stop(1, 1);

			// Use custom function if provided
			if($.isFunction(opts.effect)) {
				opts.effect.call(tooltip, self.hash());
				tooltip.queue(function(){ after.call(this); $(this).dequeue(); });
			}

			// If no effect type is supplied, use a simple toggle
			else if(opts.effect === FALSE) {
				tooltip[ type ]();
				after.call(tooltip);
			}

			// Use basic fade function
			else {
				tooltip.fadeTo(90, state ? 1 : 0, after);
			}

			// If inactive hide method is set, active it
			if(state) { opts.target.trigger('qtip-'+id+'-inactive'); }

			return self;
		},

		show: function(event){ self.toggle(TRUE, event); },

		hide: function(event){ self.toggle(FALSE, event); },

		focus: function(event)
		{
			if(self.rendered === FALSE) { return FALSE; }

			var tooltip = self.elements.tooltip,
				qtips = $(selector),
				curIndex = parseInt(tooltip[0].style.zIndex, 10),
				newIndex = $.fn.qtip.zindex + qtips.length,
				focusClass = uitooltip + '-focus',
				cachedEvent = $.extend({}, event),
				callback;

			// Only update the z-index if it has changed and tooltip is not already focused
			if(!tooltip.hasClass(focusClass) && curIndex !== newIndex)
			{
				// Reduce our z-index's and keep them properly ordered
				qtips.each(function() {
					this.style.zIndex = this.style.zIndex - 1;
				});

				// Fire blur event for focussed tooltip
				$(selector + '.' + focusClass).each(function() {
					var self = $(this), api = self.qtip(), blur;

					if(!api || api.rendered === FALSE) { return TRUE; }

					// Set focused status to FALSE
					self.removeClass(focusClass);

					// Trigger blur event
					blur = $.Event('tooltipblur');
					blur.originalEvent = cachedEvent;
					self.trigger(blur, [api, newIndex]);
				});

				// Call API method
				callback = $.Event('tooltipfocus'); 
				callback.originalEvent = cachedEvent;
				tooltip.trigger(callback, [self.hash(), newIndex]);

				// Set the new z-index and set focus status to TRUE if callback wasn't FALSE
				if(!callback.isDefaultPrevented()) {
					tooltip.addClass(focusClass)[0].style.zIndex = newIndex;
				}
			}

			return self;
		},

		reposition: function(event)
		{
			if(self.rendered === FALSE) { return FALSE; }

			var target = options.position.target,
				tooltip = self.elements.tooltip,
				posOptions = options.position,
				my = posOptions.my, 
				at = posOptions.at,
				adjust = posOptions.adjust,
				elemWidth = self.elements.tooltip.width(),
				elemHeight = self.elements.tooltip.height(),
				offsetParent = $(posOptions.container)[0],
				targetWidth = 0,
				targetHeight = 0,
				callback = $.Event('tooltipmove'),
				fixed = tooltip.css('position') === 'fixed',
				viewport = $(adjust.container && offsetParent !== document.body ? offsetParent : window),
				position = { left: 0, top: 0 },
				readjust = {
					left: function(posLeft) {
						var viewportScroll = viewport.scrollLeft,
							myWidth = my.x === 'left' ? elemWidth : my.x === 'right' ? -elemWidth : -elemWidth / 2,
							atWidth = at.x === 'left' ? targetWidth : at.x === 'right' ? -targetWidth : -targetWidth / 2,
							adjustX = (my.x === my.y ? 1 : -2) * adjust.x,
							overflowLeft = viewportScroll - posLeft,
							overflowRight = posLeft + elemWidth - viewport.width - viewportScroll,
							offset = myWidth - adjustX - (my.precedance === 'x' || my.x === my.y ? atWidth : 0);

						if(overflowLeft > 0) {
							position.left -= offset;
						}
						else if(overflowRight > 0) {
							position.left -= (my.x === 'center' ? -1 : 1) * offset;
						}

						return position.left - posLeft;
					},
					top: function(posTop) {
						var viewportScroll = viewport.scrollTop,
							myHeight = my.y === 'top' ? elemHeight : my.y === 'bottom' ? -elemHeight : -elemHeight / 2,
							atHeight = at.y === 'top' ? targetHeight : at.y === 'bottom' ? -targetHeight : -targetHeight / 2,
							adjustY = (my.y === my.x ? 1 : -2) * adjust.y,
							overflowTop = viewportScroll - posTop,
							overflowBottom = posTop + elemHeight - viewport.height - viewportScroll,
							offset = myHeight - adjustY - (my.precedance === 'y' || my.x === my.y ? atHeight : 0);

						if(overflowTop > 0) {
							position.top -= offset;
						}
						else if(overflowBottom > 0) {
							position.top -= (my.y === 'center' ? -1 : 1) * offset;
						}

						return position.top - posTop;
					}
				};

			// Cache our viewport details
			viewport = {
				elem: viewport,
				height: viewport[ (viewport[0] === window ? 'h' : 'outerH') + 'eight' ](),
				width: viewport[ (viewport[0] === window ? 'w' : 'outerW') + 'idth' ](),
				scrollLeft: viewport.scrollLeft(),
				scrollTop: viewport.scrollTop()
			};

			
			
			
			// Check if mouse was the target
			if(target === 'mouse') {
				// Force left top to allow flipping
				at = { x: 'left', y: 'top' };

				// Use cached event if one isn't available for positioning
				event = adjust.mouse || !event || !event.pageX ? $.extend({}, $.fn.qtip.mouse) : event;
				position = { top: event.pageY, left: event.pageX };
			}
			else {
				// Check if event targetting is being used
				if(target === 'event') {
					if(event && event.target && event.type !== 'scroll' && event.type !== 'resize') {
						target = self.cache.target = $(event.target);
					}
					else {
						target = self.cache.target;
					}
				}

				// Parse the target into a jQuery object and make sure there's an element present
				target = $(target).eq(0);
				if(target.length === 0) { return self; }

				// Check if window or document is the target
				else if(target[0] === document || target[0] === window) {
					targetWidth = target.width();
					targetHeight = target.height();

					if(target[0] === window) {
						position = {
							top: fixed ? 0 : viewport.scrollTop,
							left: fixed ? 0 : viewport.scrollLeft
						};
					}
				}

				// Use Imagemap plugin if target is an AREA element
				else if(target.is('area') && $.fn.qtip.plugins.imagemap) {
					position = $.fn.qtip.plugins.imagemap(target, at);
					targetWidth = position.width;
					targetHeight = position.height;
					position = position.offset;
				}

				else {
					targetWidth = target.outerWidth();
					targetHeight = target.outerHeight();

					position = offset(target);
				}

				// Adjust position relative to target
				position.left += at.x === 'right' ? targetWidth : at.x === 'center' ? targetWidth / 2 : 0;
				position.top += at.y === 'bottom' ? targetHeight : at.y === 'center' ? targetHeight / 2 : 0;
			}

			// Adjust position relative to tooltip
			position.left += adjust.x + (my.x === 'right' ? -elemWidth : my.x === 'center' ? -elemWidth / 2 : 0);
			position.top += adjust.y + (my.y === 'bottom' ? -elemHeight : my.y === 'center' ? -elemHeight / 2 : 0);

			// Calculate collision offset values
			if(adjust.screen && target[0] !== window && target[0] !== document.body) {
				position.adjusted = { left: readjust.left(position.left), top: readjust.top(position.top) };
			}
			else {
				position.adjusted = { left: 0, top: 0 };
			}

			// Set tooltip position class
			tooltip.attr('class', function(i, val) {
				return $(this).attr('class').replace(/ui-tooltip-pos-\w+/i, '');
			})
			.addClass(uitooltip + '-pos-' + my.abbreviation());

			// Call API method
			callback.originalEvent = $.extend({}, event);
			tooltip.trigger(callback, [self.hash(), position, viewport.elem]);
			if(callback.isDefaultPrevented()){ return self; }
			delete position.adjusted;

			// Use custom function if provided
			if(tooltip.is(':visible') && $.isFunction(posOptions.effect)) {
				posOptions.effect.call(tooltip, self.hash(), position);
				tooltip.queue(function() {
					var elem = $(this);
					// Reset attributes to avoid cross-browser rendering bugs
					elem.css({ opacity: '', height: '' });
					if($.browser.msie && this.style) { this.style.removeAttribute('filter'); }
					elem.dequeue();
				});
			}
			else if(!isNaN(position.left, position.top)) {
				tooltip.css(position);
			}

			return self;
		},

		// IE max/min height/width simulartor function
		redraw: function()
		{
			// Make sure tooltip is rendered and the browser needs the redraw
			if(!self.rendered || !($.browser.msie && parseInt($.browser.version.charAt(0), 10) < 9)) { return FALSE; }

			var tooltip = self.elements.tooltip, 
				style = tooltip.attr('style'),
				dimensions;

			// Determine actual dimensions using our calculate function
			tooltip.css({ width: 'auto', height: 'auto' });
			dimensions = calculate('dimensions', 1);

			// Determine actual width
			$.each(['width', 'height'], function(i, prop) {
				// Parse our max/min properties
				var max = parseInt(tooltip.css('max-'+prop), 10) || 0,
					min = parseInt(tooltip.css('min-'+prop), 10) || 0;

				// Determine new dimension size based on max/min/current values
				dimensions[prop] = max + min ? Math.min( Math.max( dimensions[prop], min ), max ) : dimensions[prop];
			});

			// Set the newly calculated dimensions
			tooltip.css(dimensions);
		},

		disable: function(state)
		{
			var tooltip = self.elements.tooltip;

			if(self.rendered) {
				tooltip.toggleClass('ui-state-disabled', state);
			}
			else {
				self.cache.disabled = !!state;
			}

			return self;
		},

		destroy: function()
		{
			var elements = self.elements,
				oldtitle = elements.target.data('oldtitle');

			// Destroy any associated plugins when rendered
			if(self.rendered) {
				$.each(self.plugins, function() {
					if(this.initialize === 'render') { this.destroy(); }
				});
			}

			// Remove bound events
			unassignEvents(1, 1, 1, 1);

			// Remove api object and tooltip
			target.removeData('qtip');
			if(self.rendered) { elements.tooltip.remove(); }

			// Reset old title attribute if removed and reset describedby attribute
			if(oldtitle) {
				target.attr('title', oldtitle);
			}
			target.removeAttr('aria-describedby');

			return target;
		},

		hash: function()
		{
			var apiHash = $.extend({}, self);
			delete apiHash.cache;
			delete apiHash.timers;
			delete apiHash.options;
			delete apiHash.plugins;
			delete apiHash.render;
			delete apiHash.hash;

			return apiHash;
		}
	});
}

// Initialization method
function init(id, opts)
{
	var obj, posOptions,

	// Setup element references
	elem = $(this),
	docBody = $(document.body),

	// Use document body instead of document element if needed
	newTarget = this === document ? docBody : elem,

	// Grab metadata from element if plugin is present
	metadata = (elem.metadata) ? elem.metadata(opts.metadata) : NULL,

	// Check if the metadata returned is in HTML5 form and grab 'name' from the object instead
	metadata5 = metadata && opts.metadata.type === 'html5' ? metadata[opts.metadata.name] : NULL,

	// Merge in our sanitized metadata and remove metadata object so we don't interfere with other metadata calls
	config = $.extend(TRUE, {}, $.fn.qtip.defaults, opts, sanitizeOptions(metadata5 || metadata));
	elem.removeData('metadata');

	// Re-grab our positioning options now we've merged our metadata
	posOptions = config.position;

	// Setup missing content if none is detected
	if('boolean' === typeof config.content.text) {

		// Grab from supplied attribute if available
		if(config.content.attr !== FALSE && elem.attr(config.content.attr)) {
			config.content.text = elem.attr(config.content.attr);
		}

		// No valid content was found, abort render
		else {
			return FALSE;
		}
	}

	// Setup target options
	if(posOptions.container === FALSE) { posOptions.container = docBody; }
	if(posOptions.target === FALSE) { posOptions.target = newTarget; }
	if(config.show.target === FALSE) { config.show.target = newTarget; }
	if(config.hide.target === FALSE) { config.hide.target = newTarget; }

	// Convert position corner values into x and y strings
	posOptions.at = new $.fn.qtip.plugins.Corner(posOptions.at);
	posOptions.my = new $.fn.qtip.plugins.Corner(posOptions.my);

	// Destroy previous tooltip if overwrite is enabled, or skip element if not
	if(elem.data('qtip')) {
		if(config.overwrite) {
			elem.qtip('destroy');
		}
		else if(config.overwrite === FALSE) {
			return FALSE;
		}
	}

	// Remove title attribute and store it if present
	if(elem.attr('title')) {
		elem.data('oldtitle', elem.attr('title')).removeAttr('title');
	}

	// Initialize the tooltip and add API reference
	obj = new QTip(elem, config, id);
	elem.data('qtip', obj);

	return obj;
}

// jQuery $.fn extension method
$.fn.qtip = function(options, notation, newValue)
{
	var command = String(options).toLowerCase(), // Parse command
		returned = NULL,
		args = command === 'disable' ? [TRUE] : $.makeArray(arguments).slice(1, 10),
		event = args[args.length - 1],
		opts;

	// Check for API request
	if((!arguments.length && this.data('qtip')) || command === 'api') {
		opts = this.data('qtip');
		return opts ? opts.hash() : undefined;
	}

	// Execute API command if present
	else if('string' === typeof options)
	{
		this.each(function()
		{
			var api = $(this).data('qtip');
			if(!api) { return TRUE; }

			// Call APIcommand
			if((/option|set/).test(command) && notation) {
				if(newValue !== undefined) {
					api.set(notation, newValue);
				}
				else {
					returned = api.get(notation);
				}
			}
			else {
				// Render tooltip if not already rendered when tooltip is to be shown
				if(!api.rendered && (command === 'show' || command === 'toggle')) {
					if(event && event.timeStamp) { api.cache.event = event; }
					api.render(1);
				}

				// Check for disable/enable commands
				else if(command === 'enable') {
					command = 'disable'; args = [FALSE];
				}

				// Execute API command
				if(api[command]) {
					api[command].apply(api[command], args);
				}
			}
		});

		return returned !== NULL ? returned : this;
	}

	// No API commands. validate provided options and setup qTips
	else if('object' === typeof options || !arguments.length)
	{
		opts = sanitizeOptions($.extend(TRUE, {}, options));

		// Bind the qTips
		return $.fn.qtip.bind.call(this, opts, event);
	}
};

// $.fn.qtip Bind method
$.fn.qtip.bind = function(opts, event)
{
	return this.each(function(i) {
		var options, targets, events,
			
		// Find next available ID, or use custom ID if provided
		id = opts.id = (!opts.id || opts.id === FALSE || opts.id.length < 1 || $('#ui-tooltip-'+opts.id).length) ? $.fn.qtip.nextid++ : opts.id,
		
		// Setup events namespace
		namespace = '.qtip-'+id+'-create',

		// Initialize the qTip and re-grab newly sanitized options
		self = init.call(this, id, opts);
		if(self === FALSE) { return TRUE; }
		options = self.options;

		// Initialize plugins
		$.each($.fn.qtip.plugins, function() {
			if(this.initialize === 'initialize') { this(self); }
		});

		// Determine hide and show targets
		targets = { show: options.show.target, hide: options.hide.target };
		events = {
			show: String(options.show.event).replace(' ', namespace+' ') + namespace,
			hide: String(options.hide.event).replace(' ', namespace+' ') + namespace
		};

		// Define hoverIntent function
		function hoverIntent(event) {
			function render() {
				// Cache mouse coords,render and render the tooltip
				self.render(typeof event === 'object' || options.show.ready);

				// Unbind show and hide event
				targets.show.unbind(events.show);
				targets.hide.unbind(events.hide);
			}

			// Only continue if tooltip isn't disabled
			if(self.cache.disabled) { return FALSE; }

			// Cache the event data
			self.cache.event = $.extend({}, event);

			// Start the event sequence
			if(options.show.delay > 0) {
				clearTimeout(self.timers.show);
				self.timers.show = setTimeout(render, options.show.delay);
				if(events.show !== events.hide) {
					targets.hide.bind(events.hide, function() { clearTimeout(self.timers.show); });
				}
			}
			else { render(); }
		}

		// Bind show events to target
		targets.show.bind(events.show, hoverIntent);

		// Prerendering is enabled, create tooltip now
		if(options.show.ready || options.prerender) { hoverIntent(event); }
	});
};

// Override some of the core jQuery methods for library-specific purposes
$.each({
	/* Allow other plugins to successfully retrieve the title of an element with a qTip applied */
	attr: function(attr) {
		var self = $(this), api = self.data('qtip');
		return (arguments.length === 1 && attr === 'title' && api && api.rendered === TRUE) ? self.data('oldtitle') : NULL;
	},

	/* 
	* Taken directly from jQuery 1.8.2 widget source code
	* Trigger 'remove' event on all elements on removal if jQuery UI isn't present 
	*/
	remove: $.ui ? NULL : function( selector, keepData ) {
		$(this).each(function() {
			if (!keepData) {
				if (!selector || $.filter( selector, [ this ] ).length) {
					$('*', this).add(this).each(function() {
						$(this).triggerHandler('remove');
					});
				}
			}
		});
	}
},
function(name, func) {
	if(!func) { return TRUE; }
	$.fn['Old'+name] = $.fn[name];
	$.fn[name] = function() {
		return func.apply(this, arguments) || $.fn['Old'+name].apply(this, arguments);
	};
});

/* 
* Add ARIA role attribute to document body if not already present
* http://wiki.jqueryui.com/Tooltip - 4.3 Accessibility recommendation
*/
$(document.body).attr('role', function(i, val) { return !val ? 'application' : val; });

// Cache mousemove events for positioning purposes
$(document).bind('mousemove.qtip', function(event) {
	$.fn.qtip.mouse = { pageX: event.pageX, pageY: event.pageY };
});

// Set global qTip properties
$.fn.qtip.version = '2.0.0pre';
$.fn.qtip.nextid = 0;
$.fn.qtip.inactiveEvents = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' ');
$.fn.qtip.zindex = 15000;

// Setup base plugins
$.fn.qtip.plugins = {
	// Corner object parser
	Corner: function(corner) {
		corner = String(corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, 'center').toLowerCase();
		this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase();
		this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase();

		this.precedance = (corner.charAt(0).search(/^(t|b)/) > -1) ? 'y' : 'x';
		this.string = function() { return this.precedance === 'y' ? this.y+this.x : this.x+this.y; };
		this.abbreviation = function() { 
			var x = this.x.substr(0,1), y = this.y.substr(0,1);
			return x === y ? x : (x === 'c' || (x !== 'c' && y !== 'c')) ? y + x : x + y;
		};
	}
};

// Define configuration defaults
$.fn.qtip.defaults = {
	prerender: FALSE,
	id: FALSE,
	overwrite: TRUE,
	metadata: {
		type: 'class'
	},
	content: {
		text: TRUE,
		attr: 'title',
		title: {
			text: FALSE,
			button: FALSE
		}
	},
	position: {
		my: 'top left',
		at: 'bottom right',
		target: FALSE,
		container: FALSE,
		adjust: {
			x: 0, y: 0,
			mouse: TRUE,
			screen: FALSE,
			resize: TRUE,
			container: FALSE
		},
		effect: TRUE
	},
	show: {
		target: FALSE,
		event: 'mouseenter',
		effect: TRUE,
		delay: 90,
		solo: FALSE,
		ready: FALSE
	},
	hide: {
		target: FALSE,
		event: 'mouseleave',
		effect: TRUE,
		delay: 0,
		fixed: FALSE,
		inactive: FALSE
	},
	style: {
		classes: '',
		widget: FALSE
	},
	events: {
		render: NULL,
		move: NULL,
		show: NULL,
		hide: NULL,
		focus: NULL,
		blur: NULL
	}
};function Ajax(qTip)
{
	var self = this;

	self.checks = {
		'^content.ajax': function() { this.plugins.ajax.load(this.options.content.ajax); }
	};

	$.extend(self, {

		init: function()
		{
			// Grab ajax options
			var ajax = qTip.options.content.ajax;

			// Bind render event to load initial content
			qTip.elements.tooltip.bind('tooltiprender.ajax', function() { 
				self.load(ajax);

				// Bind show event
				qTip.elements.tooltip.bind('tooltipshow.ajax', function() {
					// Update content if content.ajax.once is FALSE and the tooltip is rendered
					if(ajax.once === FALSE && qTip.rendered === TRUE) { self.load(ajax); }
				});
			});
		},

		load: function(ajax)
		{
			// Define success and error handlers
			function successHandler(content, status)
			{
				// Call user-defined success handler if present
				if($.isFunction(ajax.success)) {
					var result = ajax.success.call(qTip.hash(), content, status);
					if(result === FALSE){ return; }
				}

				// Update content
				qTip.set('content.text', content);

			}
			function errorHandler(xhr, status, error)
			{
				var content = status || error, result;

				// Call user-defined success handler if present
				if($.isFunction(ajax.error)) {
					result = ajax.error.call(qTip.hash(), xhr, status, error);
					if(result === FALSE){ return; }
				}

				// Update tooltip content to indicate error
				qTip.set('content.text', content);
			}

			// Setup $.ajax option object and process the request
			$.ajax( $.extend(TRUE, {}, ajax, { success: successHandler, error: errorHandler }) );

			return self;
		},

		destroy: function()
		{
			// Remove bound events
			qTip.elements.tooltip.unbind('tooltipshow.ajax');
		}
	});

	self.init();
}


$.fn.qtip.plugins.ajax = function(qTip)
{
	var api = qTip.plugins.ajax,
		opts = qTip.options.content.ajax;

	// Make sure the qTip uses the $.ajax functionality
	if(opts && opts.url) {
		// An API is already present, return it
		if(api) {
			return api;
		}
		// No API was found, create new instance
		else {
			qTip.plugins.ajax = new Ajax(qTip);
			return qTip.plugins.ajax;
		}
	}
};

$.fn.qtip.plugins.ajax.initialize = 'render';

// Setup plugin sanitization
$.fn.qtip.plugins.ajax.sanitize = function(options)
{
	var content = options.content, opts;
	if(content && 'ajax' in content) {
		opts = content.ajax;
		if(typeof opts !== 'object') { opts = options.content.ajax = { url: opts }; }
		if('boolean' !== typeof opts.once && opts.once) { opts.once = !!opts.once; }
	}
};

// Extend original qTip defaults
$.extend(TRUE, $.fn.qtip.defaults, {
	content: {
		ajax: {
			once: TRUE
		}
	}
});// Tip coordinates calculator
function calculateTip(corner, width, height)
{
	var width2 = Math.floor(width / 2), height2 = Math.floor(height / 2),

	// Define tip coordinates in terms of height and width values
	tips = {
		bottomright:	[[0,0],				[width,height],		[width,0]],
		bottomleft:		[[0,0],				[width,0],				[0,height]],
		topright:		[[0,height],		[width,0],				[width,height]],
		topleft:			[[0,0],				[0,height],				[width,height]],
		topcenter:		[[0,height],		[width2,0],				[width,height]],
		bottomcenter:	[[0,0],				[width,0],				[width2,height]],
		rightcenter:	[[0,0],				[width,height2],		[0,height]],
		leftcenter:		[[width,0],			[width,height],		[0,height2]]
	};

	// Set common side shapes
	tips.lefttop = tips.bottomright; tips.righttop = tips.bottomleft;
	tips.leftbottom = tips.topright; tips.rightbottom = tips.topleft;

	return tips[corner];
}

function Tip(qTip, command)
{
	var self = this,
		opts = qTip.options.style.tip,
		elems = qTip.elements,
		tooltip = elems.tooltip,
		wrapper = elems.wrapper,
		cache = { 
			top: 0, 
			left: 0, 
			corner: { string: function(){} }
		},
		size = {
			width: opts.width,
			height: opts.height
		},
		color = { },
		border = opts.border || 0,
		method = opts.method || FALSE;

	self.corner = NULL;
	self.mimic = NULL;
	self.checks = {
		'^position.my|style.tip.(corner|mimic|method|border)': function() {
			// Re-determine tip type and update
			border = opts.border;

			// Make sure a tip can be drawn
			if(!self.init()) {
				self.destroy();
			}

			// Only update the position if mouse isn't the target
			else if(this.get('position.target') !== 'mouse') {
				this.reposition();
			}
		},
		'^style.tip.(height|width)': function() {
			// Re-set dimensions and redraw the tip
			size = {
				width: opts.width,
				height: opts.height
			};
			self.create();
			self.update();

			// Reposition the tooltip
			qTip.reposition();
		},
		'^style.(classes|widget)$': function() {
			self.detectColours();
			self.update();
		}
	};

	// Tip position method
	function position(corner)
	{
		var tip = elems.tip,
			corners  = ['left', 'right'],
			offset = opts.offset,
			precedance, precedanceOp;

		// Return if tips are disabled or tip is not yet rendered
		if(opts.corner === FALSE || !tip) { return FALSE; }

		// Inherit corner if not provided
		corner = corner || self.corner;

		// Cache precedances
		precedance = corner.precedance;
		precedanceOp = precedance === 'y' ? 'x' : 'y';

		// Setup corners to be adjusted
		corners[ precedance === 'y' ? 'push' : 'unshift' ]('top', 'bottom');

		// Calculate offset adjustments
		offset = Math.max(corner[ precedanceOp ] === 'center' ? offset : 0, offset);

		// Reet initial position
		tip.css({ top: '', bottom: '', left: '', right: '', margin: '' });
		
		// Adjust primary corners
		switch(corner[ precedance === 'y' ? 'x' : 'y' ])
		{
			case 'center':
				tip.css(corners[0], '50%').css('margin-'+corners[0], -Math.floor(size[ (precedance === 'y') ? 'width' : 'height' ] / 2) + offset);
			break;

			case corners[0]:
				tip.css(corners[0], offset);
			break;

			case corners[1]:
				tip.css(corners[1], offset);
			break;
		}

		// Determine secondary adjustments
		offset = size[ (precedance === 'x') ? 'width' : 'height' ];
		if(border) {
			tooltip.toggleClass('ui-tooltip-accessible', !tooltip.is(':visible'));
			offset -= parseInt(wrapper.css('border-' + corner[ precedance ] + '-width'), 10) || 0;
			tooltip.removeClass('ui-tooltip-accessible');
		}

		// VML adjustments
		if(method === 'vml' && (/bottom|right/).test(corner[ corner.precedance ])) {
			offset += border ? 1 : -1;
		}

		// Adjust secondary corners
		tip.css(corner[precedance], -offset);
	}

	function reposition(event, api, pos, viewport) {
		if(!elems.tip) { return; }

		var newCorner = $.extend({}, self.corner),
			precedance = newCorner.precedance === 'y' ? ['y', 'top', 'left', 'height', 'x'] : ['x', 'left', 'top', 'width', 'y'],
			adjusted = pos.adjusted,
			offset = [0, 0];

		// Make sure our tip position isn't fixed e.g. doesn't adjust with adjust.screen
		if(self.corner.fixed !== TRUE) {
			// Adjust tip corners
			if(adjusted.left) {
				newCorner.x = newCorner.x === 'center' ? (adjusted.left > 0 ? 'left' : 'right') : (newCorner.x === 'left' ? 'right' : 'left');
			}
			if(adjusted.top) {
				newCorner.y = newCorner.y === 'center' ? (adjusted.top > 0 ? 'top' : 'bottom') : (newCorner.y === 'top' ? 'bottom' : 'top');
			}

			// Update and redraw the tip if needed
			if(newCorner.string() !== cache.corner.string() && (cache.top !== adjusted.top || cache.left !== adjusted.left)) {
				self.update(newCorner);
			}
		}

		// Setup offset adjustments
		offset[0] = border ? parseInt(wrapper.css('border-' + newCorner[ precedance[0] ] + '-width'), 10) || 0 : (method === 'vml' ? 1 : 0);
		offset[1] = Math.max(newCorner[ precedance[4] ] === 'center' ? opts.offset : 0, opts.offset);

		// Adjust tooltip position in relation to tip element
		pos[ precedance[1] ] += (newCorner[ precedance[0] ] === precedance[1] ? 1 : -1) * (size[ precedance[3] ] - offset[0]);
		pos[ precedance[2] ] -= (newCorner[ precedance[4] ] === precedance[2] || newCorner[ precedance[4] ] === 'center' ? 1 : -1) * offset[1];

		// Cache details
		cache.left = adjusted.left;
		cache.top = adjusted.top;
		cache.corner = newCorner;
	}

	$.extend(self, {
		init: function()
		{
			var ie = $.browser.msie,
				enabled = self.detectCorner(),
				center = self[self.mimic ? 'mimic' : 'corner'].string().indexOf('center') > -1;

			// Determine tip corner and type
			if(enabled) {
				// Check if rendering method is possible and if not fall back
				if(method === TRUE) {
					method = $('<canvas />')[0].getContext ? 'canvas' : ie && (center || size.height !== size.width) ? 'vml' : 'polygon';
				}
				else {
					if(method === 'canvas') {
						method = ie ? 'vml' : !$('<canvas />')[0].getContext ? 'polygon' : 'canvas';
					}
					else if(method === 'polygon') {
						method = ie && center ? 'vml' : method;
					}
				}

				// Create a new tip
				self.create();
				self.detectColours();
				self.update();

				// Bind update events
				tooltip.unbind('.qtip-tip').bind('tooltipmove.qtip-tip', reposition);
			}

			return enabled;
		},

		detectCorner: function()
		{
			var corner = opts.corner,
				at = qTip.options.position.at,
				my = qTip.options.position.my;
				if(my.string) { my = my.string(); }

			// Detect corner and mimic properties
			if(corner === FALSE || (my === FALSE && at === FALSE)) {
				return FALSE;
			}
			else {
				if(corner === TRUE) {
					self.corner = new $.fn.qtip.plugins.Corner(my);
				}
				else if(!corner.string) {
					self.corner = new $.fn.qtip.plugins.Corner(corner);
					self.corner.fixed = TRUE;
				}
			}

			return self.corner.string() !== 'centercenter';
		},

		detectColours: function() {
			var tip = elems.tip,
				corner = self.corner,
				precedance = self.corner[ self.corner.precedance ],
				borderSide = 'border-' + precedance + '-color',
				invalid = /rgba?\(0, 0, 0(, 0)?\)|transparent/i,
				isTitleTop = elems.titlebar && corner.y === 'top',
				isWidget = qTip.options.style.widget,
				elemFill = isWidget ? elems.content : isTitleTop ? elems.titlebar : elems.wrapper,
				elemBorder = !isWidget ? elems.wrapper : isTitleTop ? elems.titlebar : elems.content;

			// Detect tip colours from CSS styles
			color.fill = tip.css({ backgroundColor: '', border: '' }).css('background-color') || 'transparent';
			color.border = tip.get(0).style ? tip.get(0).style['border' + precedance.charAt(0) + precedance.substr(1) + 'Color'] : tip.css(borderSide) || 'transparent';

			// Make sure colours are valid and reset background and border properties
			if(invalid.test(color.fill)) { 
				color.fill = border ? elemFill.css('background-color') : elemBorder.css(borderSide);
			}
			if(!color.border || invalid.test(color.border)) {
				color.border = elemBorder.css(borderSide) || color.fill;
			}

			// Reset background and border colours
			$('*', tip).add(tip).css('background-color', 'transparent').css('border', 0);
		},

		create: function()
		{
			var width = size.width,
				height = size.height;

			// Create tip element and prepend to the tooltip if needed
			if(elems.tip){ elems.tip.remove(); }
			elems.tip = $('<div class="ui-tooltip-tip" />')
				.toggleClass('ui-widget-content', qTip.options.style.widget)
				.css(size).prependTo(tooltip);

			// Create tip element
			switch(method)
			{
				case 'canvas':
					// save() as soon as we create the canvas element so FF2 doesn't bork on our first restore()!
					$('<canvas height="'+height+'" width="'+width+'" />').appendTo(elems.tip)[0].getContext('2d').save(); 
				break;

				case 'vml':
					elems.tip.html('<vml:shape coordorigin="0 0" coordsize="'+width+' '+height+'" stroked="' + !!border + '" ' +
						' style="behavior:url(#default#VML); display:inline-block; antialias:TRUE; position: absolute; ' +
						' top:0; left:0; width:'+width+'px; height:'+height+'px; vertical-align:'+self.corner.y+';">' +

						'<vml:stroke weight="' + (border-2) + 'px" joinstyle="miter" miterlimit="10" ' + 
							' style="behavior:url(#default#VML); display:inline-block;" />' +

						'</vml:shape>');
				break;

				case 'polygon':
					elems.tip.append('<div class="ui-tooltip-tip-inner" />').append(border ? '<div class="ui-tooltip-tip-border" />' : '');
				break;
			}

			return self;
		},

		update: function(corner)
		{
			var tip = elems.tip,
				width = size.width,
				height = size.height,
				regular = 'px solid ',
				transparent = 'px dashed transparent', // Dashed IE6 border-transparency hack. Awesome!
				i = border > 0 ? 0 : 1,
				translate = Math.ceil(border / 2 + 0.5),
				mimic = opts.mimic,
				factor, context, path, coords, inner, round;

			// Re-determine tip if not already set
			if(!corner) { corner = self.corner; }

			// Use corner property if we detect an invalid mimic value
			if(mimic === FALSE) { mimic = corner; }

			// Otherwise inherit mimic properties from the corner object as necessary
			else {
				mimic = new $.fn.qtip.plugins.Corner(mimic);
				mimic.precedance = corner.precedance;

				if(mimic.x === 'inherit') { mimic.x = corner.x; }
				else if(mimic.y === 'inherit') { mimic.y = corner.y; }
				else if(mimic.x === mimic.y) {
					mimic[ corner.precedance ] = corner[ corner.precedance ];
				}
			}

			// Determine what type of rounding to use so we get pixel perfect precision!
			round = Math[ /b|r/.test(mimic[ mimic.precedance === 'y' ? 'x' : 'y' ]) ? 'ceil' : 'floor' ];

			// Find inner child of tip element
			inner = tip.children();

			// Create tip element
			switch(method)
			{
				case 'canvas':
					// Grab canvas context and clear it
					context = inner.get(0).getContext('2d');
					if(context.restore) { context.restore(); }
					context.clearRect(0,0,3000,3000);

					// Grab tip coordinates
					coords = calculateTip(mimic.string(), width, height);

					// Draw the canvas tip (Delayed til after DOM creation)
					for(i; i < 2; i++) {
						// Save and translate canvas origin
						if(i) {
							context.save();
							context.translate(
								round((mimic.x === 'left' ? 1 : mimic.x === 'right' ? -1 : 0) * (border + 1) * (mimic.precedance === 'y' ? 0.5 : 1)),
								round((mimic.y === 'top' ? 1 : mimic.y === 'bottom' ? -1 : 0) * (border + 1) * (mimic.precedance === 'x' ? 0.5 : 1))
							);
						}

						context.beginPath();
						context.moveTo(coords[0][0], coords[0][1]);
						context.lineTo(coords[1][0], coords[1][1]);
						context.lineTo(coords[2][0], coords[2][1]);
						context.closePath();
						context.fillStyle = color[ i ? 'fill' : 'border' ];
						context.fill();
					}
					break;

				case 'vml':
					// Determine tip coordinates based on dimensions
					coords = calculateTip(mimic.string(), width, height);

					// Create coordize and tip path using tip coordinates
					path = 'm' + coords[0][0] + ',' + coords[0][1] + ' l' + coords[1][0] +
						',' + coords[1][1] + ' ' + coords[2][0] + ',' + coords[2][1] + ' xe';

					inner.attr({ 'path': path, 'fillcolor': color.fill });

					if(border) {
						inner.children().attr('color', color.border);

						if(mimic.precedance === 'y') {
							inner.css('top', (mimic.y === 'top' ? 1 : -1) * (border - 2));
							inner.css('left', (mimic.x === 'left' ? 1 : -2));
						}
						else {
							inner.css('left', (mimic.x === 'left' ? 1 : -1) * (border - 2));
							inner.css('top', (mimic.y === 'top' ? 1 : -2));
						}

					}
					break;

				case 'polygon':
					// Determine border translations
					if(mimic.precedance === 'y') {
						factor = width > height ? 1.5 : width < height ? 5 : 2.2;
						translate = [
							mimic.x === 'left' ? translate : mimic.x === 'right' ? -translate : 0,
							Math.floor(factor * translate * (mimic.y === 'bottom' ? -1 : 1) * (mimic.x === 'center' ? 0.8 : 1))
						];
					}
					else {
						factor = width < height ? 1.5 : width > height ? 5 : 2.2;
						translate = [
							Math.floor(factor * translate * (mimic.x === 'right' ? -1 : 1) * (mimic.y === 'center' ? 0.9 : 1)),
							mimic.y === 'top' ? translate : mimic.y === 'bottom' ? -translate : 0
						];
					}

					inner.removeAttr('style').each(function(i) {
						// Determine what border corners/colors to set
						var toSet = {
								x: mimic.precedance === 'x' ? (mimic.x === 'left' ? 'right' : 'left') : mimic.x,
								y: mimic.precedance === 'y' ? (mimic.y === 'top' ? 'bottom' : 'top') : mimic.y
							},
							path = mimic.x === 'center' ? ['left', 'right', toSet.y, height, width] : ['top', 'bottom', toSet.x, width, height],
							col = color[!i && border ? 'border' : 'fill'];

						if(i) { 
							$(this).css({ 'position': 'absolute', 'z-index': 1, 'left': translate[0], 'top': translate[1] });
						}

						// Setup borders based on corner values
						if(mimic.x === 'center' || mimic.y === 'center') {
							$(this).css('border-' + path[2], path[3] + regular + col)
								.css('border-' + path[0], Math.floor(path[4] / 2) + transparent)
								.css('border-' + path[1], Math.floor(path[4] / 2) + transparent);
						}
						else {
							$(this).css('border-width', Math.floor(height / 2) + 'px ' + Math.floor(width / 2) + 'px')
								.css('border-' + toSet.x, Math.floor(width / 2) + regular + col)
								.css('border-' + toSet.y, Math.floor(height / 2) + regular + col);
						}
					});
					break;
			}

			// Update position
			position(corner);

			return self;
		},

		destroy: function()
		{
			// Remove previous tip if present
			if(elems.tip) {
				elems.tip.remove();
			}

			// Remove bound events
			tooltip.unbind('.qtip-tip');
		}
	});
}

$.fn.qtip.plugins.tip = function(qTip)
{
	var api = qTip.plugins.tip,
		opts = qTip.options.style.tip;

	// Make sure tip options are present
	if(opts && opts.corner) {
		// An API is already present,
		if(api) {
			return api;
		}
		// No API was found, create new instance
		else {
			qTip.plugins.tip = new Tip(qTip);
			qTip.plugins.tip.init();

			return qTip.plugins.tip;
		}
	}
};

// Initialize tip on render
$.fn.qtip.plugins.tip.initialize = 'render';

// Setup plugin sanitization options
$.fn.qtip.plugins.tip.sanitize = function(options)
{
	var style = options.style, opts;
	if(style && 'tip' in style) {
		opts = options.style.tip;
		if(typeof opts !== 'object'){ options.style.tip = { corner: opts }; }
		if(!(/string|boolean/i).test(typeof opts.corner)) { opts.corner = true; }
		if(typeof opts.method !== 'string'){ opts.method = TRUE; }
		if(!(/canvas|polygon/i).test(opts.method)){ opts.method = TRUE; }
		if(typeof opts.width !== 'number'){ delete opts.width; }
		if(typeof opts.height !== 'number'){ delete opts.height; }
		if(typeof opts.border !== 'number'){ delete opts.border; }
		if(typeof opts.offset !== 'number'){ delete opts.offset; }
	}
};

// Extend original qTip defaults
$.extend(TRUE, $.fn.qtip.defaults, {
	style: {
		tip: {
			corner: TRUE,
			mimic: FALSE,
			method: TRUE,
			width: 9,
			height: 9,
			border: 0,
			offset: 0
		}
	}
});$.fn.qtip.plugins.imagemap = function(area, corner)
{
	var shape = area.attr('shape').toLowerCase(),
		baseCoords = area.attr('coords').split(','),
		coords = [],
		image = $('img[usemap="#'+area.parent('map').attr('name')+'"]'),
		imageOffset = image.offset(),
		result = {
			width: 0, height: 0,
			offset: { top: 1e10, right: 0, bottom: 0, left: 1e10 }
		},
		i = 0, next = 0;

	// POLY area coordinate calculator
	//	Special thanks to Ed Cradock for helping out with this.
	//	Uses a binary search algorithm to find suitable coordinates.
	function polyCoordinates(result, coords)
	{
		var i = 0,
			compareX = 1, compareY = 1,
			realX = 0, realY = 0,
			newWidth = result.width,
			newHeight = result.height;

		// Use a binary search algorithm to locate most suitable coordinate (hopefully)
		while(newWidth > 0 && newHeight > 0 && compareX > 0 && compareY > 0)
		{
			newWidth = Math.floor(newWidth / 2);
			newHeight = Math.floor(newHeight / 2);

			if(corner.x === 'left'){ compareX = newWidth; }
			else if(corner.x === 'right'){ compareX = result.width - newWidth; }
			else{ compareX += Math.floor(newWidth / 2); }

			if(corner.y === 'top'){ compareY = newHeight; }
			else if(corner.y === 'bottom'){ compareY = result.height - newHeight; }
			else{ compareY += Math.floor(newHeight / 2); }

			i = coords.length; while(i--)
			{
				if(coords.length < 2){ break; }

				realX = coords[i][0] - result.offset.left;
				realY = coords[i][1] - result.offset.top;

				if((corner.x === 'left' && realX >= compareX) ||
				(corner.x === 'right' && realX <= compareX) ||
				(corner.x === 'center' && (realX < compareX || realX > (result.width - compareX))) ||
				(corner.y === 'top' && realY >= compareY) ||
				(corner.y === 'bottom' && realY <= compareY) ||
				(corner.y === 'center' && (realY < compareY || realY > (result.height - compareY)))) {
					coords.splice(i, 1);
				}
			}
		}

		return { left: coords[0][0], top: coords[0][1] };
	}

	// Make sure we account for padding and borders on the image
	imageOffset.left += Math.ceil((image.outerWidth() - image.width()) / 2);
	imageOffset.top += Math.ceil((image.outerHeight() - image.height()) / 2);

	// Parse coordinates into proper array
	if(shape === 'poly') {
		i = baseCoords.length; while(i--)
		{
			next = [ parseInt(baseCoords[--i], 10), parseInt(baseCoords[i+1], 10) ];

			if(next[0] > result.offset.right){ result.offset.right = next[0]; }
			if(next[0] < result.offset.left){ result.offset.left = next[0]; }
			if(next[1] > result.offset.bottom){ result.offset.bottom = next[1]; }
			if(next[1] < result.offset.top){ result.offset.top = next[1]; }

			coords.push(next);
		}
	}
	else {
		coords = $.map(baseCoords, function(coord){ return parseInt(coord, 10); });
	}

	// Calculate details
	switch(shape)
	{
		case 'rect':
			result = {
				width: Math.abs(coords[2] - coords[0]),
				height: Math.abs(coords[3] - coords[1]),
				offset: { left: coords[0], top: coords[1] }
			};
		break;

		case 'circle':
			result = {
				width: coords[2] + 2,
				height: coords[2] + 2,
				offset: { left: coords[0], top: coords[1] }
			};
		break;

		case 'poly':
			$.extend(result, {
				width: Math.abs(result.offset.right - result.offset.left),
				height: Math.abs(result.offset.bottom - result.offset.top)
			});

			if(corner.string() === 'centercenter') {
				result.offset = {
					left: result.offset.left + (result.width / 2),
					top: result.offset.top + (result.height / 2)
				};
			}
			else {
				result.offset = polyCoordinates(result, coords.slice());
			}

			result.width = result.height = 0;
		break;
	}

	// Add image position to offset coordinates
	result.offset.left += imageOffset.left;
	result.offset.top += imageOffset.top;

	return result;
};

function Modal(qTip, options)
{
	var self = this,
		elems = qTip.elements,
		tooltip = elems.tooltip,
		namespace = '.qtipmodal',
		events = 'tooltipshow'+namespace+' tooltiphide'+namespace;

	// See if overlay is already present
	elems.overlay = $('#qtip-overlay');

	$.extend(self, {
		init: function()
		{
			// Check if the tooltip is modal
			tooltip.bind(events, function(event, api, duration) {
				var type = event.type.replace('tooltip', '');

				if($.isFunction(options[type])) {
					options[type].call(elems.overlay, duration, api);
				}
				else {
					self[type](duration);
				}
			});

			// Create the overlay if needed
			if(!elems.overlay.length) {
				self.create();
			}

			// Hide tooltip on overlay click if enabled
			if(options.blur === TRUE) {
				elems.overlay.bind('click'+namespace+qTip.id, function(){ qTip.hide.call(qTip); });
			}
		},

		create: function()
		{
			// Create document overlay
			elems.overlay = $('<div />', {
				id: 'qtip-overlay',
				css: {
					position: 'absolute',
					top: 0,
					left: 0,
					display: 'none'
				}
			})
			.appendTo(document.body);

			// Update position on window resize or scroll
			$(window).bind('resize'+namespace, function() {
				elems.overlay.css({
					height: Math.max( $(window).height(), $(document).height() ),
					width: Math.max( $(window).width(), $(document).width() )
				});
			})
			.trigger('resize');
		},

		toggle: function(state)
		{
			var overlay = elems.overlay,
				effect = qTip.options.show.modal.effect,
				type = state ? 'show': 'hide';

			// Setop all animations
			overlay.stop(TRUE, FALSE);

			// Use custom function if provided
			if($.isFunction(effect)) {
				effect.call(overlay, state);
			}

			// If no effect type is supplied, use a simple toggle
			else if(effect === FALSE) {
				overlay[ type ]();
			}

			// Use basic fade function
			else {
				overlay.fadeTo(90, state ? 0.7 : 0, function() {
					if(!state) { $(this).hide(); }
				});
			}
		},

		show: function() { self.toggle(TRUE); },
		hide: function() { self.toggle(FALSE); },

		destroy: function()
		{
			var delBlanket = TRUE;

			// Check if any other modal tooltips are present
			$('*').each(function() {
				var api = $(this).data('qtip');
				if(api && api.id !== qTip.id && api.options.show.modal) {
					// Another modal tooltip was present, leave overlay
					delBlanket = FALSE;
					return FALSE;
				}
			});

			// Remove overlay if needed
			if(delBlanket) {
				elems.overlay.remove();
				$(window).unbind('scroll'+namespace+' resize'+namespace);
			}
			else {
				elems.overlay.unbind('click'+namespace+qTip.id);
			}

			// Remove bound events
			tooltip.unbind(events);
		}
	});

	self.init();
}

$.fn.qtip.plugins.modal = function(qTip)
{
	var api = qTip.plugins.modal,
		opts = qTip.options.show.modal;

	// An API is already present,
	if(api) {
		return api;
	}
	// No API was found, create new instance
	else if(opts && opts.on === TRUE) {
		qTip.plugins.modal = new Modal(qTip, opts);
		return qTip.plugins.modal;
	}
};

// Plugin needs to be initialized on render
$.fn.qtip.plugins.modal.initialize = 'render';

// Setup sanitiztion rules
$.fn.qtip.plugins.modal.sanitize = function(opts) {
	if(opts.show) { 
		if(typeof opts.show.modal !== 'object') { opts.show.modal = { on: !!opts.show.modal }; }
		else if(typeof opts.show.modal.on === 'undefined') { opts.show.modal.on = TRUE; }
	}
};

// Extend original qTip defaults
$.extend(TRUE, $.fn.qtip.defaults, {
	show: {
		modal: {
			on: FALSE,
			effect: TRUE,
			blur: TRUE
		}
	}
});/* BGIFrame adaption (http://plugins.jquery.com/project/bgiframe) - Special thanks to Brandon Aaron */
function BGIFrame(qTip)
{
	var self = this,
		elems = qTip.elements,
		tooltip = elems.tooltip,
		namespace = '.bgiframe-' + qTip.id,
		events = 'tooltipmove'+namespace+' tooltipshow'+namespace;

	$.extend(self, {
		init: function()
		{
			// Create the BGIFrame element
			elems.bgiframe = $('<iframe class="ui-tooltip-bgiframe" frameborder="0" tabindex="-1" src="javascript:\'\';" ' +
				' style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=0);"></iframe>');

			// Append the new element to the tooltip
			elems.bgiframe.appendTo(tooltip);

			// Update BGIFrame on tooltip move
			tooltip.bind(events, self.adjust);
		},

		adjust: function()
		{
			var dimensions = qTip.get('dimensions'), // Determine current tooltip dimensions
				plugin = qTip.plugins.tip,
				tip = qTip.elements.tip,
				tipAdjust, offset;

			// Adjust border offset
			offset = parseInt(tooltip.css('border-left-width'), 10) || 0;
			offset = { left: -offset, top: -offset };

			// Adjust for tips plugin
			if(plugin && tip) {
				tipAdjust = (plugin.corner.precedance === 'x') ? ['width', 'left'] : ['height', 'top'];
				offset[ tipAdjust[1] ] -= tip[ tipAdjust[0] ]();
			}

			// Update bgiframe
			elems.bgiframe.css(offset).css(dimensions);
		},

		destroy: function()
		{
			// Remove iframe
			self.iframe.remove();

			// Remove bound events
			tooltip.unbind(events);
		}
	});

	self.init();
}

$.fn.qtip.plugins.bgiframe = function(qTip)
{
	// Proceed only if the browser is IE6 and offending elements are present
	if(!($.browser.msie && (/^6\.[0-9]/).test($.browser.version) && $('select, object').length)) {
		return FALSE;
	}

	// Retrieve previous API object
	var api = qTip.plugins.bgiframe;

	// An API is already present,
	if(api) {
		return api;
	}
	// No API was found, create new instance
	else {
		qTip.plugins.bgiframe = new BGIFrame(qTip);
		return qTip.plugins.bgiframe;
	}
};

// Plugin needs to be initialized on render
$.fn.qtip.plugins.bgiframe.initialize = 'render';

}(jQuery, window));


