function ns_validate(){
          /* if(Trim(jQuery('#ns_email').val()) == ""){
			   jQuery("#_nsmail_validation").html("<p style='color:red;width:250px'> Enter your e-mail</p>");
				jQuery("#_nsmail_validation").show();				
				jQuery('#ns_email').select();
				return false;
			}else{
			var filt=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/
							
				var m = jQuery('#ns_email').val();	
				
				var returnval=filt.test(m);
				jQuery("#_nsmail_validation").hide();
				jQuery('#ns_email').removeAttr("style");
				if (returnval==false){
					jQuery("#_nsmail_validation").html("<p style='color:red;'> Enter  valid e-mail</p>");
					jQuery("#_nsmail_validation").show();					
					jQuery('#ns_email').select();
					return false;
				}else {
				jQuery("#_mail_validation").hide();
				jQuery("#ns_email").removeAttr("style");
			   }
		   }	*/
		   return true;   
}
function LTrim(str)
{
  var whitespace = new String(" \t\n\r");
  var s = new String(str);
  if (whitespace.indexOf(s.charAt(0)) != -1) {
    var j=0, i = s.length;
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;
    s = s.substring(j, i);
  }
  return s;
}

function RTrim(str)
{
  var whitespace = new String(" \t\n\r");
  var s = new String(str);
  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    var i = s.length - 1;       // Get length of string
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;
    s = s.substring(0, i+1);
  }
  return s;
}

function Trim(str)
{
  return RTrim(LTrim(str));
}
var t;
$(function(){ 
	//$('.popup_promotion').floatingPosition('right', 'bottom');
	$(".popup_promotion").floating({targetX:"left", targetY:"bottom"});
	setTimeout("servingMLM()", 1000);
	  $("#ns_hp").keyup(function(){
				
				if(Trim(jQuery(this).val())!=""){
					var num=Trim(jQuery(this).val());
					 //$("#check_contact").html("");		
					var NumberToTest =num;
					var IsFound = /^-?\d+$/.test(NumberToTest);
					if(!IsFound){
						jQuery("#_nshp_validation").html("<span style='color:red;'>Enter Only Numbers</span>");
					    jQuery("#_nshp_validation").show();	
						//alert('only numbers');
						jQuery(this).val('');
						return false;
					} 
				}
			});	
     		   
     $('.ns_subscribe').click(function() {		
			    if(Trim(jQuery('#ns_email').val()) == ""){
				   jQuery("#_nsmail_validation").html("<span style='color:red;'> Enter Your E-mail</span>");
					jQuery("#_nsmail_validation").show();				
					jQuery('#ns_email').select();
					return false;
				}
				if(Trim(jQuery('#ns_hp').val()) == ""){
				   jQuery("#_nshp_validation").html("<span style='color:red;'> Enter Your HP</span>");
					jQuery("#_nshp_validation").show();				
					jQuery('#ns_hp').select();
					return false;
				}
				if(Trim(jQuery('#ns_email').val()) != ""){
				    var filt=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/								
					var m = jQuery('#ns_email').val();						
					var returnval=filt.test(m);
					jQuery("#_nsmail_validation").hide();
					jQuery('#ns_email').removeAttr("style");
					if (returnval==false){
						jQuery("#_nsmail_validation").html("<span style='color:red;'> Enter  valid e-mail</span>");
						jQuery("#_nsmail_validation").show();					
						jQuery('#ns_email').select();
						return false;
					}else {
					jQuery("#_mail_validation").hide();
					jQuery("#ns_email").removeAttr("style");
				   }
			   }							   
				var nspath=$('.ns_filepath').val();	
				jQuery.ajax({ 
					type: "POST",
					url: nspath+"php/news_subsribe_save.php",
					data: "nsemail="+jQuery("#ns_email").val()+"&nsname="+jQuery(".ns_name").val()+"&nshp="+jQuery("#ns_hp").val()+"&last_visit="+jQuery("#last_visit_subs").val(),
					cache: false, 
					beforeSend: function() {
						$.showAlert({message:"Processing..."});
					},
					complete: function() {
						$.hideAlert();
					},
					success: function(t) { 
						var tobj = eval("(" + t + ")");
						if(tobj.output==true) {
							jQuery("#ns_email").val('');
							jQuery(".ns_name").val('');$('#ns_hp').val('');
							$('._nsmail_validation,._nshp_validation').hide();
							jQuery(".subscribe_msg").html("<span style='color:green;'>Subscribed Successfully</span>").show();
						}else{
							jQuery(".subscribe_msg").html("<span style='color:red;'>Failed Try Again</span>").show();
						}
					},
					error:function(t){
					  alert(t);		
					}
			
				});
		});	
		$('ul#animated-portfolio').animatedinnerfade({
			speed: 1000,
			timeout: 5000,
			type: 'random',
			containerheight: '270px',
			containerwidth: '300px',
			animationSpeed: 5000,
			animationtype: 'fade',
			bgFrame: 'none',
			controlBox: 'none',
			displayTitle: 'none'
		});
		//jQuery("#close_popup").click(function() {
			//$("#animated-portfolio").toggle();
			$(".close_popup").toggle(function() {
				  $(".desc_image").hide();			 				 	
				  jQuery(".close_popup").html('<img src="./misc/css/newPlus.jpg"/>');
				  $(".popup_promotion").height("20px");
				  $(".popup_promotion").floatingPosition('right', 'bottom');
				  $(".popup_promotion").attr("location", "top");
				  clearTimeout(t);
			    }, function() { 
				  $(".desc_image").show();
				  t=setTimeout("servingMLM()", 100);
				  jQuery(".close_popup").html('<img src="./misc/css/newminus.jpg" />');
				  $(".popup_promotion").height("290px");
			  });				
		//});
	/*jQuery('.popup_promotion').mouseover(function(e) {
		$(".popup_promotion").floatingPosition('right', 'bottom');
		$(".popup_promotion").attr("location", "right");
      clearTimeout(t);
  	});
	jQuery('.popup_promotion').mouseout(function(e) {
      t=setTimeout("servingMLM()", 100);
		$(".popup_promotion").floatingPosition('right', 'bottom');
		$(".popup_promotion").attr("location", "right");
  	});*/
	 
});	
function servingMLM() { 
	/*jQuery('.popup_promotion').mouseover(function(t) { 
		$(".popup_promotion").floatingPosition('right', 'bottom');
		$(".popup_promotion").attr("location", "top");
       clearTimeout(t);
	    //t.stopPropagation();
  	});*/
	/*jQuery('.popup_promotion').mouseout(function(e) {
      t=setTimeout("servingMLM()", 100);
		$(".popup_promotion").floatingPosition('right', 'bottom');
		$(".popup_promotion").attr("location", "right");
  	});*/
	if($(".popup_promotion").attr("location")=='left') {
		$(".popup_promotion").floatingPosition('right', 'bottom');
		$(".popup_promotion").attr("location", "right");
	} else if($(".popup_promotion").attr("location")=='right') {
		$(".popup_promotion").floatingPosition('left', 'top');
		$(".popup_promotion").attr("location", "top");
	} else if($(".popup_promotion").attr("location")=='top') {
		$(".popup_promotion").floatingPosition('left', 'bottom');
		$(".popup_promotion").attr("location", "left");
	} else {
		$(".popup_promotion").floatingPosition('left', 'bottom');
		$(".popup_promotion").attr("location", "left");
	}
	t=setTimeout("servingMLM()", 10000);
}
