function insertFlash(url, width, height)
{

    document.write('<object type="application/x-shockwave-flash" data="swf/localitzacio6.swf" width="600" height="400">');
    document.write('<param name="movie" value="swf/localitzacio6.swf" />');
    document.write('<param name="quality" value="high" />');
    document.write('</object>');
}




function sendSome()
{
    var usuario = "ies-montjuic";
    var dominio = "xtec";
    var extension = "cat";
    var subject = "Info";

    emailCod=(usuario + '@' + dominio + '.' + extension + "?" + "subject" + "=" + subject);
    emailLabel=(usuario + '@' + dominio + '.' + extension);
    document.write('<a href="mailto:' + emailCod + '">' + emailLabel + '</a>');
}


function validaEnviar()
{
    var n=true;
    var e1=true;
    var e2=true;    
/*    var m=true;*/
    
    n=validateField('nom1','msgerror','message','Si us plau, indica el teu nom', 'Si us plau indica el teu nom');
    e1=validateEmail('email1', 'msgerror','message','El correu indicat no \xE9s v\xE0lid', 'Si us plau, indica el teu correu');
    e2=validateEmail('email2', 'msgerror','message','El correu indicat no \xE9s v\xE0lid', 'Si us plau, indica el teu correu');
    /*m=validateTextarea('comentari', 'msgerror','message','Si us plau, indica un missatge', 'Si us plau, indica un missatge');    */
    
    if (n!=false) n=true;
    if (e1!=false) e1=true;
    if (e2!=false) e2=true;
/*    if (m!=false) m=true;*/
 
    
    if (n && e1 && e2) 
    {
        document.getElementById('formenviar').submit();
    }                 

}

function validateField(id,msgArea,msg,alertText,isError)
{
    field = document.getElementById(id);
    if(!check_field(field.value)){
        showMsg(msgArea, msg, alertText,isError);
        // change the color of text field
        field.style.borderColor = "red";
        field.focus();
        // make sure the form is not submitted
        return false;
    }
    else {
        return true;
    }
}

function validateEmail(id,msgArea,msg,alertText)
{
    // check the first email address ( the exclamation means "not" )
    field = document.getElementById (id);
    if(!check_email(field.value)){
        showMsg (msgArea,msg,alertText,true);
        // change the color of text field
        field.style.borderColor = "red";
        field.focus(); 
        // make sure the form is not submitted
        return false;
    }
    else {
        return true;
    }
}

function validateTextarea(id,msgArea,msg,alertText,isError)
{
    field = document.getElementById(id);
    if(!check_texta(field.value)){
    showMsg(msgArea, msg, alertText,isError);
    // change the color of text field
    field.style.borderColor = "red";
    field.focus();
    // make sure the form is not submitted
    return false;
    }
    else {
        return true;
    }
}

function check_texta(f)
{
    if (f) {
        var field = trim(f);
        if (field.length == 0) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}

function showMsg (msgArea, msg, msgText,isError)
{
    displayArea = document.getElementById (msgArea);
    displayElement =  document.getElementById (msg);
    displayArea.style.display = "";
    if (isError) {
        displayArea.style.backgroundColor="#FF6666";
    }
    else {
        displayArea.style.backgroundColor="#FFFF99";    
    }
    if (!isDOMCompliant) {
        alert (msgText);
    }
    else {
        
        changeElementText (displayElement,msgText);
        //document.location.href="#top";    
    }
}

function changeElementText (node,text) 
{
    while (node.hasChildNodes()) {
        node.removeChild(node.lastChild);
    }
    var textNode = document.createTextNode(text);
    node.appendChild(textNode );
}

function startList(){
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function check_field (f)
{
    var field = trim(f);
    if (field.length == 0) {
        return false;
    }
    else {
        return true;
    }
} 

function trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}

function isDOMCompliant ()
{
        return (document.getElementsByTagName && document.createElement);
}

function check_email (emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}

