// JavaScript Document
function bookmarksite(){
	obj_body=document.getElementById("showimage");
	obj_body.style.visibility='visible';
	
}

var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
var whitespace = " \t\n\r"
var reWhitespace = /^\s+$/
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{   // Is s empty?
    return (isEmpty(s) || reWhitespace.test(s));
}
function checkmail(e)
{
	return emailfilter.test(e.value);	
}

function validemailCheck (emailStr) {

var rv = '';
//return rv;

var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|COM|NET|ORG|EDU|INT|MIL)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
	rv = "Email address seems incorrect (check @ and .'s)";	
	return rv;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {

	if (user.charCodeAt(i)>127) {

		rv = "Ths username contains invalid characters.";
		return rv;
   	}	
}

for (i=0; i<domain.length; i++) {

	if (domain.charCodeAt(i)>127) {
		rv = "Ths domain name contains invalid characters.";
		return rv;
	}

}

// See if "user" is valid

if (user.match(userPat)==null) {
// user is not valid
	rv = "The username doesn't seem to be valid.";
	return rv;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);

if (IPArray!=null) {
// this is an IP address
	for (var i=1;i<=4;i++) {

		if (IPArray[i]>255) {
			rv = "Destination IP address is invalid!";
			return rv;
	   }
	}
	return rv;
}

// Domain is symbolic name.  Check if it's valid.

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;

for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
		rv = "The domain name does not seem to be valid.";
		return rv;
   }
}
/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {

	rv = "The address must end in a well-known domain or two letter " + "country.";
	return rv;

}
// Make sure there's a host name preceding the domain.

if (len<2) {
	rv = "This address is missing a hostname!";
	return rv;

}
// If we've gotten this far, everything's valid!

return rv;

}





var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
td_obj=document.getElementById("parade_msg");
td_obj.innerHTML="";
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"

}

function check_parade(obj)
{
	
	var msg_email='';
	msg_email=validemailCheck(obj.parade_email.value);
	
	if (msg_email!='') {
		alert(msg_email);
		obj.parade_email.focus()
		return false;
	}
	return true;
}

