// JavaScript Document
<!--
//I take it you like some script here?... please give some credit to muftisays.com if you decide to use it on your site.

	var c=0;
	var d=140;
	var t;
	
	function loadQ(q_id){
		loadScript(scriptPath+'includes/js/getQ.php?q_id='+q_id);
	}
	
	function loadScript(scriptSrc){
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = scriptSrc;
		document.getElementsByTagName('head')[0].appendChild(script);
	}

	function openPreview(q_id){
		var frameQ = document.getElementById("qp"+q_id);
		frameQ.style.height = 'auto';
		frameQ.innerHTML = '<center><img src="'+scriptPath+'images/loading.gif" /></center>';
		
		loadQ(q_id);
		frameQ.style.display='block';
	}
	
	function closePreview(q_id){
		var frameQ = document.getElementById("qp"+q_id);
		
		d=d-20
		t=setTimeout("closePreview("+q_id+")",10)
		
		if(d<1){
			clearTimeout(t);
			frameQ.innerHTML  = '';
			frameQ.style.display='none';
			document.getElementById("imgPreview"+q_id).style.display = '';
			document.getElementById("imgHide"+q_id).style.display = 'none';
			frameQ.style.height = 'auto';
		}
		
		frameQ.style.height=d+'px';
		if(d==0){ d=140; }
	}
	
	function emailQ(q_id, securityCode, eTo, eName, eEmail){
		var eForm = document.getElementById('emailForm');
		//generate form
		var eHTML = '';
		eHTML = '<form action="" method="post" name="email_form" id="email_form"><table border="0" align="right" cellpadding="4" cellspacing="0"><tr><td class="hometh">Email Question</td></tr><tr><td class="hometd"><table width="100%" border="0" align="center" cellpadding="4" cellspacing="0"><tr><td align="right" class="gensmall" valign="top"><strong>To:</strong></td><td class="gensmall"><input name="to" type="text" id="to" value="'+eTo+'" /> (Friend\'s Email)<div id="recList" style="display: none;"></div></td></tr><tr><td align="right" class="gensmall"><strong>From:</strong></td><td class="gensmall"><input name="name" type="text" id="name" value="'+eName+'" /> (Your Name)</td></tr><tr><td align="right" class="gensmall"><strong>From:</strong></td><td class="gensmall"><input name="email" type="text" id="email" value="'+eEmail+'" /> (Your Email)</td></tr><tr><td align="right" valign="top" class="gensmall"><strong>Code:</strong></td><td class="gensmall">Please enter the following code: <strong>'+securityCode+'</strong><br /><input name="email_code" type="text" id="email_code" /> <input type="submit" name="Submit" value="Send &gt;&gt;&gt;" /><input name="emailq" type="hidden" id="emailq" value="true" /><input name="id" type="hidden" id="id" value="'+q_id+'" /><input name="the_code" type="hidden" id="the_code" value="'+securityCode+'" /></td></tr></table></td></tr></table></form>';
		eForm.innerHTML = eHTML;
		document.getElementById().focus;
	}
	
	function addRecipient(email){
		if(echeck(email)){
			var recList = document.getElementById('recList');
			if(recList.style.display == 'none'){ recList.style.display = ''; }
			
			var multiSend = document.getElementById('multiSend');
			if(multiSend.value){ multiSend.value = multiSend.value + '\n' + email; }
			else{ multiSend.value = email; }
			
			recList.innerHTML = recList.innerHTML + '<div id="recItem[]" title="Click to remove '+email+'" style="color: red; cursor: pointer;" onclick="removeEmail(\''+email+'\', this.id)">'+email+"<br /></div>";
			document.getElementById('to').value='';
		}
	}
	
	function removeEmail(email, listID){
		var d = document.getElementById('recList');
		var oldd = document.getElementById(listID);
		d.removeChild(oldd);
		
		var regExp = '/'+email+'\n/';
		var multiSend = document.getElementById('multiSend');
		var newList = multiSend.value;
		multiSend.value = newList.replace(email, '');
	}
	
	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}
	
	function stopScroll(marqID){
		document.getElementById(marqID).stop()
	}
	
	function startScroll(marqID){
		document.getElementById(marqID).start()
	}
	
	function doConfirm(confirmMsg, linkPage){
		if (confirm(confirmMsg)){
			location.href = linkPage;
		}
	}
	
	function highlight(divID){
		var d = document.getElementById(divID);
		d.style.fontWeight = 'bold';
		d.style.borderStyle = 'solid';
		d.style.borderWidth = '1px';
		d.style.paddingRight = '100px';
	}
	
	function unhighlight(divID){
		var d = document.getElementById(divID);
		d.style.fontWeight = 'normal';
		d.style.borderStyle = 'none';
	}
	
	function checkWin(){
		var goTo = document.getElementById('goTo');
	
		if(goTo.qID.value == ''){
			goTo.qID.style.border = 'solid 1px red';
		}
		else if(isNaN(goTo.qID.value)){
			alert('The Question field must contain a number as Question ID.');
			qID.select()
		}
		else if (goTo.tWin.checked == true){
			goTo.target = '_blank';
			goTo.submit()
		}
		else{
			goTo.target = '_self';
			goTo.submit()
		}
	}
	
	function doContrib(amount){
		var theError = document.getElementById('contribError');
		var theForm = document.getElementById('contrib');
		
		if(amount==''){ theError.innerHTML = 'Please enter a contribution amount.'; }
		else if(isNaN(amount)){ theError.innerHTML = 'Contribution amount must be a number'; }
		else if(amount < 2){ theError.innerHTML = 'Value must be 2 pounds or more'; }
		else{ theError.innerHTML = ''; theForm.submit(); }
	}
-->
