1 (function($){
  2 	'use strict';		
  3 	
  4 	/**
  5 	* get value
  6 	* @param {Object} self - this object
  7 	* @param {string} dataType - data type name (title, address, etc.)
  8 	*/
  9 	var getValue = function(self, dataType){
 10 	
 11 		var $el;
 12 		
 13 		//get value
 14 		$el = self.$element.find('[data-type="' + dataType + '"]');
 15 		
 16 		//if null?
 17 		if($el.length > 0){
 18 			return $el.text();
 19 		}
 20 		
 21 		return null;
 22 	};
 23 	
 24 	/**
 25 	* get full address
 26 	* @param {Object} self - this object
 27 	* @return {string}
 28 	*/
 29 	var getFullAddress = function(self){	
 30 	
 31 		var fullAddress = '';
 32 		
 33 		if(self.address){
 34 			fullAddress += self.address + ' ';
 35 		}
 36 		
 37 		if(self.city){
 38 			fullAddress += self.city + ' ';
 39 		}
 40 		
 41 		if(self.state){
 42 			fullAddress += self.state + ' ';
 43 		}
 44 		
 45 		if(self.zipcode){
 46 			fullAddress += self.zipcode + ' ';
 47 		}
 48 		
 49 		if(self.country){
 50 			fullAddress += self.country + ' ';
 51 		}
 52 		
 53 		return fullAddress;		
 54 	};
 55 	
 56 	/**
 57 	* get store data
 58 	* @param {Object} self - this object
 59 	*/
 60 	var getData = function(self){
 61 	
 62 		var latitude
 63 			,longitude
 64 			,icon
 65 			,zoom;
 66 		
 67 		//get vars
 68 		self.title = getValue(self, 'title');
 69 		self.address = getValue(self, 'address');
 70 		self.city = getValue(self, 'city');
 71 		self.state = getValue(self, 'state');
 72 		self.zipcode = getValue(self, 'zipcode');
 73 		self.country = getValue(self, 'country');
 74 		
 75 		//get custom marker icon (if exists)		
 76 		icon = self.$element.attr('data-marker-icon');
 77 		if(icon){
 78 			self.customMarkerIcon = icon;
 79 		}
 80 		
 81 		//get zoom
 82 		zoom = self.$element.attr('data-zoom');		
 83 		if($.isNumeric(zoom)){			
 84 			self.zoom = Number(zoom);
 85 		}
 86 		
 87 		//get latitude
 88 		latitude = self.$element.attr('data-latitude');		
 89 		if($.isNumeric(latitude)){			
 90 			self.latitude = latitude;
 91 		}
 92 		
 93 		//get longitude
 94 		longitude = self.$element.attr('data-longitude');		
 95 		if($.isNumeric(longitude)){			
 96 			self.longitude = longitude;
 97 		}
 98 		
 99 		if($.isNumeric(latitude) && $.isNumeric(longitude)){			
100 			self.latlng = new google.maps.LatLng(self.latitude, self.longitude, true);
101 		}
102 	};
103 	
104 	/**
105 	* store constructor
106 	* @param {jQueryObject} $element - store element
107 	* @param {Object} options - jlocator user options
108 	* @return {Object} - store + this	
109 	* @constructor 
110 	*/
111 	var Init = function($element, options){
112 	
113 		var self = {			
114 			$element: $element
115 			,options: options
116 			,customMarkerIcon: ''
117 			,html: ''
118 			
119 			//address vars
120 			,fullAddress: ''
121 			,title: ''
122 			,address: ''
123 			,city: ''
124 			,state: ''
125 			,zipcode: ''
126 			,country: ''
127 			,zoom: options.storeZoom
128 			
129 			//point
130 			,latitude: null
131 			,longitude: null
132 			,latlng: null
133 		};	
134 		
135 		//init html
136 		self.html = jQuery.fn['jplist']['services']['Helper']['getOuterHtml']($element);
137 		
138 		//get data
139 		getData(self);
140 		
141 		//get full address
142 		getFullAddress(self);
143 				
144 		return $.extend(this, self);
145 	};
146 	
147 	/**
148 	* store constructor
149 	* @param {jQueryObject} $element - store element
150 	* @param {Object} options - jlocator user options
151 	* @return {Object} - store
152 	* @constructor 
153 	* @name store
154     * @class Controller
155     * @memberOf jQuery.fn.jlocator
156 	* @property {jQueryObject} $element - store element
157 	* @property {Object} options - jlocator user options
158 	* @property {string} customMarkerIcon - store custom marker icon url
159 	* @property {string} html - store html
160 	* @property {string} fullAddress - store full address
161 	* @property {string} address - store address
162 	* @property {string} city - store city
163 	* @property {string} state - store state
164 	* @property {string} zipcode - store zipcode
165 	* @property {string} country - store country
166 	* @property {number} latitude - store latitude
167 	* @property {number} longitude - store longitude
168 	* @property {Object} latlng - google latlng object
169 	*/
170 	jQuery.fn.jlocator.store = function($element, options){
171 				
172 		//call constructor
173 		var self = new Init($element, options);	
174 		
175 		return self;
176 	};
177 })(jQuery);
178 
179