// JavaScript Document
$(document).ready(function(){ 
        $("ul.sf-menu").supersubs({ 
            minWidth:    6,   // minimum width of sub-menus in em units 
            maxWidth:    20,   // maximum width of sub-menus in em units 
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish({autoArrows:true});  // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason. 
						 
		//$('.scroll-pane').jScrollPane({scrollbarWidth:10,showArrows:false});
		
		//$('newsimage').click(function(){
		//		var img = $(this).attr("name");
		//		
		//});
		/*$('.pics').cycle({
			fx: 'fade',
			timeout: 3000,	
			delay:  0, 
			speed:  1500,
			random: true
		});
		*/
		//$('hr').attr("noshade","noshade");

}); 


function toggleP(me,target) {
	$("#"+me).hide();	
	$("#"+target).fadeIn("slow");	
}

function subscribe(){
	
	var ok = "";
	var email = $("#subscribe_email").val();
	var name = $("#subscribe_name").val();
	//var sname = $("#subscribe_sname").val();
	var source = $("#subscribe_source").val();
	var pid = $("#subscribe_pid").val();
	ok += email == "" ? "<li>Email address</li>" : "";
	ok += email != "" && !isEmail2(email) ? "<li>Check email format</li>" : "";
	ok += name == "" ? "<li>Name</li>" : "";
	//ok += sname == "" ? "<li>surname</li>" : "";
	
	if(ok.length == 0){
		$.ajax({
			method: "get",url: "subscribe.php",data: "email="+escape(email)+"&name="+escape(name)+"&source="+escape(source)+"&pid="+escape(pid),
			success: function(html){ //so, if data is retrieved, store it in html
				$("#keepintouch").html("Thank you for subscribing"); //show the html inside .content div
				return false;
			 }
		 }); //close $.ajax(
	} else {
		$("#sub_warning").html("Please complete your<ul>"+ok+"</ul>");
		$("#sub_warning").show("slow");
	}
	return false;
 } 
 
 function isEmail2(who) {
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(who));
}

