
	
	
	$(window).load(function() {
		$("#slider").nivoSlider({
			directionNav:false,
			controlNav:false
		});
	});
	
	$(document).ready(function() {
		setInterval("srollFeedBack()",2000);
		$("#StartAddress").focus(function(){
			if($(this).val() == "Enter Your Address"){
				$(this).val("").addClass("black");
			}
		});
		$("#StartAddress").blur(function(){
			if($(this).val().length == 0){
				$(this).val("Enter Your Address").removeClass("black");
			}
		});
		$("#feedback").click(function(){
			var def_title=$(this).attr("title");
			var d = modalShow($(this),600,330,{
				"Cancel": function(){
					$(this).dialog('close');
				},
				"Send": function(){
					console.log(d);
					d.parent().css("z-index","1000");
					d.dialog('option', 'title','Saving...');
					var f = d.find("form").serializeArray();
					$.getJSON('_save_post.php',f,function(r){
						if(r.res == 1){
							alert('Thank You!');
							d.dialog("close");
						}else{
							d.dialog('option', 'title',def_title);
							d.parent().css("z-index","1002");
							alert(r.msg);
						}
					});
				}
			});
			$.get('/_get_form.php',function(r){
				d.html(r);
			},"html");
			d.html("<i>Loading...</i>").dialog("open");
		});
		
	});
	function srollFeedBack(){
		var h = 0;
		$("#feedbacklist li").each(function(i){
			h += $(this).height()+24; 
		});
		if( h > $("#feedbacklist").height() ){
			$("#feedbacklist li").each(function(i){
				if(!$(this).hasClass("test")){
					$(this).slideUp("fast",function(){
						$($(this)).appendTo("#feedbacklist");
						$("#feedbacklist li:last").show();
					});
					return false;
				}
			});
		}
	}
	function modalShow(caller,width,height,buttons){
		var dlg = $("#dialog");
		dlg.dialog({
			modal: true,
			autoOpen: false,
			resizable: false
		}).dialog('option','height',height).dialog('option', 'width',width).dialog('option', 'buttons',buttons).dialog('option', 'title',caller.attr('title'));
		return dlg;
	}
	function detectMobile(){
		if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) { 
			document.location = "/m/"; 
		}
	}
