$(function(){
var topper = 0;
 $(".btn_up").click(function(){
	if(topper<=-35){
	topper=topper+35;
		//alert('up : '+topper);
	$(".widget-body ul").css("margin-top",topper);
	}else{
	topper=topper;
		//alert('else up : '+topper);
	}
 })
 $(".btn_down").click(function(){
	if(topper>=-630){
	topper=topper-35;
	$(".widget-body ul").css("margin-top",topper);
		//alert('down : '+topper);
	}else{
		//alert('else down : '+topper);
	}
 })
})
$(function(){
	//$(".desc").show();
	$(".desc").animate({ opacity: 0.95,duration:500 }, 1 ); //Set Opacity
	$(".collapse").click(function(){
		$(".block").slideToggle();
		$(".collapse").toggleClass("show");
	});
	
});
$(function(){
	$(".warning p").hide();
	$("a.hide-warning").click(function(){
		$(".warning p").slideToggle(2000,function(){
		$("a.hide-warning").toggleClass("show-warning");
	});
	});
	$("a.hide-strip").click(function(){
		//$(this).hide();
		$(".warning").hide();
	})
	
});
$(function(){
	var fadeInTime = 700;
	$(".next").hide();
	$(".prev").hide();
	$("#sub-menu").hide();
	$("a.home").click(function(){
		$("#sub-menu").slideUp();
		$(".next").hide();
		$(".prev").hide();
	});
	$("a.drop").click(function(){
		$("#sub-menu").slideToggle();
		$(".next").hide().fadeIn(fadeInTime);
		$(".prev").hide().fadeIn(fadeInTime);
	});
	$("a.drop-port").click(function(){
		$("#sub-menu").slideToggle();
		$(".next").hide().fadeIn(fadeInTime);
		$(".prev").hide().fadeIn(fadeInTime);
	});
	$("a.mail").click(function(){
		$("#sub-menu").slideUp();
		$(".next").hide();
		$(".prev").hide();
	});
	$(window).bind( "hashchange", function(){
		var hash = location.hash;
		$("#nav a").each(function(){
			var that = $(this);
			that[ that.attr( "href" ) === hash ? "addClass" : "removeClass" ]( "selected" );
			document.title = " | alex-web | "+hash.substring(1,100).replace(/_/g," ")+" |";
		$(".next").hide().fadeIn(fadeInTime);
		$(".prev").hide().fadeIn(fadeInTime);
		});
		if (hash.substring(0,10)=="#portfolio"){
		//alert("hash : "+shash);
			$("#sub-menu").delay(350).slideDown();
		}
	})
	$(".next").click(function(){
		$(".next").hide().fadeIn(fadeInTime);
		$(".prev").hide().fadeIn(fadeInTime);
	})
	$(".prev").click(function(){
		$(".next").hide().fadeIn(fadeInTime);
		$(".prev").hide().fadeIn(fadeInTime);
	})

	$(window).trigger( "hashchange" );
})
$(function() {
	var i;
	//$.cookie("counter",setter);
	var setter = $.cookie("counter");
	if (setter==0){
		i=0;
	}else{
		i=2;
	}
	$(".wait").hide();
	$(".success").hide();
	$(".error").hide();
	$("#submit").click(function() {
		var hasError = false;
		var name = $("#name").val();
		var email = $("#email").val();
		var subject = $("#subject").val();
		var message = $("#message").val();
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var dataString = "name="+ name + "&email=" + email + "&message=" + message + "&subject=" + subject;
		if(name==""){
			$(".success").hide();
			$(".error").show().fadeOut(2000);
			hasError = true;
		}
		  if(message==""){
			$(".success").hide();
			$(".error").show().fadeOut(2000);
			hasError = true;
			}
		 if(email=="" || !emailReg.test(email)){
				$(".success").hide();
				$(".error").show().fadeOut(2000);
				hasError = true;
			}
			
		if (hasError == false && i>0 ){
			$.ajax({
				type: "POST",
				url: "email.php",
				data: dataString,
				success: function(){
					$(".success").show().fadeOut(2000);
					$(".error").hide();
					def_form_elements("#myForm");
					$(".LV_valid_field").removeClass();
					i=i-1;
				}
			});
		}else{
			$(".success").hide();
			$(".error").hide();
			$(".wait").show().fadeOut(7000);
			setter=0;
//			var date = new Date();
//			date.setTime(date.getTime() + (1 * 60 * 1000));
			$.cookie("counter",setter);
		}
		return false;
	});

});
$(function() {
	$(".smiley").click(function() {
		var name = $("#name").val();
		var email = $("#email").val();
		var subject = $("#sSubject").val();
		var message = $("#message").val();
		var face = $(this).attr("title");
		var dataString = "name="+ name + "&email=" + email + "&message=" + message + "&subject=" + subject + "&face=" + face;
		$.ajax({
			type: "GET",
			url: "join.php",
			data: dataString,
			success: function(){
				$(".success").show().fadeOut(2000);
				$(".error").hide();
			}
		});
		return false;
	});
});

