/*<![CDATA[*/
		   
//======= Window on load ==========//

$(window).load(function () {

	// --> init Top menu Animation
	$('ul#menu-top li:not(.selected)')
	.css( {backgroundPosition: "0 25px"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 50px)"}, 
			{duration:170})
	})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 25px)"}, 
			{duration:170})
	})
	// --> END Top menu Animation

	// --> init Scrollbars
	$('.scroll-pane').jScrollPane({showArrows:true, scrollbarWidth: 10, arrowSize: 10, animateTo:true});
	// --> END Scrollbars

	//-- Start Home page slider
	$('#Slide').innerfade({
		//animationtype: 'slide',
		animationtype: 'fade',
		speed: 1000,
		timeout: 5000,
		type: 'random_start',
		containerheight: '260px'
	});
	//-- END Home page slider
	
	// --> Removing the bottom border from the last child on the list
	$("ul#list-menu li:last, ul#team li:last").css({ border: "none" });
	
	// --> init gallery thumbnails fade animation
    $(".items a:not(.active)").hover(function() {
		$(this).animate({ opacity: 1 }, "fast" );
		},function() {
		$(this).animate({ opacity: 0.5 }, "fast" );
	});
	$(".items a").css({ opacity: 0.5 }, "fast" );
	$(".items a.active").css({ opacity: 1, border: "1px solid #F45813" }, "fast" );
		
						 
	// --> Team desc Window
	$('#col_e ul#team li div.txt h2 a, #col_e ul#team li div.img a').bind('click',function(){
		if ($(this).attr("class") == "desc") {
			$("#Desc-Panel").show("slow");
			return false;
		}
	});
	// --> END Team desc Window
	
	// --> Team desc Window Close buttons
	$("div#dscClose").click(function() {
		$("#Desc-Panel").hide("slow");
	});
	// --> END Team desc Window Close buttons
	
	// --> Team desc Content
	$('#col_e ul#team li div.txt h2 a').each(function(){
		$(this).click(function(){
			//$("#Desc-Panel").html('<img src='+$(this).attr('rev')+' alt='+$(this).attr('title')+' />');
			$("#Desc-Panel-content").html('<h2>'+$(this).html()+'</h2><h3>'+$(this).parent().next().html()+'</h3><br /><p>'+$(this).parent().parent().next().html()+'</p>');
		});
	});
	
	$('#col_e ul#team li div.img a').each(function(){
		$(this).click(function(){
			//$("#Desc-Panel").html('<img src='+$(this).attr('rev')+' alt='+$(this).attr('title')+' />');
			$("#Desc-Panel-content").html('<h2>'+$(this).parent().next().find('h2').text()+'</h2><h3>'+$(this).parent().next().find('h3').text()+'</h3><br /><p>'+$(this).parent().next().next().html()+'</p>');
		});
	});
	// --> END Team desc Content
	
	// --> Drag Desc Window
	$('#Desc-Panel').Drags({
		handler: '#Desc-Panel-move',
		onMove: function(e) {
		   // $('.content').html('Div Position:(Left:' + e.pageX + ' ,Top:' + e.pageY + ')');
		},
		onDrop:function(e){
		   $('#Desc-Panel').focus();
		}
	});
	// --> END Drag Desc Window

//-- Start Contact form
	var options = {
		beforeSubmit:  showRequest,  // pre-submit callback
		success:       showResponse,  // post-submit callback
		clearForm: true,        // clear all form fields after successful submit
		resetForm: true        // reset the form after successful submit
	};

	$('#contactForm').ajaxForm(options);
	
	$('#contactForm .btn').click(function() {
		$("#contactForm").submit();
	});
	//-- END Contact form



});
//=======END Window on load ==========//

//=======Init Jquery (on page load) ==========//

$(function () {
			
// Init Links with _blank target
function externalLinks() {
	if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
	if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}

externalLinks(); 
// END Links with _blank target

});

//=======Email Validation==========//
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}


// pre-submit callback
function showRequest(formData, jqForm, options) {

 var form = jqForm[0];

	if (!form.name.value) {
	
		$('.msg').fadeIn(500, removeMsg).html("<img class='png_bg' src='images/attention.png' width='16' height='16' alt='' /> Please Fill in your name.");
		form.name.focus();
		return false;
	}

	if (!echeck(form.email.value)) {
		$('.msg').fadeIn(500, removeMsg).html("<img class='png_bg' src='images/attention.png' width='16' height='16' alt='' /> Please fill in a valid Email address.");
		form.email.focus();
		return false;
	}

	if (!form.message.value) {
		$('.msg').fadeIn(500, removeMsg).html("<img class='png_bg' src='images/attention.png' width='16' height='16' alt='' /> Please write down your message to us.");
		form.message.focus();
		return false;
	}

	$('.msg').fadeIn(500).html("<img src='images/loadinfo.gif' width='16' height='16' alt='' /> Please wait, processing form...");
	$('#contactForm').slideUp();
}

// post-submit callback
function showResponse()  {
	$('.msg').fadeIn(500).html("<img class='png_bg' src='images/success.png' width='16' height='16' alt='' /> <strong>Message Sent Successfully!<\/strong><br \/>please allow up to 24 hours before one of our representatives gets back to you.");
}

// removing the status message with a 5sec timer activated
function removeMsg() {
	$('.msg').oneTime(4000,function() {
		$(this).fadeOut(500);
		//console.debug($('.msg').oneTime());
	});
}


//=======END Email Validation==========//

//=======END Init Jquery (on page load) ==========//

/*]]>*/
