
window.addEvent('domready', function(){
	
	$('subscribe').setStyle('height','136px');
	if(gup('s') == '1')
	{ var mySlide = new Fx.Slide('subscribe').show(); }  //starts the panel in closed state  
	else
	{ var mySlide = new Fx.Slide('subscribe').hide(); }
    $('toggle_subscribe').addEvent('click', function(e){
						
		e = new Event(e);
		mySlide.toggle();
		if($$('subscribe_form') == false)
		{
			$('subscribe_content').innerHTML="<p>If you would like to hear more about the latest going-on at Something Interesting we would love to hear from you. Just fill in the form below with your name and e-mail address and we'll send you our monthly e-mail with all the latest news and gossip. Thank you.</p><form action=\"http://somethinginteresting.createsend.com/t/y/s/vurii/\" onSubmit=\"return ValidateForm()\" name=\"subscribe_form\" method=\"post\"><label for=\"name\">enter your name</label><input type=\"text\" name=\"cm-name\" id=\"name\" /><label for=\"vurii-vurii\">enter your email</label><input type=\"text\" name=\"cm-vurii-vurii\" id=\"vurii-vurii\" /><input type=\"submit\" class=\"submit_button\" value=\"\" /></form><br class=\"clear\" />";
		}
		e.stop();
	});

    if($('subscribe_close'))
		{$('subscribe_close').addEvent('click', function(e){
		e = new Event(e);
		mySlide.slideOut();
		
			$('subscribe_content').innerHTML="<p>If you would like to hear more about the latest going-on at Something Interesting we would love to hear from you. Just fill in the form below with your name and e-mail address and we'll send you our monthly e-mail with all the latest news and gossip. Thank you.</p><form action=\"http://somethinginteresting.createsend.com/t/y/s/vurii/\" onSubmit=\"return ValidateForm()\" name=\"subscribe_form\" method=\"post\"><label for=\"name\">enter your name</label><input type=\"text\" name=\"cm-name\" id=\"name\" /><label for=\"vurii-vurii\">enter your email</label><input type=\"text\" name=\"cm-vurii-vurii\" id=\"vurii-vurii\" /><input type=\"submit\" class=\"submit_button\" value=\"\" /></form><br class=\"clear\" />";
		
		e.stop();
	});
		}

});

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function validateemail(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function validateform(thisform)
{
with (thisform)
{
if (validateemail(cm-vurii-vurii,"Not a valid e-mail address!")==false)
  {cm-vurii-vurii.focus();return false;}
}
}
