//---------------------------------------------------------------------------------
function changeMovie(_movie){
	var so = new SWFObject("image/"+_movie, "player_flash", "396", "297", "8", "#060C29");
	so.write("player");
}
//---------------------------------------------------------------------------------
function changeData(_country){
	switch(_country){
		case 'uk':
			document.getElementById('services').innerHTML = "<blockquote><h4>United Kingdom</h4><h3>Chester</h3><p>Sarah Bowyer<br />The Emigration Group</p><br /><p>7 Heritage Court<br />Lower Bridge Street<br />Chester CH1 1RD<p><br /><p>Tel: +44 8452 302 526</p><p>Fax: +44 1244 342 288</p><a href='http://www.emigrationgroup.co.uk/australia_index.php' target='_blank'>www.emigrationgroup.co.uk</a><br /><a href='mailto:info@tegltd.co.uk'>Email</a></p></blockquote>";
			break;
		case 'tehran':
			document.getElementById('services').innerHTML = "<blockquote><h4>Iran</h4><h3>Theran</h3><p>Dr Haghighi</p><p>Managing Director</p><br /><p>M.P.M</p><p>Mozhde Avaran Parvaz Mehr</p><p>Unit 4, No 128, Second floor</p><p>Naseri St Vali-e-asr Ave</p><p>Tehran IRAN</p><p>Telefax: +9821 88798608</p><p>Telefax: +9821 88789465</p><p><a href='mailto:info@litriran.com'>Email</a></p><p><a href='http://www.globalmaff.com' target='_blank'>www.globalmaff.com</a></p></blockquote>";
			break;
		case 'jakarta':
			document.getElementById('services').innerHTML = "<blockquote><h4>Indonesia</h4><h3>Jakarta</h3><p>Aleng Gunawan</p><p>Registered Migration Agent Number 01 04894</p><p><br />Tel: +62 21 634 0212</p><p>Jl Keutamaan Raya 84 Jakarta Barat Indonesia</p><p><a href='mailto:alain@pacific.net.id'>Email</a></p></blockquote>";
			break;
		case 'sydney':
			document.getElementById('services').innerHTML = "<blockquote style='padding:5px 5px 0px 5px;margin-bottom:8px;'><img src='image/about/foto.jpg' alt='Photo' /></blockquote>"+
															"<blockquote><h4>Australia</h4><h3>Sydney (Admin)</h3><p>Lisa Borshoff Cross</p><p>Registered Migration Agent</p><p>Number 00 05029</p><p><a href='mailto:lisa@businessmigration.com.au'>Email</a></p></blockquote>";														    
		break;
		case 'pretoria':
			document.getElementById('services').innerHTML = "<blockquote style='padding:5px 5px 0px 5px;margin-bottom:8px;'><img src='image/about/pretoria.jpg' alt='Photo' /></blockquote>"+
															"<blockquote><h4>South Africa</h4><h3>Pretoria</h3><p>Willem Van Rensburg<br />111 Cantonments Road<br/>Lyttelton Manor extension 1<br/>Centurion<br/>Pretoria</p><p><br />Tel: +27 12 664 6114</p><p>Cell: +27 82 772 7154</p><p><a href='mailto:willemvanrensburg@vodamail.co.za'>Email</a></p></blockquote>";
			break; 
		case 'perth':
			document.getElementById('services').innerHTML = "<blockquote style='padding:5px 5px 0px 5px;margin-bottom:8px;'><img src='image/about/foto.jpg' alt='Photo' /></blockquote>"+
															"<blockquote><h4>Australia</h4><h3>Perth (Head Office)</strong></h3>Florence Buegge Borshoff</p><p>JP BA FMIA</p><p>Registered Migration Agent</p><p>Number 92 55934</p><br /><p>PO Box 2226<br />Warwick, WA 6024</p><br /><p>134a Duffy Road, Carine WA</p><br /><p> Tel: +61 8 9448 8901<br />Fax: +61 8 9448 9273<br /><a href='mailto:&#102;&#098;&#098;&#064;&#098;&#117;&#115;&#105;&#110;&#101;&#115;&#115;&#109;&#105;&#103;&#114;&#097;&#116;&#105;&#111;&#110;&#046;&#099;&#111;&#109;&#046;&#097;&#117;'>Email</a></p></blockquote>";
			break;
	}
}
//---------------------------------------------------------------------------------
function isEmail(email)
{
	if(email.length < 6) {
		return false;
	}
	var x = 0;
	for (var c=0;c<email.length;c++) {
		if (email.substring(c,c+1) == '@') {
			x = c;
		}
	}
	var y = 0;
	if (x > 0) {
		for (c=x;c<email.length;c++) {
			if (email.substring(c,c+1)=='.') {
				y = c;
				var valida = 1;
			}
		}
		if (y > 0) {
			var dominio = '';
			for (c=x;c<y;c++) {
				dominio = dominio + email.substring(1,c);
			}
		}
	}
	else {
		return false;
	}					
	if (y <= x+2){
		return false;
	}				
	if (valida == 1){
		return true;
	}
}
//---------------------------------------------------------------------------------
nameError = 'Your Name!';
mailError = 'Your Email!';
friendError = 'Friend´s Name!';
friendemaildError = 'Friend´s Email!';
mesgError = 'Your Question!';
phoneError = "Your Phone Number!";
function showError(_obj, _text){
	_obj.focus();
	_obj.style.backgroundColor = '#FEEAD8';
	_obj.style.color = '#000000';
	_obj.value = _text;
}
function backError(_obj, _text){
	if(_text == mailError || _text == nameError || _text == mesgError || _text == friendError || _text == phoneError || _text == friendError || _text == friendemaildError){
		_obj.value = "";
		_obj.style.backgroundColor = '#FFFFFF';
		_obj.style.color = '#000000';
	}
}
//---------------------------------------------------------------------------------
function validContact(){
	retorno = true;
	path = document.getElementById('contact_form');
	if(path.nome.value == ""){
		showError(path.nome, nameError);
		retorno = false;
	}
	if(!isEmail(path.email.value)){
		showError(path.email, mailError);
		retorno = false;
	}
	if(path.mensagem.value == ""){
		showError(path.mensagem, mesgError);
		retorno = false;
	}
	if(retorno){
		path.submit();
	}
}