function clear_form_elements(ele) {
    $(ele).find(":input").each(function() {
        switch(this.type) {
            case "password":
            case "select-multiple":
            case "select-one":
            case "text":
            case "textarea":
                $(this).val(" ");
                break;
            case "checkbox":
            case "radio":
                this.checked = false;
        }
    });

}
function def_form_elements(ele) {
    $(ele).find(":input").each(function() {
        switch(this.type) {
            case "text#name":
                $(this).val("anonymous");
                break;
            case "text#email":
                $(this).val("no@mail.com");
                break;
            case "textarea#message":
                $(this).val("");
                break;
        }
    });
}
$(function(){
	$("#name").click(function(){
		$(this).val("");
	})
	$("#email").click(function(){
		$(this).val("");
	})
	$("#message").click(function(){
		$(this).val("");
	})
})
/*
$(function(){
		var zIndexr = 990;
		var widgetAnimDur = 2700;
		var tabAnimDur = 2700;
		var widgetAnimDelay = 2700;
	$("#ff_fold-out").click(function(){
		//closer = "#mozilla";
		zIndexr = zIndexr+10;
		$(".firefox-widget").css("z-index",zIndexr);
		$("#firefox-tab").animate({
			opacity:"toggle"
			},
			{ duration:tabAnimDur }
		);
		$(".firefox-widget").fadeIn(tabAnimDur);
	});
	$("#stb_fold-out").click(function(){
		//closer = "#stumbleupon";
		var id="http://rss.stumbleupon.com/user/alexteq/favorites";
		var dataString = "id="+id;
		zIndexr = zIndexr+10; 
		$(".stumble-widget").css("z-index",zIndexr);
		$("#stumbleupon-tab").animate({
			opacity:"toggle"
		},
		{ duration:tabAnimDur });
		$.ajax({
			type: "POST",
			url: "stumble_upon.php",
			data: dataString,
			success: function(id){
				$(".stumble-widget").fadeIn(tabAnimDur).html(id);
			}
		});
		return false;
	})
	$("#firefox-tab span").click(function(){
		zIndexr = zIndexr+10; 
		$(".firefox-widget").css("z-index",zIndexr);
	})
	$("#stumbleupon-tab span").click(function(){
		zIndexr = zIndexr+10; 
		$(".stumble-widget").css("z-index",zIndexr);
	})
	$("#twitter-tab span").click(function(){
		zIndexr = zIndexr+10; 
		$(".twitter-widget").css("z-index",zIndexr);
	})
});
*/

$(function(){
/*	$("#stb_fold-out").click(function(){
		$(".btn_up").fadeIn(1000);
		$(".btn_down").fadeIn(1000);
		$(".throbber").fadeIn(1000);
		var id="http://rss.stumbleupon.com/user/alexteq/favorites";
		var dataString = "id="+id;
		$.ajax({
			type: "POST",
			url: "stumble_upon.php",
			data: dataString,
			success: function(id){
				$(".ticker").fadeIn(1000).html(id);
			}
		});
		return false;
	})
*/
	$("#twtr_fold-out").click(function(){
		$(".btn_up").fadeIn(1000);
		$(".btn_down").fadeIn(1000);
		$(".throbber").fadeIn(1000);
		//closer = "#twitter";
		var id="http://twitter.com/statuses/user_timeline/46364066.rss";
		var dataString = "id="+id;
/*		zIndexr = zIndexr+10; 
		$(".twitter-widget").css("z-index",zIndexr);
		$("#twitter-tab").animate({
			opacity:"toggle"
		},
		{ duration:tabAnimDur });
	*/	$.ajax({
			type: "POST",
			url: "twitter.php",
			data: dataString,
			success: function(id){
				$(".ticker").fadeIn(1000).html(id);
			}
		});
		return false;
	})

})
$(function(){
	$.localScroll.defaults.axis = "xy";
	// Scroll initially if there"s a hash (#something) in the url 
	$.localScroll.hash({
		target: "#panel", // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});
	$.localScroll({
		target: "#panel", // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The "this" is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});
});
$(function(){
	// Call stylesheet init so that all stylesheet changing functions 
	// will work.
	$.stylesheetInit();

	// This code loops through the stylesheets when you click the link with 
	// an ID of "toggler" below.
	$('#toggler').bind(
		'click',
		function(e){
		$.stylesheetToggle();
		return false;
	});
});