var homewindow = window.parent.opener;

function mainwinfocus(url) {
	if (homewindow.closed == true)
		{
		homewindow = window.open(url);
		}
	else
		{
		homewindow.location = url;
		}
	homewindow.focus();	
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function hasIllegalCharacters(test_string, illegal_string)
{
    var is_illegal = false;
    var the_char = "";
    for (var loop=0; loop < illegal_string.length; loop++)
    {
        the_char = illegal_string.charAt(loop);
        if (test_string.indexOf(the_char) != -1)
        {
            is_illegal = true;
        }
    }
    return is_illegal;
}

function checkEmail(the_email)
{
    var the_at = the_email.indexOf("@");
    var the_dot = the_email.lastIndexOf(".");
    var a_space = the_email.indexOf(" ");
    var illegal_chars = "!#$%^&*()/:;,+";

    if ((the_at != -1) &&  // if there's an '@'
        (the_at != 0) &&  // and it's not at position 0
        (the_dot != -1) && // and there's a '.'
        (the_dot > the_at + 1) &&  // and something between the '@' and '.'
        (the_dot < the_email.length - 1) && // and something after the '.'
        (a_space  == -1) && // and there're no spaces
	(!hasIllegalCharacters(the_email, illegal_chars))) // and no illegal characters
    	{
        	    return true;
    	}  else {
        	    return false;
    	}
}

function docontact()
{
	var contact_window = window.open("http://www.clayalder.com/scr/index.php", "contact", "width=600,height=300,resizable,scrollbars");
	return true;
}