//var blank = new Image();
//blank.src = 'images/blank.gif';
//var menuLock = false;
//var savedPicture = '';
/**
 *	Executes the function when the DOM is ready to be used
 *  to load all ACE components
 */
$(function(){
	BrowserDetect.init();
	/*
	alert(BrowserDetect.browser)
	alert("Browser version: "+BrowserDetect.version)
	alert("OS name: "+BrowserDetect.OS)
	*/

	jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
//	  if($(this).is(':animated') /*|| $(this).next('div').is(':visible')*/) { return false;} 
	  return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);  
	};

	jQuery.fn.exists = function() {
	  return $(this).length > 0;
	};

    /**
     * Disable context menu of the complete page
     */
	$('html').noContext();

	/**
	 * Fix IE display bugs
	 */
	//if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) { }
	var ie6 = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	//var ie8 = (/MSIE ((8)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (ie6) {;
//		$("div#menu li ul").ifixpng(); //.css({cursor:'pointer'}).click(function(){ alert('ifixpng'); });; 
//		$('img[@src$=.png]').ifixpng(); 
//		$('img[@src$=.png]').ifixpng(); 
	}

	//submenu bgfix
	$('.menu #m1').css('width','41px');
	$('.menu #m2').css('width','133px');
	$('.menu #m3').css('width','91px');
	$('.menu #m4').css('width','121px');
	$('.menu #m5').css('width','120px');

//		alert(BrowserDetect.version)
	//check mac browser
	if(BrowserDetect.OS =="Mac" /*&& BrowserDetect.version < 3.2 */) {
		$('div#menu').css('font-size','11.5pt');
		$('div#content').css('font-size','11pt');
	} else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3) ;
//		else if (ffversion>=2)
		else if (ffversion>=1)	{
			$('div#menu').css('font-size','11.5pt');
			$('div#content').css('font-size','11pt');
		}
	}

	$("div#menu ul.menu ul").hide();
	$("div#menu li.level1").hover(
		function () {
			if(! $(this).find('ul').hasClass('mutex')) {
				$(this).find('ul').addClass('mutex')
				$(this).find('ul').slideFadeToggle(330, null, null);
			}
		}, 
		function () {
			if( $(this).find('ul').hasClass('mutex')) {
				$(this).find('ul').slideFadeToggle(330, null, eval("$(this).find('ul').removeClass('mutex')"));
			}
		}
	);

	$("div#menu ul.menu ul").click(function () {
		$(this).removeClass('mutex');
		$(this).slideFadeToggle(300, null, null);
	});

	/**
	 * Adjust witdth of homepage
	 * 	$(".content_m").css('height','250px');
	 */

	/**
	 * Sets the defaults for AJAX requests to the url "php/controller.php",
	 * disables global handlers and uses POST instead of GET. 
	 * the cache is also set to force some browsers to retrieve the lastest version of the content.
	 */
	$.ajaxSetup({
		url: "php/controller.php",
		global: false,
		type: "POST",
		cache: false
	});

	var currItem = $("#menu a.current");
	/*
	 * MENU SECTION
	 *********************************/
	$("a").click(function(e){

		el =$(this);
		href = el.attr('href');
		if(el.hasClass('current')) {return}
		if(href=="#" || href=="") {return}
		href = href.slice(1);

		$.ajax({
			data: 'a='+href,
			success: function(html) {
				//update the active menu state
				currItem = updateActiveMenu(currItem, el);
				$.scrollTo( { top:0, left:0}, 300,{onAfter: onSuccessCallback(html, href)} );				
			}
		});	
	});

	/**
	 * init the images gallery & the special notice scrolling effect
	 */
