

//$(document).ready(function() { - removed to avoid conflict 
jQuery(document).ready(function($) {	

	$('.truncate').each(function() {
		
		var length = $(this).attr('length');
		
		if(length  == null || length == '')
			length = 100;
		
    	var stringLength = $(this).attr('strLn');
    	if(typeof stringLength !== 'undefined' && stringLength !== false)
    	{
    		length = stringLength;
    	}
		
		var trunc = $(this).text();
		if (trunc.length > length) {
		
		    /* Truncate the content of the P, then go back to the end of the
		       previous word to ensure that we don't truncate in the middle of
		       a word */
		    trunc = trunc.substring(0, length)+"...";
		    $(this).text(trunc);
		}
    });
	
	//Menubar
	$("ul.dropdown li").hover(function(){
	    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
    
    
	
	$("#sales").click(function () {
	    
		$('#rentSearch-container').hide();
		$('#salesSearch-container').show();
		
	});	
	
	$("#rentals").click(function () {
		
		$('#salesSearch-container').hide();
		$('#rentSearch-container').show();
		
	});
	
	
	
	$('.offsetcenter').offset({ top: 0, right: 100 });
	
	var cssObj = {
		      'font-style' : 'italic',
		      'color' : 'gray'
		    };
	$('#text1').css(cssObj);
	
	
	

});

//function handleSwitcher(value, elem)
//{
//	$('.active').removeClass('active').addClass('inactive');
//	$(elem).removeClass('inactive').addClass('active');
//	$('.slide').hide();
//	$('#'+value).show();
//}

function handleSearch(elem)
{
	if($(elem).val()=='Search')
	{
		$(elem).val("");
	}
		
}


//
//// page init
//function initNavFix() {
//	new touchNav({
//		navBlock: 'nav'
//	});
//}
//
//if (window.addEventListener) window.addEventListener("load", initNavFix, false);
//else if (window.attachEvent) window.attachEvent("onload", initNavFix);
//
//// navigation accesibility module
//function touchNav(options) {
//	this.options = {
//		mobileReg: /(ipad|iphone|ipod|android|blackberry|iemobile)/gi,
//		hoverClass: 'hover',
//		followLink: false,
//		menuItems: 'li',
//		menuOpener: 'a',
//		menuDrop: 'div',
//		navBlock: null
//	}
//	for(var p in options) {
//		this.options[p] = options[p];
//	}
//	this.init();
//}
//touchNav.prototype = {
//	init: function() {
//		this.isMobile = (this.options.mobileReg).test(navigator.userAgent);
//		if(typeof this.options.navBlock === 'string') {
//			this.menu = document.getElementById(this.options.navBlock);
//		} else if(typeof this.options.navBlock === 'object') {
//			this.menu = this.options.navBlock;
//		}
//		if(this.menu) {
//			this.getElements();
//			this.addEvents();
//		}
//	},
//	getElements: function() {
//		this.menuItems = this.menu.getElementsByTagName(this.options.menuItems);
//	},
//	hideActiveDropdown: function() {
//		if(this.activeParent) {
//			for(var i = 0; i < this.menuItems.length; i++) {
//				this.removeClass(this.menuItems[i], this.options.hoverClass);
//			}
//			this.activeParent = null;
//		}
//	},
//	getOpener: function(obj) {
//		for(var i = 0; i < obj.childNodes.length; i++) {
//			if(obj.childNodes[i].tagName && obj.childNodes[i].tagName.toLowerCase() == this.options.menuOpener.toLowerCase()) {
//				return obj.childNodes[i];
//			}
//		}
//		return false;
//	},
//	getDrop: function(obj) {
//		for(var i = 0; i < obj.childNodes.length; i++) {
//			if(obj.childNodes[i].tagName && obj.childNodes[i].tagName.toLowerCase() == this.options.menuDrop.toLowerCase()) {
//				return obj.childNodes[i];
//			}
//		}
//		return false;
//	},
//	addEvents: function() {
//		// mobile event handlers
//		if(this.isMobile) {
//			for(var i = 0; i < this.menuItems.length; i++) {
//				this.menuItems[i].touchNav = this;
//				if(this.getDrop(this.menuItems[i])) {
//					this.addHandler(this.getOpener(this.menuItems[i]), 'click', this.bind(this.clickHandler,this.menuItems[i]));
//				}
//			}
//			this.addHandler(document.body, 'click', this.bind(this.outsideHandler, this));
//			this.addHandler(document.body, 'touchstart', this.bind(this.outsideHandler, this));
//		}
//		// desktop event handlers
//		else {
//			for(var i = 0; i < this.menuItems.length; i++) {
//				this.menuItems[i].touchNav = this;
//				this.addHandler(this.menuItems[i], 'mouseover', this.mouseoverHandler);
//				this.addHandler(this.menuItems[i], 'mouseout', this.mouseoutHandler);
//			}
//		}
//	},
//	outsideHandler: function(e) {
//		var childFlag = false;
//		if(this.activeParent) {
//			this.outsideTarget = e.target || e.currentTarget || e.srcElement;
//			while (this.outsideTarget.parentNode) {
//				if(this.activeParent == this.outsideTarget) {
//					childFlag = true;
//					break;
//				}
//				this.outsideTarget = this.outsideTarget.parentNode;
//			}
//			if(!childFlag) {
//				this.hideActiveDropdown();
//			}
//		}
//	},
//	mouseoverHandler: function() {
//		this.touchNav.addClass(this, this.touchNav.options.hoverClass);
//	},
//	mouseoutHandler: function() {
//		this.touchNav.removeClass(this, this.touchNav.options.hoverClass);
//	},
//	clickHandler: function(e) {
//		// get current dropdown
//		var tNav = this.touchNav;
//		tNav.currentElement = e.currentTarget || e.srcElement;
//		tNav.currentParent = tNav.currentElement.parentNode;
//
//		// hide previous drop (if exists)
//		if(tNav.activeParent && !tNav.isParent(tNav.activeParent, tNav.currentParent) && tNav.currentParent != tNav.activeParent) {
//			tNav.hideActiveDropdown();
//		}
//
//		// handle current drop
//		if(tNav.hasClass(tNav.currentParent, tNav.options.hoverClass)) {
//			tNav.removeClass(tNav.currentParent, tNav.options.hoverClass);
//			if(tNav.options.followLink) {
//				window.location.href = tNav.currentElement.href;
//			}
//		} else {
//			tNav.addClass(tNav.currentParent, tNav.options.hoverClass);
//			tNav.activeParent = tNav.currentParent;
//			return tNav.preventEvent(e);
//		}
//	},
//	preventEvent: function(e) {
//		if(!e) e = window.event;
//		if(e.preventDefault) e.preventDefault();
//		if(e.stopPropagation) e.stopPropagation();
//		e.cancelBubble = true;
//		return false;
//	},
//	isParent: function(parent, child) {
//		while(child.parentNode) {
//			if(child.parentNode == parent) {
//				return true;
//			}
//			child = child.parentNode;
//		}
//		return false;
//	},
//	addHandler: function(object, event, handler) {
//		if (typeof object.addEventListener != 'undefined') object.addEventListener(event, this.bind(handler,object), false);
//		else if (typeof object.attachEvent != 'undefined') object.attachEvent('on' + event, this.bind(handler,object));
//	},
//	removeHandler: function(object, event, handler) {
//		if (typeof object.removeEventListener != 'undefined') object.removeEventListener(event, handler, false);
//		else if (typeof object.detachEvent != 'undefined') object.detachEvent('on' + event, handler);
//	},
//	hasClass: function(obj,cname) {
//		return (obj.className ? obj.className.match(new RegExp('(\\s|^)'+cname+'(\\s|$)')) : false);
//	},
//	addClass: function(obj,cname) {
//		if (!this.hasClass(obj,cname)) obj.className += " "+cname;
//	},
//	removeClass: function(obj,cname) {
//		if (this.hasClass(obj,cname)) obj.className=obj.className.replace(new RegExp('(\\s|^)'+cname+'(\\s|$)'),' ');
//	},
//	bind: function(func, scope){
//		return function() {
//			return func.apply(scope, arguments);
//		}
//	}
//}
