$(function(){
	var section2open = false;
	
	
	//Separate Sections of JS out
	///-------------------   Utils -----------------------------------------------------//
	function addCommas(nStr)
		{
			nStr += '';
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return x1 + x2;
		}
	function parseNum(num)
	{
		//Num to string
		num = num+"";
		x = num.split('.');
		if(x[1] == "00") return x[0];
		if(x[1].substring(1,1) == "0") return x[0] + x[1].substring(0,1);
		else return x[0] + x[1];
	}
	
    
	

  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
	///-------------------   Featured Slideshow Block Section --------------------------//
	//Section Large Image Slideshow
	
	function FeaturedSlideShow_Init(){
		ResizeFeaturedSlideShow();	
	}
	
	function ResizeFeaturedSlideShow(){
		$("#supersized").height($(window).height()-40);
	}
	
	//$("#supersized").easyTooltip();
	/*$("#supersized").easyTooltip({
		tooltipId: "FeaturedShowTooltip",
		useElement: "tooltipcaption"
	});*/
	
	
	/*$('#scrolldownbut').click(function() {
		//calculate how far it needs to expand
		//blocks to fit width
		
	
			
			$('#s2expandingcontainer').animate({height: '260' }, 300, function(){
				$("#s2expandingcontainer").fadeTo(300, 1);
				$("#s2blockcontainer").fadeIn('fast');
				$("#block_container_viewmore").fadeIn('fast');
				$("#block_container_scrolldown").fadeOut('fast');
				$('#current_list_wrapper').fadeOut('fast');
				$('html,body').animate({scrollTop: ($('#s2expandingcontainer').offset().top-50)},2000);
			});
			section2open = true;
			
	});
	
	$(window).scroll(function(){
		if($(window).scrollTop() > 200 && section2open==false) {
			
			
			$('#s2expandingcontainer').animate({height: '260' },300 , function(){
				$("#s2expandingcontainer").fadeTo(300, 1);
				$("#s2blockcontainer").fadeIn('fast');
				$("#block_container_scrolldown").fadeOut('fast');
				$('#current_list_wrapper').fadeOut('fast');
				$("#block_container_viewmore").fadeIn('fast');
			});
			section2open = true;
		}
		if($(window).scrollTop() < 100 && section2open==true) {
			
			$('#s2expandingcontainer').animate({height: '40' },300 , function(){
				$("#block_container_scrolldown").fadeIn('fast');
				$('#current_list_wrapper').fadeOut('fast');
				$("#s2expandingcontainer").fadeTo(300, .6);
				$("#s2blockcontainer").fadeOut('fast');
				$("#block_container_viewmore").fadeOut('fast');
			});
			section2open=false
		}
	});*/
	///-------------------   Current Listings Slider Section --------------------------//
	//Section Current Listings Slider
	//Variables
	var allcurrentlistings;
	var filteredcurrentlistings;
	var filteredcurrentlistings_count = 0;
	var filteredcurrentListings_contentExpanded = false;
	var slider1;
	var sortType = "pdown";
	var propType = "0";
	var FeaturedToolTipTitle = "";
	var filteredcurrentListings_blocksNum = Math.floor( ($(window).width()-80) / $("div.block").width());
	var currentWidth = $(window).width();
	var currentHeight = $(window).height();
	var filteredcurrentlistingstotalheight = 0;
	
	function CurrentListings_Init(){
			//$('#current_list_wrapper').fadeOut(0);
			//$('#s2blockcontainer').fadeOut(0);
			$("#current_slider_wrapper").append("<img src='"+ ThemeHREF + "/images/darkloading.gif' id='currentloader' />");
			//$("#s2expandingcontainer").fadeTo(500, .6);
			//$("#s2expandingcontainer").height(40);
			LoadCurrentListings();
	}
	
	$('div.filter #proptype').jqDropDown({ effect: 'fade', effectSpeed: 300, modal: false, defaultOption: "Property Type", 
	
	optionChanged: function(propDD){
		
		propType = $("#proptype").val();
		//alert(propType);
		DisplayCurrentBlocks();
		//alert(propType);
		//ReloadCurrentListingsSlider();
		} });
	$('div.filter #sorttype').jqDropDown({ effect: 'fade', effectSpeed: 300, modal: false, defaultOption: "Sort Properties", 
	defaultStyle: false,
	containerName: 'ddContainerLong' ,  
	toggleBtnName: 'ddToggle', 
	optionListName: 'ddOptionList',
	optionChanged: function(sortDD){
		sortType = $("#sorttype").val();
		DisplayCurrentBlocks();
		//alert(sortType);
		//ReloadCurrentListingsSlider();
		} });
		
		
	// ascending order
    function SortByPriceAsc(x,y) {
      return x.Price - y.Price; 
    }
	
	function SortByPriceDesc(x,y) {
      return  y.Price - x.Price; 
    }
	function SortByBedsAsc(x,y) {
      return x.Bedrooms - y.Bedrooms; 
    }
	function SortByBedsDesc(x,y) {
      return y.Bedrooms - x.Bedrooms; 
    }
	
	function SortByBathsDesc(x,y) {
      return y.Bathrooms - x.Bathrooms; 
    }
	function SortBySqrftAsc(x,y) {
      return x.InteriorSize - y.InteriorSize; 
    }
	function SortBySqrftDesc(x,y) {
      return y.InteriorSize - x.InteriorSize; 
    }

    function SortByName(x,y) {
      return ((x.Name == y.Name) ? 0 : ((x.Name > y.Name) ? 1 : -1 ));
    }
	
	
	function FilterCurrentListings()
	{
		//Filter the current listings by listing type
		filteredcurrentlistings = [];
		if(propType != "0"){
			$.each(allcurrentlistings, function(k, v) { 
		 		$.each(v, function(key, value) { 
				//if(key=="TypeId" && value == 5 && propType == 2) alert("Week Lease");
					if(key=="TypeId" && propType == 2 && value == 5) filteredcurrentlistings.push(v);
					if(key=="TypeId" && value == propType) filteredcurrentlistings.push(v);
				});
			});
		} else {
			filteredcurrentlistings = allcurrentlistings;
		}
		
		//Sort the listings by their features
		switch(sortType){
			default:
		 case "pdown": filteredcurrentlistings.sort(SortByPriceDesc); break;
		 case "pup": filteredcurrentlistings.sort(SortByPriceAsc); break;
		 
		 case "bedown": filteredcurrentlistings.sort(SortByBedsDesc); break;
		 case "beup": filteredcurrentlistings.sort(SortByBedsAsc); break;
		 case "badown": filteredcurrentlistings.sort(SortByBathsDesc); break;
		 case "sqdown": filteredcurrentlistings.sort(SortBySqrftDesc); break;
		 case "squp": filteredcurrentlistings.sort(SortBySqrftAsc); break;
		}
		
		//Filter further by search criteria
		if($("#CurrentSearch").val() != "" && $("#CurrentSearch").val() != null && $("#CurrentSearch").val() != "Search"){
			var searcharr = [];
			$.each(filteredcurrentlistings, function(k, v) { 
				$.each(v, function(key, value) { 
					if(key=="Address"){
						//Break the Address into pieces
						arrvalue = value.toLowerCase().split(" ");
						//Check each one
						$.each(arrvalue, function(){
							if(this.substring(0, $("#CurrentSearch").val().length) == $("#CurrentSearch").val().toLowerCase()) searcharr.push(v);
						});
					}
					if(key=="City"){
						//Break the Address into pieces
						arrvalue = value.toLowerCase();//.split(" ");
						//Check each one
						//$.each(arrvalue, function(){
							if(arrvalue.substring(0, $("#CurrentSearch").val().length) == $("#CurrentSearch").val().toLowerCase()) searcharr.push(v);
						//});
					}
					
				});
			});
			
			filteredcurrentlistings = searcharr;
		}
		
	}
	
	//$('div.block_overlay').transify();
	$('#viewmorebut').click(function() {
		//calculate how far it needs to expand
		//blocks to fit width
		
		$('#current_list_wrapper').fadeOut('slow');
		$('#current_slider_wrapper').fadeOut('slow');
	  if(filteredcurrentListings_contentExpanded){
		  $('#s2expandingcontainer').animate({height: '260' }, 1000, function() {
			  filteredcurrentListings_contentExpanded = false;
			  $('#current_slider_wrapper').fadeIn('slow');
	  		  $('#viewmorebut').html("view more");
			  
			});
			
	  } else {
		  AnimateTotalHeight();
		 filteredcurrentListings_contentExpanded = true;  
		 $('#current_list_wrapper').fadeIn('slow');	
	  	$('#viewmorebut').html("view less");
	  }
	  $('#viewmorebut').slideto({
				target:"#s2blockcontainer",
				offsety: -60,
				speed  : 1500
			  });
	});
	
	function AnimateTotalHeight(){
		filteredcurrentListings_blocksNum = Math.floor( ($(window).width()-80) / $("div.block").width());
		//rows
		
		var rows = Math.ceil(filteredcurrentlistings_count / filteredcurrentListings_blocksNum);
		filteredcurrentlistingstotalheight = (($("div.block").height()) * (rows))+80;
		if(filteredcurrentlistingstotalheight < 200) filteredcurrentlistingstotalheight = 200;
		$('#s2expandingcontainer').animate({height: filteredcurrentlistingstotalheight }, 1000); 	
	}
	
	
	
	$('#clprev').click(function(){		slider1.goToPreviousSlide();		return false;	  });
	$('#clnext').click(function(){		slider1.goToNextSlide();		return false;	  });
	$('#CurrentSearch').keyup(function(){   DisplayCurrentBlocks(); });
	$('#CurrentSearch').click(function(){if($('#CurrentSearch').val() == "Search")$('#CurrentSearch').val("");});

			
	function ClearSlider(){
		//$('.bx-wrapper').remove();	
		$('#listingblocks1').remove();
		
		$('#current_slider_wrapper').append("<div id=\"listingblocks1\"></div>");
	}
			
	function StartCurrentListingsSlider(){
			
			if(!filteredcurrentListings_contentExpanded){
				var filteredcurrentListings_blocksNum =Math.floor( ($(window).width() -80) / $("div.block").width());
				try{
					if(slider1!=undefined)slider1.destroyShow();
				} catch(err)
				{ }
				slider1 = $('#listingblocks1').bxSlider({
						
						displaySlideQty:filteredcurrentListings_blocksNum,
						controls: false,
						hideControlOnEnd:true,
						infiniteLoop:false
						});
				$("#current_slider_wrapper  .bx-wrapper").center({
					vertical:false	
					
				});
				
				
				$("#currentloader").remove();
				//$("a").easyTooltip();
		}else
		{
			$("#currentloader").remove();
			//$("a").easyTooltip();
			
			AnimateTotalHeight();
			
		}
			}
			
	function CreateDarkListingBlock( Cipher, Address, City, State, Mailcode, Price, Beds, Baths, Interior, SmugThumbUrl, SmugSmallUrl, SmugMediumUrl )
			{
				//Clean the city for retrieval
				var cleancity = City.replace(/\//g,'*');
				cleancity = cleancity.replace(/ /g,'-');
				
				//Clean the address for retrieval
				var cleanaddress = Address.replace(/\//g,'*');
				cleanaddress = cleanaddress.replace(/ /g,'-');
				
				var href = ListingCurrentHREF+State.toLowerCase()+"/"+cleancity.toLowerCase()+"/"+Mailcode+"/"+ Cipher +"/"+cleanaddress+".htm";
				
				var BlockContent = '<div class="block">' + 
						'<a href="'+ href + '" title="Click to view: ' + Address + '" class="listing_linkwrapper"> ' +
						'<div class="listing_thumbwrapper"><a href="'+ href + '" title="Click to view: ' + Address + '"><img class="darklisting_thumb" src="' + SmugThumbUrl + '" /></a>' +
						'<div class="darklisting_extra">'+
						'<div class="darklisting_background"></div><div class="darklisting_info">'+Price+'</div>'+
						'</div></div>'+
						'<div class="darklisting_propinfo"><div class="listing_address">' + Address + '</div>' +
						'<div class="listing_city">' + City + '</div></div></a></div>';
				
				
				
				return BlockContent;
			}
			
			
	function DisplayCurrentBlocks()
	{
		$("#wrappedlistingblocks1").html('');
		$("#listingblocks1").html('');
		$("#S2Warning").fadeOut('slow');
		ClearSlider();
		FilterCurrentListings();
		filteredcurrentlistings_count = filteredcurrentlistings.length;
		if(filteredcurrentlistings_count > 0){
			for(var i=0; i < filteredcurrentlistings.length; i++){
				var cleanprice = (filteredcurrentlistings[i].Price==0)? filteredcurrentlistings[i].Price = "Call For Details": (filteredcurrentlistings[i].TypeId==2)? "$" + addCommas(filteredcurrentlistings[i].Price) + "/mo": (filteredcurrentlistings[i].TypeId==5)? "$" + addCommas(filteredcurrentlistings[i].Price) + "/wk" : "$" + addCommas(filteredcurrentlistings[i].Price);
				var block = CreateDarkListingBlock( 
					filteredcurrentlistings[i].CipherId,
					filteredcurrentlistings[i].Address, filteredcurrentlistings[i].City, 
					filteredcurrentlistings[i].State, filteredcurrentlistings[i].MailCode, cleanprice, 
					filteredcurrentlistings[i].Bedrooms, filteredcurrentlistings[i].Bathrooms, filteredcurrentlistings[i].InteriorSize, 
					filteredcurrentlistings[i].FeaturedThumb, filteredcurrentlistings[i].FeaturedSmall, filteredcurrentlistings[i].FeaturedMedium);
					
				
				$("#wrappedlistingblocks1").append(block);
				$("#listingblocks1").append(block);
			} 
			StartCurrentListingsSlider();
			//$("#wrappedlistingblocks1").center({
				//	vertical:false	
					
			//	});
			$("#block_container_controls").fadeIn('slow');
			if(filteredcurrentlistings_count > 8)$("#block_container_viewmore").fadeIn('slow'); else $("#block_container_viewmore").fadeOut('slow');
			
		
		
		}else {
					$("#S2Warning").fadeIn('slow');
					$("#block_container_viewmore").fadeOut('slow');
					$("#block_container_controls").fadeOut('slow');
		}
	}
			
	function LoadCurrentListings(){
				
		//clear current set
		
		$.ajax({
		   type: "POST",
		   url: JSONRetrievalURL+"?r="+UserId+"&t="+propType+"&s="+sortType,
		   success: function(msg){
			//Load into 
			allcurrentlistings = msg.Listings;
			DisplayCurrentBlocks();
			},
			dataType: "json"
		 }); 
	}
			

	
	///-------------------   Blog Post Slider Section ------------------------------//
	
	//Section for a Singular Blog Post
	//s3BlogPosts
	var slider2 = $('#s3BlogPosts').bxSlider({
						controls: false,
						mode: "fade",
						hideControlOnEnd:true,
						infiniteLoop:false
						});	
						
	$('#blogprev').click(function(){		slider2.goToPreviousSlide();		return false;	  });
	$('#blognext').click(function(){		slider2.goToNextSlide();		return false;	  });
	$('#OtherSearch').keyup(function(){  DisplayOtherBlocks(); });
	///-------------------   Other Listings Block Section --------------------------//
	//Section Other Listings Block
	//Variables
	var allotherlistings;
	var filteredotherlistings;
	var otherlistings_count = 0;
	var slider2;
	var otherListings_currentState = LocationRelevancy;
	//var otherListings_currentCity;
	var otherListings_maxrows = 5;
	
	function OtherListings_Init(){
			$("#s3wrappedblock").html("<img src='"+ ThemeHREF + "/images/liteloading.gif' id='otherloader' />");
			LoadOtherListings(); 
	}
	
	/*$('div.filter #filtercountry').jqDropDown({ effect: 'fade', effectSpeed: 300, modal: true, defaultOption: 'United States', defaultStyle: false ,
	optionChanged: function(){alert('option changed...');}, 
    containerName: 'ddLITEContainer' ,  
	toggleBtnName: 'ddLITEToggle' ,
	optionListName: 'ddLITEOptionList' });
	$('div.filter #filterstate').jqDropDown({ effect: 'fade', effectSpeed: 300, modal: false,  defaultOption: 'Select a State', defaultStyle: false ,
	optionChanged: function(){
		otherListings_currentState = $("#filterstate").val();
		DisplayOtherBlocks();
		}, 
    containerName: 'ddLITEContainer' ,  
	toggleBtnName: 'ddLITEToggle', 
	optionListName: 'ddLITEOptionList'  });
	$('div.filter #filtercity').jqDropDown({ effect: 'fade', effectSpeed: 300, modal: false,  defaultOption: 'Select a City', defaultStyle: false ,
	optionChanged: function(){
		otherListings_currentCity = $("#filtercity").val();
		DisplayOtherBlocks();
		}, 
    containerName: 'ddLITEContainer'  , 
	toggleBtnName: 'ddLITEToggle' ,
	optionListName: 'ddLITEOptionList'  });
	$('div.filter #filterarea').jqDropDown({ effect: 'fade', effectSpeed: 300, modal: true,  defaultOption: 'Select an Area', defaultStyle: false ,
	optionChanged: function(){alert('option changed...');}, 
    containerName: 'ddLITEContainer' ,  
	toggleBtnName: 'ddLITEToggle', 
	optionListName: 'ddLITEOptionList'  });*/
	
	
	function FilterOtherListings()
	{
		//Filter the current listings by listing type
		
		filteredotherlistings = [];
		if(otherListings_currentState != undefined){
			//alert(otherListings_currentState);
			$.each(allotherlistings, function(k, v) { 
		 		$.each(v, function(key, value) { 
					if(key=="State" && value == otherListings_currentState) filteredotherlistings.push(v);
				});
			});
		} else {
			filteredotherlistings = allotherlistings;
		}
		
		/*if(otherListings_currentCity != undefined){
			//alert(otherListings_currentCity);
			var cityfiltervar = [];
			$.each(filteredotherlistings, function(k, v) { 
		 		$.each(v, function(key, value) { 
					if(key=="City" && value == otherListings_currentCity) cityfiltervar.push(v);
				});
			});
			filteredotherlistings = cityfiltervar;
		}*/
		
		//Filter further by search criteria
		/*if($("#OtherSearch").val() != "" && $("#OtherSearch").val() != null){
			var searcharr = [];
			$.each(filteredotherlistings, function(k, v) { 
				$.each(v, function(key, value) { 
					if(key=="Address" && value.indexOf($("#OtherSearch").val()+"") > -1) searcharr.push(v);
				});
			});
			
			filteredotherlistings = searcharr;
		}*/
	}
	
	function ReloadOtherListingsSlider(){
		
		//LoadOtherListings()
		//slider1.destroyShow();
		//var blocksnum =Math.floor( $(window).width() / $("div.block").width());
		/*slider1 = $('#listingblocks1').bxSlider({
				displaySlideQty:blocksnum,
				controls: true,
				hideControlOnEnd:true,
				infiniteLoop:false
				});	*/
		
		
	}
			
	function StartOtherListingsSlider(){
			//$("a").easyTooltip();
			$("#s3wrappedblock").fadeIn();
			$("#otherloader").remove();
	}
		
	function CreateLiteListingBlock( Cipher, TypeId, Brief, Address, City, State, StateAbbr, Mailcode, Price, Beds, Baths, Interior, SmugThumbUrl, SmugMediumUrl )
	{
		//Clean the city for retrieval
		var cleancity = City.replace(/\//g,'*');
		cleancity = cleancity.replace(/ /g,'-');
		
		//Clean the address for retrieval
		var cleanaddress = Address.replace(/\//g,'*');
		cleanaddress = cleanaddress.replace(/ /g,'-');
		
		var href = ListingOtherHREF+State.toLowerCase()+"/"+cleancity.toLowerCase()+"/"+Mailcode+"/"+ Cipher +"/"+cleanaddress+".htm";
		//alert(Brief.length);
		if(Brief.length > 20) Brief = Brief.substring(0, 20) + "...";
		if(Brief =="" || Brief == undefined) { if(TypeId==4) { Brief = "Land";} else { Brief = parseNum(Beds) + " Bedrooms"; }};
		if(Address.length > 25) CleanAddress = Address.substring(0, 25) + "..."; else CleanAddress = Address;
		var BlockContent = '<div class="block">' + 
				'<a rel="nofollow" href="'+ href + '" title="Click to view: ' + Address + '" class="listing_linkwrapper"> ' +
				'<div class="listing_thumbwrapper"><a rel="nofollow" href="'+ href + '" title="Click to view: ' + Address + '" ><img class="litelisting_thumb" src="' + SmugThumbUrl + '"  /></a>' +
						'<div class="litelisting_extra">'+
						'<div class="litelisting_background"></div><div class="litelisting_info">'+Price+'</div>'+
						'</div></div>'+
				'<div class="litelisting_propinfo"><div class="listing_address">' + CleanAddress + '</div>' +
				'<div class="listing_city">' + City + ', ' + StateAbbr + '</div>' +
				
				'<div class="listing_brief">' + Brief + '</div></div>' +
				'</a></div>';
		return BlockContent;
	}
	
	function DisplayOtherBlocks()
	{
		
		$("#s3wrappedblock").html('');
		$("#s3wrappedblock").fadeOut(0);
		FilterOtherListings();
		
			otherlistings_count = filteredotherlistings.length;
		var col1height = $("#col1").height();
			var col2width = $("#col2").width();
			//alert(col1height + " : " + col2width);
			var rows = Math.floor(col1height / 180);
			var columns = Math.floor(col2width / 200);
			
			if(rows > otherListings_maxrows) rows = otherListings_maxrows;
			
			var availableblocks = rows * columns;
			$.shuffle(filteredotherlistings);
			//alert(rows);
			//alert(availableblocks);
			var i = 0;
			$.each(filteredotherlistings, function(){
				if(this.RegId != UserId){
				var cleanprice = (this.Price==0)? this.Price = "Call For Details": (this.TypeId==2)? "$" + addCommas(this.Price) + "/mo": (this.TypeId==5)? "$" + addCommas(this.Price) + "/wk":"$" + addCommas(this.Price);
				var block = CreateLiteListingBlock( 
				this.CipherId,
				this.TypeId,
				this.Brief,
						this.Address, this.City, this.State, this.StateAbbr, this.MailCode, 
						cleanprice, this.Bedrooms, this.Bathrooms, 
						this.InteriorSize, this.FeaturedThumb, this.FeaturedMedium);
				
				i++;  if(i>availableblocks) return;
				$("#s3wrappedblock").append(block);
				}
			});
			
		$("#s3wrappedblock").fadeIn("slow");
				StartOtherListingsSlider();
				
		
		//$("a").easyTooltip();

	}
			
	function LoadOtherListings()
	{
		
		
		var GetURL = JSONRetrievalURL+"?sid="+SiteID;
		/*if(otherListings_currentCity != ""){
			   GetURL += "&c="+otherListings_currentCity;
		   }
		 if(otherListings_currentState !=""){
			  GetURL += "&s="+otherListings_currentState;
		   }*/
		$.ajax({
		   type: "POST",
		   url: GetURL,		   
		   success: function(msg){
			 //  alert(msg);
			 //alert(msg.Listings);
			
			allotherlistings = msg.Listings;
			//alert(listingothercount);
			
			
			DisplayOtherBlocks();
			
			
			
		   },
			dataType: "json"
		 });
		
		
	}
			
			
			
			var delay = (function(){
			  var timer = 0;
			  return function(callback, ms){
				clearTimeout (timer);
				timer = setTimeout(callback, ms);
			  };
			})();
	//Global Functions	
			
	$(document).ready(function(){ 
		FeaturedSlideShow_Init();
		CurrentListings_Init();
		OtherListings_Init();
	});
	
	function resizebody(){
		//Get the scale of the browser based on the relative size of the the width -/+ 1920
		//if < than 1920 width
		var scale =  1 - (1920/$(window).width());
		
	 
		var el = 'body';
		setScale(el, scale);
	}
	
	function setScale(el, scale){
			$(el).css('transform','scale('+scale+')');
			$(el).css('-webkit-transform','scale('+scale+')');
			$(el).css('-webkit-transform-origin','0 0');
			$(el).css('-moz-transform','scale('+scale+')');
			$(el).css('-moz-transform-origin','0 0');
			$(el).css('-o-transform','scale('+scale+')');
			$(el).css('-o-transform-origin','0 0');
			$(el).css('-ms-transform','scale('+scale+')');
			$(el).css('-ms-transform-origin','0 0');
	}
	
	/*$(window).resize(function(){
		delay(function(){
			if(currentWidth != $(window).width() || currentHeight != $(window).height())
		  		//resizebody();
				window.location.reload();
		}, 500);
	});*/
				
	
				
	return false;  
				
});