//	initMenu();
	initSlideshow();
	initBoxes();

	function initBoxes() {
		$('#noticePane').jScrollPane({showArrows:true});

	 	$('div.home marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
         /*   if ($(this).data('drag') == true) {
                this.scrollTop = $(this).data('scrollY') + ($(this).data('y') - event.clientY);
            }
           */
        }).mousedown(function (event) {
         //   $(this).data('drag', true).data('y', event.clientY).data('scrollY', this.scrollTop);
        }).mouseup(function () {
         //   $(this).data('drag', false);
        });
	

	}


	function getPixelHeight(el) {
		if(el.css('height').indexOf('p')!=-1)
			return parseInt(el.css('height').substr(0, el.css('height').length - 2));
		else
			return el.css('height');
	}
	/**
	 * Custom Accordion style effect
	 */		
	function faqAccordion(e, container ) { 
		//load manually the accordion theme
	
		e.accordion({
			autoHeight: false,
			fillSpace: false,
			collapsible:true,
			active:false
		});
		e.accordion( 'disable' )
	/*
		e.addClass('ui-accordion ui-widget ui-helper-reset');
		e.find('h3').addClass('ui-accordion-header ui-helper-reset ui-state-active ui-corner-all');
		e.find('h3').find('a').before('<span class="ui-icon ui-icon-triangle-1-e"/>');
		e.find('div').addClass('ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom');
*/
		curHeight = getPixelHeight(container); 
		height = 0;
		//alert('init: ' + curHeight);
		
		$(e).find('div').hide(); 
		//$(e).find('a').click(function(){return false;});
		
		$(e).find('a').click( function(){ 
			if($(this).attr('id') == 'top') $.scrollTo( { top:0 }, 300 );				
			else if ($(this).attr('id') == 'header') {
//				if($(e).find('div').is(':animated') || $(this).parent().next('div').is(':visible')) {return false;} //mouverover filter
				//interaction cues.
				$(e).find('h3.opened').removeClass('ui-state-active ui-corner-top');
				$(e).find('h3.opened').addClass('ui-state-default ui-corner-all');
	
				$(e).find('h3.opened').find('span').removeClass('ui-icon-triangle-1-s');
				$(e).find('h3.opened').find('span').addClass('ui-icon-triangle-1-e');
	
				$(e).find('div:visible').removeClass('ui-corner-bottom ui-accordion-content-active');
				$(e).find('div:visible').addClass('ui-corner-all');
				
				oldHeight = 0;
				
				if($(e).find('h3.opened').css('height')) {
					oldHeight = getPixelHeight($(e).find('div:visible'));
//					$(".content_m").css({ height: curHeight }, 200)
				}
				$(e).find('h3.opened').removeClass('opened'); 
				
				$(e).find('div:visible').slideUp('slow'); 

				if($(this).parent().next('div').is(':visible')) {
					curHeight -= (getPixelHeight($(e).find('div:visible')));
					$(".content_m").animate({ height: curHeight }, 200);
				}
				else $(this).parent().next('div').slideDown('slow',function(){
	//				alert((getPixelHeight($(e).find('div:visible'))))
	
	//				if(oldHeight == 0) {
	
					curHeight += (getPixelHeight($(e).find('div:visible')) - oldHeight);
	//				alert($(e).find('h3.opened').css('height'))
	//				alert($(e).find('div:visible').css('height'))
					//update content height
	//				alert('new Height: ' + curHeight)
	//				$(".content_m").animate({ height: curHeight }, 200)
	
					$(".content_m").css( 'height', curHeight);				
						
	//				} 
				}).end().addClass('opened'); 
	
				//interaction cues.
				$(e).find('h3.opened').removeClass('ui-state-default ui-corner-all');
				$(e).find('h3.opened').addClass('ui-state-active ui-corner-top');
	
				$(e).find('h3.opened').find('span').removeClass('ui-icon-triangle-1-e');
				$(e).find('h3.opened').find('span').addClass('ui-icon-triangle-1-s');
	
				$(e).find('div:visible').removeClass('ui-corner-all');
				$(e).find('div:visible').addClass('ui-corner-bottom ui-accordion-content-active');				

			} else { ; } //do nothing
		}); 
	};

	/**
	 * crossfade page transition
	 */
	function onSuccessCallback(html, href){
		var cont = $('div#content');
		cont.fadeOut(150, function() {
			cont.html(html);
			$(".content_m").animate({ height: $('div#content > div').css('height') }, 200, function() {
				//suppose to be in initPage methods but cause glitch!
				if (href == "faq" || href == "fundraisers_faq") {
					var oldSize = -1;
					var initSize = $('div#content > div').css('height');
					initSize = parseInt(initSize.substr(0, initSize.length - 2));
					faqAccordion($('.subFaq'), $('div#content > div') ); 
				}
	            cont.fadeIn(150 , function() { initPage(href); })
			});

		})	
	}
	
	function onSuccessFormCallback(responseText, statusText)  { 
//		alert('status: ' + statusText + '\n\nresponseText: \n' + responseText)
		currItem = updateActiveMenu(currItem, null);
		$.scrollTo( { top:0, left:0}, 300,{onAfter: onSuccessCallback(responseText, "thanks")} );				
	}

	function initPage(href) {
		switch(href) {
			case 'home' :
				initSlideshow();
				initBoxes();
				break;
			//forms
			case "proposal":
			case "howtobook":
			case "dealers" :
			case "affiliates" :
			
				//rollover on button
				$('#submit, #reset').hover(function() { $(this).addClass('hover'); }, function() {  $(this).removeClass('hover'); });
				$('#submit').click(function() { $('form').submit();	});
				$('#reset').click(function() { $('form')[ 0 ].reset();	});
			    // bind to the form's submit event 
			    $('form').submit(function() { $(this).ajaxSubmit({ beforeSubmit: validateForm, success: onSuccessFormCallback });  return false;  }); 
				$("#divRequired").hide();

				
				if ( $("#fax").exists() ) { $("#fax").mask("(999) 999-9999"); }
				if ( $("#phone").exists() ) { $("#phone").mask("(999) 999-9999? x99999"); }
				if ( $("#guest").exists() ) { $("#guest, #nb1, #nb2, #nb3, #nb4, #nb5, #nb6, #nb7, #nb8").mask("9?99"); }
				if ( $("#addressLocation").exists() ) { $("#addressLocation, #otherEvent, #businessCard").hide(); $("#chkReferral4").click(function() { $("#businessCard").slideToggle(); });  }
				if ( $("#startTime").exists() ) { $("#startTime").clock({displayFormat:'12',defaultHour:'07',defaultMinute:'00',defaultAM:'PM',seconds:false});$("#endTime").clock({displayFormat:'12',defaultHour:'11',defaultMinute:'00',defaultAM:'PM',seconds:false}); }
				if ( $("#otherLanguage").exists() ) { $("#otherLanguage").hide(); }
				if ( $("#splimoFeet").exists() ) { 
					$("#splimoFeet, #spOtherTalent").css('display', 'block');
					$("#splimoFeet, #spOtherTalent").hide();
					$("#chkTalent3").click(function() { $("#splimoFeet").slideToggle(); });
					$("#chkTalent23").click(function() { $("#spOtherTalent").slideToggle(); });
					$("#limoFeet").mask("9?99");
					$("#phone2, #refPhone1, #refPhone2").mask("(999) 999-9999? x99999");
				}
				if ( $("#daydropdown").exists() ) {
					createDateSelect("daydropdown", "monthdropdown", "yeardropdown")
				}

				//dealer form
				if ( $("#uploadBtn").exists() ) { 
					$("#chkLang4").click(function() { $("#otherLanguage").slideToggle(); });
					var button = $('#uploadBtn');
					new Ajax_upload(button, {
						action: 'php/upload.php',
						autoSubmit:true,
						data : {
							'key1' : "This data won't",
							'key2' : "be send because",
							'key3' : "we will overwrite it"
						},
						onChange: function(file, ext){},
						onSubmit : function(file , ext){
							button.text('Uploading');
							
							//if (ext && new RegExp('^(' + allowed.join('|') + ')$').test(ext)){
							if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)){
								/* Setting data */
								this.setData({
									'key': 'This string will be send with the file'
								});
								this.disable();
							} else {
								// extension is not allowed
								$('.uploadText').text('Error: only images are allowed');
								button.text('Upload image');
								// cancel upload
								return false;				
							}			
							// Uploding -> Uploading. -> Uploading...
							interval = window.setInterval(function(){
								var text = button.text();
								if (text.length < 13){
									button.text(text + '.');
								} else {
									button.text('Uploading');
								}
							}, 200);
						},
						onComplete : function(file, response){
	
							window.clearInterval(interval);
							
							if(response == "success") {
								button.text('Change image');
								window.clearInterval(interval);
								$('.uploadText').text('Image: ' + file + ' uploaded');
								$('#picture').val(file) 
							} else {
								button.text('Upload');
								$('.uploadText').text('Please choose a picture smaller than 2MB');
							}
							this.enable();
						}		
					});
				}

				if ( $("form input:radio").exists() )
					$("form input:radio").click(function() {
						switch ($(this).val()) {
							case 'Same as Above':
								$("#addressLocation").slideUp();
							break;
							case 'Another Address':
								$("#addressLocation").slideDown();
							break;
							// <CAN_BE_BETTER>
							case 'Fundraiser':
								$("#otherEvent").slideUp(function() {$("#eventTypeOther").val('');});
							break;
							case 'Business Event':
								$("#otherEvent").slideUp(function() {$("#eventTypeOther").val('');});
							break;
							case 'Private Party':
								$("#otherEvent").slideUp(function() {$("#eventTypeOther").val('');});
							break;
							case 'Other':
								$("#otherEvent").slideDown();
							break;
							// </CAN_BE_BETTER>
							default:
								//do nothing for others input radio 
						}
					});
				break;


			case 'fundraisers' :
			case 'join' :
				initSlideshow();
				initSubLinks();
				break;

			case 'areas' :
			case 'contact' :
				initSlideshow();
				break;
	
			case 'games' :
			case 'why' :
				initInteractionUl();
				break;

			case 'faq' :
				//already init before display to avoid a glitch
				break;
		}		
	}
	
	function updateActiveMenu(previousItem, currentItem) {
		if(previousItem!=null) previousItem.removeClass('current');
		if(currentItem!=null) currentItem.addClass('current');
		return currentItem;
	}
	
	function initSubLinks() {
		$('.button').hover(function() { $(this).addClass('hover'); }, function() {  $(this).removeClass('hover'); });
		$("div#content div.button").click(function(e) {
			subHref =$(this).attr('id').slice(1);
			$('#menu a').each(function() {
				if ($(this).attr('href').slice(1) == subHref) {
					currItem = updateActiveMenu(currItem, $(this));
				}
			})
			
			$.ajax({ data: 'a='+subHref, success: function(html) { $.scrollTo( { top:0, left:0}, 300,{onAfter: onSuccessCallback(html, subHref)} ); } });
		});
	}
	
	function initSlideshow() {
		/*
		$('#slideshow').removeClass("flash-replaced");
		$('#slideshow').html('');
		$('#slideshow').flash( { src: 'swf/slideshow.swf?r='+ (new Date()).getTime() + Math.round(Math.random() * 10000), width: 380, height: 253 	}, { version: 8 })
		*/
	}

	function initInteractionUl() {
		if ($(".ui-state-default")) $(".ui-state-default").hover( function () { $(this).addClass('ui-state-hover'); },  function () { $(this).removeClass('ui-state-hover'); } );
	}
 

	/**
	 * Show message if required fields are empty,
	 * validate the format of the mail field
	 * 
	 * @param the form to validate
	 * @return false if the is some empty fields in the form, 
	 * true otherwise.
	 */
	function validateForm(formData, jqForm, options) {
//		showRequest(formData, jqForm, options)
//		return false;
		var isErr = false;
		$("span.required").each(function(i){
			var resetField = $(this).parent('p').next().find('input:hidden')
			if(resetField) {resetField.removeClass('error')}
			var requiredField = $(this).parent('p').next().find('input:visible'); //, select');
			if(requiredField.attr('id')=="radEventType") {
				if ($('input[type=radio][name=radEventType]:checked').length != 1) {
					isErr = true;
//					if(!requiredField.hasClass('error')) requiredField.addClass('error');
	      			$('#divRequired').html('Please fill all required field(s)').hide();
				}
//				if($(requiredField)$(this).parent('p').next().find('input:[radio]:checked').size == 0) 
			}
			else if(requiredField.val()=="") { //&& requiredField.parent().css('height')!=0) {
				isErr = true;
	      		$('#divRequired').html('Please fill all required field(s) highlighted in red').hide();
				if(!requiredField.hasClass('error')) requiredField.addClass('error');
/*			}
			else if(requiredField.attr('id')=="dateParty") {
				var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				if(!reg.test(requiredField.val())) {
					isErr = true;
					if(!requiredField.hasClass('error')) requiredField.addClass('error');
	      			$('#divRequired').html('Please enter a valid email address').hide();
				} else if(requiredField.hasClass('error')) requiredField.removeClass('error');
*/
/*				
			} else if(requiredField.attr('id')=="emailAddress" || requiredField.attr('id')=="emailAddress2") {
			    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				if(!reg.test(requiredField.val())) {
					isErr = true;
					if(!requiredField.hasClass('error')) requiredField.addClass('error');
	      			$('#divRequired').html('Please enter a valid email address').hide();
				} else if(requiredField.hasClass('error')) requiredField.removeClass('error');
*/			} else {
				if(requiredField.hasClass('error')) requiredField.removeClass('error');
			}
		});
		if(isErr) $('#divRequired').effect("highlight", {color:'red'}, 300);
		else { $('#divRequired').html('').hide(); }
		if(isErr)  {return false;}
//		return !isErr;
	}
	
	//http://www.protocoder.com/javascript/jquery-simple-clock-plugin-for-time-entry/
	var clockNumber = 0;
	$.fn.clock = function(params) {
    
		$(this).each(function() {
		  var s = $(this).extend({displayFormat:12,defaultHour:'12',defaultMinute:'00',defaultAM:'AM',seconds:false,defaultSeconds:'00'},params || {});
		  var clockTemplate  = '<div id="clock'+ (++clockNumber) +'">';
		  clockTemplate += '<select name="clockHours'+clockNumber+'" id="clockHours'+clockNumber+'" rel="'+clockNumber+'">';
		  for(var i = 1; i<=s.displayFormat;i++){
		    j = (i<10 ? ('0'+i) : i);
		    clockTemplate += '<option value="'+j+'"'+(j == s.defaultHour ? ' selected' : '')+'>'+j+'</option>';
		  }
		  clockTemplate += '</select>';        
		  clockTemplate += ':<select name="clockMinutes'+clockNumber+'" id="clockMinutes'+clockNumber+'" rel="'+clockNumber+'">';
		  for(var i = 0; i<60;i++){
		    j = (i<10 ? ('0'+i) : i);
		    clockTemplate += '<option value="'+j+'"'+(j == s.defaultMinute ? ' selected' : '')+'>'+j+'</option>';
		  }      
		  clockTemplate += '</select>';
		  if(s.seconds){
		    clockTemplate += ':<select name="clockSeconds'+clockNumber+'" id="clockSeconds'+clockNumber+'" rel="'+clockNumber+'">';
		    for(var i = 0; i<60;i++){
		      j = (i<10 ? ('0'+i) : i);
		      clockTemplate += '<option value="'+j+'"'+(j == s.defaultSeconds ? ' selected' : '')+'>'+j+'</option>';
		    }                    
		    clockTemplate += '</select>';
		  }
		  if(s.displayFormat == '12'){
		    clockTemplate += '&nbsp;<select name="clockAM'+clockNumber+'" id="clockAM'+clockNumber+'" rel="'+clockNumber+'">';
		    clockTemplate += '<option value="AM"'+(s.defaultAM == 'AM' ? ' selected' : '')+'>AM</option>';
		    clockTemplate += '<option value="PM"'+(s.defaultAM == 'PM' ? ' selected' : '')+'>PM</option>';
		    clockTemplate += '</select>';
		  }
		  clockTemplate += '</div>';            
		  var t = $(this);          
		  $(this).css({display:'none'});
		  $(this).after(clockTemplate);
		  calculateClockValue(t,s,clockNumber);
		  $('#clockHours'+clockNumber+', #clockMinutes'+clockNumber+', #clockSeconds'+clockNumber+', #clockAM'+clockNumber).change(function(from){
		    var num = $(this).attr('rel');
		    calculateClockValue(t,s,num);
		  });
		});
	
		function calculateClockValue(t,s,num){
		  var hour = $('#clockHours'+num).val();
		  var minutes = ':'+$('#clockMinutes'+num).val();
		  var sec = (s.seconds ? ':'+$('#clockSeconds'+num).val() : '');
		  var am = (s.displayFormat == '12' ? ' ' + $('#clockAM'+num).val() : '');                    
		  t.val(hour + minutes + sec + am);    
		}
	}
  
	// pre-submit callback 
	function showRequest(formData, jqForm, options) { 
	    // formData is an array; here we use $.param to convert it to a string to display it 
	    // but the form plugin does this for you automatically when it submits the data 
	    var queryString = $.param(formData); 
	 
	    // jqForm is a jQuery object encapsulating the form element.  To access the 
	    // DOM element for the form do this: 
	    // var formElement = jqForm[0]; 
	 
	    //alert('About to submit: \n\n' + queryString); 
		 $('#divRequired').html(queryString).show();
	    // here we could return false to prevent the form from being submitted; 
	    // returning anything other than false will allow the form submit to continue 
	    return false; 
	} 
	 
	//  alert($('div#content_container').css('height'));
	//  alert($('div#content_container').css('width'));
});


var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
function createDateSelect(dayfield, monthfield, yearfield){
	var today=new Date()
	var dayfield=document.getElementById(dayfield)
	var monthfield=document.getElementById(monthfield)
	var yearfield=document.getElementById(yearfield)
	for (var i=0; i<31; i++)
		dayfield.options[i]=new Option(i, i+1)
	dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
	for (var m=0; m<12; m++)
		monthfield.options[m]=new Option(monthtext[m], monthtext[m])
	monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
		var thisyear=today.getFullYear()
	for (var y=0; y<2; y++){
		yearfield.options[y]=new Option(thisyear, thisyear)
		thisyear+=1
	}
	yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}




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: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
