function re_pictext(){
if (document.comp.pictext.value == ""){return;}
document.getElementById("bpic").innerHTML="<FONT SIZE=4 COLOR='" + document.comp.pictext_color.value + "' FACE='verdana,tahoma,arial'>" + document.comp.pictext.value + "</FONT>";


}
function re_clrs(){

if (document.comp.text_color.value == ""){return;}

if (document.layers){
        document.layers['tclr'].color = document.comp.text_color.value;
        document.layers['tclr'].bgColor = document.comp.back_color.value;
        }
    else if (document.all)
        {document.all['tclr'].style.color = document.comp.text_color.value;
        document.all['tclr'].style.background = document.comp.back_color.value;
        }
        
}
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){
		   
		   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 validate(){
var frm = document.comp;
if (frm.sender_name.value == "") {alert("Please enter your name in the form.");frm.sender_name.focus();return false;}
if (frm.sender_email.value == "") {alert("Please enter your email address in the form.");frm.sender_email.focus();return false;}
if (frm.recip_name.value == "") {alert("Please enter your recipient's name in the form.");frm.recip_name.focus();return false;}
if (frm.recip_email.value == "") {alert("Please enter your recipient's email address in the form.");frm.recip_email.focus();return false;}
if (frm.greeting.value == "") {alert("Please enter a greeting in the form.");frm.greeting.focus();return false;}
if (frm.the_message.value == "") {alert("Please enter a message in the form.");frm.the_message.focus();return false;}
if (frm.closing.value == "") {alert("Please enter a closing in the form.");frm.closing.focus();return false;}
if (echeck(frm.sender_email.value)==false){
alert("The address entered in the \"Your Email Address\" field does not appear to be a valid email address. Please correct this and try again.");
frm.sender_email.focus();
return false;
}
if (echeck(frm.recip_email.value)==false){
alert("The address entered in the \"Recipient\'s Email Address\" field does not appear to be a valid email address. Please correct this and try again.");
frm.recip_email.focus();
return false;
}
return true;



}

function resetfrm(){

document.sig.src="/white.jpg";
document.getElementById("tclr").style.backgroundColor = "#FFFFFF";
document.getElementById("tclr").style.color = "#000000";
document.comp.pictext.value=""
writepic(); 
}

function re_sig(){

if (document.comp.sig.value == ""){return;}
document.sig.src=document.comp.sig.value;

}

function re_picdim(){

document.getElementById("bpic").style.background = "url(" + picobj.src + ") no-repeat top center";
document.getElementById("bpic").style.width = picobj.width;
document.getElementById("bpic").style.height = picobj.height;
document.comp.pic_width.value=document.getElementById("bpic").style.width;
document.comp.pic_height.value=document.getElementById("bpic").style.height;
document.comp.pic_select.value=picobj.src;

}


function wait(){
  if ( picobj.width==0 || picobj.height==0 ) 
    setTimeout("wait()",500); 
  else 
    re_picdim(); 



} 

function choosec(page,evt){
var tp;
var lft;

if (evt.screenX > screen.availWidth/2){lft=evt.screenX-350} else {lft=evt.screenX};
if (evt.screenY > screen.availHeight/2){tp=evt.screenY-300} else {tp=evt.screenY};
wclr=window.open(page,"wclr","toolbar=0,location=0,directories=0,status=0,dependent=1,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=320,height=250,left="+lft+",top="+tp);

if (wclr.opener==null){wclr.opener=self;}

}
function createsig(){
var bg=document.comp.back_color.value;
var fg=document.comp.text_color.value;
if (bg == ""){bg="FFFFFF"};
if (fg == ""){fg="000000"};
var poop= window.open("","poop","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,WIDTH=500,height=300");
poop.document.write('<HTML><BODY BGCOLOR="#ffffc0"><FONT SIZE=2 COLOR="#1B86BA" FACE="tahoma,arial,verdana"><B>Using your mouse, click and hold the left button and write your signature in the rectangle below.</B></FONT><BR><BR>');
poop.document.write('<center>');
poop.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="400" height="200" id="draw-jpeg" align="middle">');
poop.document.write('<param name="allowScriptAccess" value="sameDomain" />');
poop.document.write('<param name="movie" value="draw-jpeg.swf" />');
poop.document.write('<param name="quality" value="best" />');
poop.document.write('<param name="bgcolor" value="' + bg + '" />');
poop.document.write('<PARAM NAME=FlashVars VALUE="bgc=' + bg + '&fgc=' + fg + '">');
poop.document.write('<embed src="draw-jpeg.swf" quality="best" bgcolor="' + bg + '" width="400" height="200" name="draw-jpeg" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="bgc=' + bg + '&fgc=' + fg + '" />');
poop.document.write('</object>');
poop.document.write('</center>');
poop.document.write('</body>');
poop.document.write('</html>');
poop.document.close();
}

function writepic(){
document.comp.pictext.value=document.comp.pictext_tmp.value;
var taln;
var valn;
var tfont;
if (document.comp.ffont[0].checked==true){tfont="verdana"};
if (document.comp.ffont[1].checked==true){tfont="comic sans ms"};
if (document.comp.ffont[2].checked==true){tfont="georgia"};
if (document.comp.talign[0].checked==true){taln="center"};
if (document.comp.talign[1].checked==true){taln="left"};
if (document.comp.talign[2].checked==true){taln="right"};
if (document.comp.tvalign[0].checked==true){valn="top"};
if (document.comp.tvalign[1].checked==true){valn="bottom"};
document.comp.pictext_align.value = taln;
document.comp.pictext_valign.value = valn;
document.comp.pictext_font.value = tfont;
document.getElementById("bpic").style.textAlign = taln;
document.getElementById("bpic").style.verticalAlign = valn;
document.getElementById("bpic").style.fontFamily = tfont;
document.getElementById("bpic").style.fontSize = "20px";
document.getElementById("bpic").style.color = document.comp.pictext_color.value;
document.getElementById("bpic").innerHTML="<p style='padding:15px'>" + document.comp.pictext.value + "</p>";
}

