function writit(text, id) {
    if (document.getElementById)
    {
        x = document.getElementById(id);
        x.innerHTML = '';
        x.innerHTML = text;
    }
    else if (document.all)
    {
        x = document.all[id];
        x.innerHTML = text;
    }
    else if (document.layers)
    {
        x = document.layers[id];
        text2 = text;
        x.document.open();
        x.document.write(text2);
        x.document.close();
    }
}

function GetInputField(theform, theid) {

    thestr = "document.getElementById('" + theform + "')." + theid + ".value";
    val    = eval(thestr);
    return val;
}

function CheckInp() {

    theemail = GetInputField('downloaddemo', 'ddemail');
    lcase = theemail.toLowerCase();

    if( theemail.search('@') == -1 ) {          // Not found.   
        writit("Please provide a correct email address.", "ddmessage");
        return;
    }    

    if( theemail.search(' ') != -1 ) {       // Found.   
        writit("There's a space in your email address.<br>Please provide a correct email address.", "ddmessage");
        return;
    }    
    
    if( lcase.search('spam') != -1 ) {       // Found   
        ms =  "The email address you provided seems to be used to catch spam message only.<br>";
        ms += "Please provide a true email address. We are NOT going to send you spam and<br>";
        ms += "we guarantee that your email address isn't shared with anyone else.<br>";
        ms += "You may quit the newsletter mailing list when you have received the first newsletter.<br><br>";
        ms += "Please provide another email address.";
        writit(ms, "ddmessage");
        return;
    }    

    if( lcase.search(/pirat/) != -1 || 
        lcase.search(/paradox/) != -1 || 
        lcase.search(/warez/) != -1 || 
        lcase.search(/crack/) != -1 || 
        lcase.search(/pirac/) != -1 ||
        lcase.search(/\.al/) != -1 || 
        lcase.search(/\.am/) != -1 || 
        lcase.search(/\.az/) != -1 || 
        lcase.search(/\.ba/) != -1 || 
        lcase.search(/\.by/) != -1 ||
        lcase.search(/\.gh/) != -1 || 
        lcase.search(/\.hu/) != -1 || 
        lcase.search(/\.id/) != -1 || 
        lcase.search(/\.iq/) != -1 || 
        lcase.search(/\.ir/) != -1 || 
        lcase.search(/\.ke/) != -1 || 
        lcase.search(/\.kg/) != -1 || 
        lcase.search(/\.kz/) != -1 || 
        lcase.search(/\.mk/) != -1 || 
        lcase.search(/\.ng/) != -1 || 
        lcase.search(/\.pk/) != -1 ||
        lcase.search(/\.ro/) != -1 || 
        lcase.search(/\.ru/) != -1 || 
        lcase.search(/\.si/) != -1 || 
        lcase.search(/\.sk/) != -1 || 
        lcase.search(/\.tj/) != -1 || 
        lcase.search(/\.tr/) != -1 || 
        lcase.search(/\.ua/) != -1 || 
        lcase.search(/\.ug/) != -1 || 
        lcase.search(/\.uz/) != -1 || 
        lcase.search(/\.yu/) != -1 || 
        lcase.search(/\.zw/) != -1 ) {
	  waitawhile = 0;
	  for(count=0; count<500000; count++) {
		waitawhile += Math.pow(5,7);
        }
        ms =  "Failed to contact the email server.<br>The server seems to be down at the moment.<br>";
        ms += "Please try again later.<br>";
        writit(ms, "ddmessage");
        return;
    }
    
    window.location.href = "http://www.mhc.se/software/plugins/downloaddemoemail.php?ddemail=" + theemail; 
}  

