	function checkdownload(id_of_action, signUpActionId,parent_page, page_name){
		//alert('sdfsd');
	//	e = document.frmdownload.elements;
//		len = e.length;
		cfrmemail = document.frmdownload.Contact0Email;
		/*for(i=0; i<len; i++){
			if(trim(e[i].value) == ''){
				alert('Enter email address before clicking Submit.');
				e[i].focus();
				return false;
			}
		}
		*/
		
		
		if(checkemailadd(cfrmemail)){
			///JQuery Ajax Post data
			$('#btsubmit').attr('disabled', "disabled");
			
			strCfrmEmail = cfrmemail.value;//document.frmcfrm.Contact0Email.value;
			//$.post("test.php", { name: "John", time: "2pm" } );
			if(!parent_page) parent_page='';
			
			
			var myscript = document.createElement('script'); 
			myscript.setAttribute('src', 'http://sf.tradingadvantage.com/upsertlead.aspx?email='+strCfrmEmail+'&aid=TA.com&pid=Newsltr'); //&subid1=TA.com HP Webform
			myscript.setAttribute('id', 'sfscript');
			document.body.appendChild(myscript); 
			
			
			$.ajax({
			  url: "checkajax.php",
			  type: 'POST',
			  data: { apiEmail: strCfrmEmail, actionId: id_of_action, signUpId: signUpActionId ,page:parent_page, pageName:page_name },
			  success: function(data){
							if(data.contructor == 'fail') {
								alert('Sorry! The email address is not available');
								//msgErrorPrint("The email address you entered not found!");
								$('#btsubmit').disabled = false;
								$('#btsubmit').removeAttr('disabled');
								return false;
							}else{
								//alert('Added ' + data.errorcode);
								//msgErrorPrint("Email was resent.");
								//document.frmcfrm.target = '_parent';
								//document.frmcfrm.submit();
								
								lnkpg = data.errorcode;//$(this).attr('rel');
								if(ispopshow) {
							        $('.dialogBody iframe').attr({src: lnkpg});
							        return false;
							    }
								
								
								ifrmpg = '<iframe src='+lnkpg+' width="95%" height="95%" style="overflow: hidden;" scrolling="No"></iframe>';
								showWindow(ifrmpg, {hideCancelButton: false, title: 'Trading Advantage' }, 'Trading Advantage');
								//alert(data); return false;
								return false;
							}
						//alert('Email was resent.');
					},
			  dataType: "json",
			  async: false
			});
			
			/*$.post("checkajax.php", { apiEmail: strCfrmEmail, actionId: id_of_action, signUpId: signUpActionId ,page:parent_page},
				function(data){
					if(data.contructor == 'fail') {
						alert('Sorry! The email address is not available');
						//msgErrorPrint("The email address you entered not found!");
						$('#btsubmit').disabled = false;
						$('#btsubmit').removeAttr('disabled');
						return false;
					}else{
						//alert('Added ' + data.errorcode);
						//msgErrorPrint("Email was resent.");
						//document.frmcfrm.target = '_parent';
						//document.frmcfrm.submit();
						
						lnkpg = data.errorcode;//$(this).attr('rel');
						if(ispopshow) {
					        $('.dialogBody iframe').attr({src: lnkpg});
					        return false;
					    }
						
						
						ifrmpg = '<iframe src='+lnkpg+' width="95%" height="95%" style="overflow: hidden;" scrolling="No"></iframe>';
						showWindow(ifrmpg, {hideCancelButton: false, title: 'Trading Advantage' }, 'Trading Advantage');
						//alert(data); return false;
						return false;
					}
				//alert('Email was resent.');
			}, "json");*/
			
			return false;
		}
		return false;
	}

	function checkemailadd(emailadd){
		
		patern = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;///^([\w\-\.\+])+@+(([\w])+.+([.\w])+)$/; 
		if(!emailadd.value.match(patern)){
			alert("The email entered is invalid!");
			emailadd.focus();
			return false;
		}
		return true;
	}
	
	function trim(str) {
	     return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' '); 
	}
