
////////////////////////// N E W S L E T T E R ///////////////////////////////////////////////

	 /*
	  * Newsletter server path
	  */
	//nsPath='http://localhost/newsletter/';
	nsPath='http://www.1upbanners.com/newsletter/';
	
	 /*
	  * By this function we can meke the dynamic script tag
	  * By the dynamic script we can call any server side page instantly and execute that page
	  */
	function nsDynamicScript(src, id)
	{
		//Add the dynamic script into the head of the requested page.
		var registerScript=document.createElement("script");
		registerScript.src=nsPath+src;
		if(navigator.appName!='Microsoft Internet Explorer')
			registerScript.id=id;
		registerScript.type="text/javascript";
		registerScript.charset="utf-8";
		var head=document.getElementsByTagName("head")[0];
		head.appendChild(registerScript);
	}
	
	 /*
	  * After successfull request sending, delete the script tag, 
	  * not only the tag, all properties of the script tag will be
	  * delete from the memory to avoid the memory leak.
	  * in IE this removeChild doesn't work, fortunately an IE is instead of add a new script node,
	  * that replace the src property of the script.
	  */
	function nsDeleteScript(id)
	{
		var script;
		while(script=document.getElementById(id))
		{
			script.parentNode.removeChild(script);
			for(var prop in script)
			{
				delete script[prop];
			}
		}
	}
	
	 /*
	  * Newsletter form
	  */
	function newsletterForm()
	{
		document.write('<div><div id="nsActionReply" align="center">&nbsp;</div><br /><form name="newsletter" id="newsletter" action="" method="post"><span><label>First name*: </label><input type="text" name="ns_f_name" id="ns_f_name" maxlength="50" value=""/></span>&nbsp;<span><label>Last name*: </label><input type="text" name="ns_l_name" id="ns_l_name" maxlength="50" value=""/></span>&nbsp;<span><label>Email Id*: </label><input type="text" name="ns_email_id" id="ns_email_id" maxlength="100" value=""/></span>&nbsp;<span><input type="button" name="ns_subscribe" id="ns_subscribe" value="Subcribe" onclick="nsAction(document.newsletter.ns_f_name.value, document.newsletter.ns_l_name.value, document.newsletter.ns_email_id.value, true);"/></span><span><input type="button" name="ns_unsubscribe" id="ns_unsubscribe" value="Unsubscribe" onclick="nsAction(document.newsletter.ns_f_name.value, document.newsletter.ns_l_name.value, document.newsletter.ns_email_id.value, false);"/></span></form></div>');
	}
	
	 /*
	  * Newsletter action
	  */
	function nsAction(fname, lname, email, add)
	{
		if(fname=='' || lname=='' || email=='')
			alert("Fields marked with asterisks(*) are mandatory !");
		else
		{
			//var emailPat=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2, 4})$/;
			var emailPat=/^\w+([\._]?\w+)*@\w+([\._]?\w+)*(\.\w{2,3})+$/;
			if(emailPat.test(email))
			{
				var site='http://'+window.location.hostname;
				if(add)
					var action='add';
				else
					var action='remove';
				var to='action.php?jsonp=nsActionCallback&ele=nsActionReply&fname='+fname+'&lname='+lname+'&email='+email+'&site='+site+'&action='+action;
			
				nsDynamicScript(to, "nsActionJson");
				if(navigator.appName!='Microsoft Internet Explorer')
					nsDeleteScript("nsActionJson"); 
					//	window.location=  site + "/subscribe.php";
				
				document.getElementById("nsActionReply").innerHTML="Sending.....";
								
			}
			else
				alert("Invalid Email Id !");
		}
	}
	
	 /*
	  * Callback of newsletter action
	  */
	function nsActionCallback(result)
	{
		var nsReplyObj=eval('('+result+')');
		document.getElementById(nsReplyObj.ele).innerHTML=nsReplyObj.reply;
		
	}
	
	
	