//---------------------------------------------------------------------------------
function validQuestion(){
	retorno = true;
	path = document.getElementById('question');
	if(!isEmail(path.email.value)){
		showError(path.email, mailError);
		retorno = false;
	}
	if(path.mensagem.value == ""){
		showError(path.mensagem, mesgError);
		retorno = false;
	}
	if(retorno){
		path.submit();
	}
}



//---------------------------------------------------------------------------------
function validWork(){
	retorno = true;
	path = document.getElementById('form_work');
	if(path.nome.value == ""){
		showError(path.nome, nameError);
		retorno = false;
	}
	if(!isEmail(path.email.value)){
		showError(path.email, mailError);
		retorno = false;
	}
	if(path.phone.value == ""){
		showError(path.phone, phoneError);
		retorno = false;
	}
	if(retorno){
		path.submit();
	}
}
//---------------------------------------------------------------------------------
function validAssessement(){
	retorno = true;
	path = document.getElementById('form_assessement');
	if(path.nome.value == ""){
		showError(path.nome, nameError);
		retorno = false;
	}
	if(!isEmail(path.email.value)){
		showError(path.email, mailError);
		retorno = false;
	}
	if(path.phone.value == ""){
		showError(path.phone, phoneError);
		retorno = false;
	}
	if(!retorno){
		location.href = "#";
	}else{
		path.submit();
	}
}
//---------------------------------------------------------------------------------
function menuOver(_obj){
	document.getElementById(_obj).style.color = '#FC8E29';
	document.getElementById(_obj).style.fontWeight = 'bold';
}
//---------------------------------------------------------------------------------
//Try to create the Http Request
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}
//---------------------------------------------------------------------------------
//Send Tell a Friend
function sendTell() {
	// Form validation
	hError = false;
	path = document.getElementById('tell_form');
	if(path.your_name.value == ""){
		showError(path.your_name, nameError);
		hError = true;
	}
	if(!isEmail(path.your_email.value)){
		showError(path.your_email, mailError);
		hError = true;
	}
	if(path.friends_name.value == ""){
		showError(path.friends_name, friendError);
		hError = true;
	}
	if(!isEmail(path.friends_email.value)){
		showError(path.friends_email, friendemaildError);
		hError = true;
	}
	if(hError){
		return false;
	}
	//-----------------------------------
	variables = '?name='+path.your_name.value+'&email='+path.your_email.value+'&friends_name='+path.friends_name.value+'&friends_email='+path.friends_email.value;
	document.getElementById("tell_friend").innerHTML = "<strong>Sending...</strong>";
	//-----------------------------------
	xmlhttp.open("GET", "send_tell.php"+variables,true);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
			vars = xmlhttp.responseText.split(";");
			if(vars[0] != "enviado"){
				document.getElementById("tell_friend").innerHTML =  "<h3>Tell a Friend</h3><hr />"+
																	"<p><strong>Sorry "+vars[1]+",</strong></p>"+
																	"<p>Something went wrong…<br /> Please try again in a little bit!</p><br />"+
																	"<p><a href='javascript:sendMore(\""+vars[1]+"\",\""+vars[2]+"\")'><img src='image/home/bt_try_again.gif' alt='Try Another' class='bt_submit' /></a></p>";	
			}else{
				document.getElementById("tell_friend").innerHTML = "<h3>Tell a Friend</h3><hr />"+
																   "<p>Thank you for telling your friend about us.</p><br />"+
																   "<a href='javascript:sendMore(\""+vars[1]+"\",\""+vars[2]+"\")'><img src='image/home/bt_tell_another.gif' alt='Another' /></a></p>";
			}
		}
    }
    xmlhttp.send(null)
}

function sendMore(nome, email){
	document.getElementById("tell_friend").innerHTML = "<h3>Tell a Friend</h3>"+
													   "<form id='tell_form'>"+
													   "<fieldset><hr />"+
													   "<div><label for='your_name'>Your Name:</label><input value='"+nome+"' onclick='backError(this, this.value)' class='form' id='your_name' style='width:122px;' /></div>"+
													   "<div><label for='your_email'>Your Email:</label><input value='"+email+"' onclick='backError(this, this.value)' class='form' id='your_email' style='width:122px;' /></div>"+
													   "<div><label for='friends_name'>Friend's Name:</label><input onclick='backError(this, this.value)' class='form' id='friends_name' style='width:122px;' /></div>"+
													   "<div><label for='friends_email'>Friend's Email:</label><input onclick='backError(this, this.value)' class='form' id='friends_email' style='width:122px;' /></div>"+
													   "<a href='javascript:;' onclick='sendTell()'><img src='image/home/bt_submit.gif' alt='Submit' class='bt_submit' /></a>"+
													   "</fieldset>"+
													   "</form>";
}
