// JavaScript Document

var started = '';

var ended = '';



if(typeof(window.external) != 'undefined'){   // Catch IE

document.getElementsByName = function(name, tag){  // fix the function for them

    if(!tag){

        tag = '*';

    }

    var elems = document.getElementsByTagName(tag);

    var res = []

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

        att = elems[i].getAttribute('name');

        if(att == name) {

            res.push(elems[i]);

        }

    }

    return res;

}

}





function mouseover(){

	document.getElementById("submit_button").src='img/submit_down.png';

	

}



function mouseout(){

	document.getElementById("submit_button").src='img/submit_up.png';

}



function nav_mouseover(id){

	setTimeout('ani_step2(\''+id+'\')',175);

	document.getElementById(id).setAttribute("class", "box2");

	document.getElementById(id).setAttribute("className", "box2");

}



function nav_mouseout(id){

	document.getElementById(id).setAttribute("class", "box2");

	document.getElementById(id).setAttribute("className", "box2");

	setTimeout('ani_step1(\''+id+'\')',175);

}



function ani_step1(id){

	document.getElementById(id).setAttribute("class", "box1");

	document.getElementById(id).setAttribute("className", "box1");

}





function ani_step2(id){

	document.getElementById(id).setAttribute("class", "box3");

	document.getElementById(id).setAttribute("className", "box3");

}









function gsmover(){

	setTimeout('gs2()',175);

	document.getElementById('get-started').setAttribute("class", "gs-box2");

	document.getElementById('get-started').setAttribute("className", "gs-box2");

}



function gsmout(){

	document.getElementById('get-started').setAttribute("class", "gs-box2");

	document.getElementById('get-started').setAttribute("className", "gs-box2");

	setTimeout('gs1()',175);

}



function gs1(){

	document.getElementById('get-started').setAttribute("class", "gs-box1");

	document.getElementById('get-started').setAttribute("className", "gs-box1");

}





function gs2(){

	document.getElementById('get-started').setAttribute("class", "gs-box3");

	document.getElementById('get-started').setAttribute("className", "gs-box3");

}





/* subnavigation functions */

function subnav(id){

	var promos = document.getElementsByName("promotions");

	var arts = document.getElementsByName("articles");

	var rts = document.getElementsByName("recordingtips");

	

	document.getElementById("subnav-promotions").removeAttribute('style');

	document.getElementById("subnav-articles").removeAttribute('style');

	document.getElementById("subnav-recordingtips").removeAttribute('style');

	

	document.getElementById("subnav-promotions").style.display = '';

	document.getElementById("subnav-articles").style.display = '';

	document.getElementById("subnav-recordingtips").style.display = '';

	

	document.getElementById("subnav-promotions2").style.display = 'none';

	document.getElementById("subnav-articles2").style.display = 'none';

	document.getElementById("subnav-recordingtips2").style.display = 'none';

	

	switch(id){

		case "promotions":

				document.getElementById("subnav-promotions").src='img/subnav/promotions-over.png';

				document.getElementById('community-nav').style.display = "none";

				document.getElementById('community-nav-header').style.display = "none";

				document.getElementById('community-left').style.backgroundImage = "url(img/community_leftbar2.png)";

				promos[0].style.display = '';

				promos[0].removeAttribute('style');

				arts[0].style.display = 'none';

				rts[0].style.display = 'none';

				

				document.getElementById("subnav-promotions2").removeAttribute('style');

				document.getElementById("subnav-promotions2").style.display = '';

				document.getElementById("subnav-promotions").style.display = 'none';

				break;

		case "recordingtips":

				document.getElementById("subnav-recordingtips").src='img/subnav/recording-tips-over.png';

				document.getElementById('community-nav').style.display = "none";

				document.getElementById('community-nav-header').style.display = "none";

				document.getElementById('community-left').style.backgroundImage = "url(img/community_leftbar2.png)";

				rts[0].style.display = '';

				rts[0].removeAttribute('style');

				arts[0].style.display = 'none';

				promos[0].style.display = 'none';

				

				document.getElementById("subnav-recordingtips2").style.display = '';

				document.getElementById("subnav-recordingtips2").removeAttribute('style');

				document.getElementById("subnav-recordingtips").style.display = 'none';

				break;

		case "articles":

		default:

				document.getElementById("subnav-articles").src='img/subnav/articles-over.png';

				document.getElementById('community-nav').style.display = '';

				document.getElementById('community-nav').removeAttribute('style');

				document.getElementById('community-nav-header').style.display = '';

				document.getElementById('community-nav-header').removeAttribute('style');

				document.getElementById('community-left').style.backgroundImage = "url(img/community_leftbar.png)";

				arts[0].style.display = '';

				arts[0].removeAttribute('style');

				promos[0].style.display = 'none';

				rts[0].style.display = 'none';

				

				document.getElementById("subnav-articles2").removeAttribute('style');

				document.getElementById("subnav-articles2").style.display = '';

				document.getElementById("subnav-articles").style.display = 'none';

				break;				

	}

}



function subnav2(id){

	var tst = document.getElementsByName("testimonials");

	var ovr = document.getElementsByName("overview");

	var ins = document.getElementsByName("inspiration");

	var mix = document.getElementsByName("mixers");





	document.getElementById("subnav-inspiration").removeAttribute('style');

	document.getElementById("subnav-mixers").removeAttribute('style');

	document.getElementById("subnav-testimonials").removeAttribute('style');

	document.getElementById("subnav-overview").removeAttribute('style');

	

	document.getElementById("subnav-inspiration").style.display = '';

	document.getElementById("subnav-mixers").style.display = '';

	document.getElementById("subnav-testimonials").style.display = '';

	document.getElementById("subnav-overview").style.display = '';

	

	document.getElementById("subnav-inspiration2").style.display = 'none';

	document.getElementById("subnav-mixers2").style.display = 'none';

	document.getElementById("subnav-testimonials2").style.display = 'none';

	document.getElementById("subnav-overview2").style.display = 'none';

	

	

	switch(id){

		case "mixers":

				document.getElementById("brian").style.display = 'none';

				mix[0].style.display = '';

				mix[0].removeAttribute('style');

				ins[0].style.display = 'none';

				ovr[0].style.display = 'none';

				tst[0].style.display = 'none';

				

				document.getElementById("subnav-mixers2").removeAttribute('style');

				document.getElementById("subnav-mixers2").style.display = '';

				document.getElementById("subnav-mixers").style.display = 'none';

				break;

		case "overview":

				document.getElementById("brian").style.display = 'none';

				ovr[0].style.display = '';

				ovr[0].removeAttribute('style');

				ins[0].style.display = 'none';

				mix[0].style.display = 'none';

				tst[0].style.display = 'none';

				

				document.getElementById("subnav-overview2").removeAttribute('style');

				document.getElementById("subnav-overview2").style.display = '';

				document.getElementById("subnav-overview").style.display = 'none';

				break;

		case "inspiration":

				document.getElementById("brian").style.display = '';

				document.getElementById("brian").removeAttribute('style');

				ins[0].style.display = '';

				ins[0].removeAttribute('style');

				mix[0].style.display = 'none';

				ovr[0].style.display = 'none';

				tst[0].style.display = 'none';

				

				document.getElementById("subnav-inspiration2").removeAttribute('style');

				document.getElementById("subnav-inspiration2").style.display = '';

				document.getElementById("subnav-inspiration").style.display = 'none';

				break;

		case "testimonials":

		default:

				document.getElementById("brian").style.display = 'none';

				tst[0].style.display = '';

				tst[0].removeAttribute('style');

				ins[0].style.display = 'none';

				ovr[0].style.display = 'none';

				mix[0].style.display = 'none';

				

				document.getElementById("subnav-testimonials2").removeAttribute('style');

				document.getElementById("subnav-testimonials2").style.display = '';

				document.getElementById("subnav-testimonials").style.display = 'none';

				break;				

	}

}



function subnav3(id){

	var promos = document.getElementsByName("promotions");

	var rts = document.getElementsByName("rates");

	

	document.getElementById("subnav-promotions").removeAttribute('style');

	document.getElementById("subnav-rates").removeAttribute('style');

	

	document.getElementById("subnav-promotions").style.display = '';

	document.getElementById("subnav-rates").style.display = '';

	

	document.getElementById("subnav-promotions2").style.display = 'none';

	document.getElementById("subnav-rates2").style.display = 'none';

	

	switch(id){

		case "promotions":

				document.getElementById("subnav-promotions").src='img/subnav/promotions-over.png';

				promos[0].style.display = '';

				promos[0].removeAttribute('style');

				rts[0].style.display = 'none';

				

				document.getElementById("subnav-promotions2").removeAttribute('style');

				document.getElementById("subnav-promotions2").style.display = '';

				document.getElementById("subnav-promotions").style.display = 'none';

				break;

		case "rates":

				document.getElementById("subnav-rates").src='img/subnav/rates-over.png';

				rts[0].style.display = '';

				rts[0].removeAttribute('style');

				promos[0].style.display = 'none';

				

				document.getElementById("subnav-rates2").style.display = '';

				document.getElementById("subnav-rates2").removeAttribute('style');

				document.getElementById("subnav-rates").style.display = 'none';

				break;			

	}

}



var popUnderCode = "<div id='popunder' class='popunder'> </div>";

var popUpCode = "<div id='popup' class='popup'><img alt='Close' id='close' onclick='removeElements()' src='img/close.png' onmouseout='this.src=\"img/close.png\"' onmouseover='this.src=\"img/close-hover.png\"'/> <h3>Preparation Guidelines</h3><p>PREPARING YOUR TRACKS IS EASY.  We ask that you export separate .WAV files for each track in your recording session; if your recording session has 24 tracks, you will export 24 .WAV files.  Please name each track appropriately(i.e.: kick drum, snare drum, lead guitar etc.).  Most importantly, please export all of your tracks with the exact same starting point in your session.  This way, all of your tracks will line up when we work on your mix.</p><p>You need to decide if you are going to export with or without processing (reverb, EQ, compression, volume changes, automation, etc.).  We recommend that you export without processing and leave this to our creative mix engineers.  If there is a specific sound that you love, feel free to export that track with processing.  Once all tracks have been properly exported, place them in a folder named with the song title and zip the folder before uploading to our secure server.  If you have any problems with this process, please e-mail us at <a class='link' href='mailto:support@emixengine.com'>support@emixengine.com</a>.</p></div>";

var popped = false;

function showprep(){

	if(!popped){

		var div = document.createElement('div');

		div.innerHTML = popUnderCode;

		document.getElementById('get-started-main').appendChild(div.firstChild);	

		div.innerHTML = popUpCode;

		document.getElementById('get-started-main').appendChild(div.firstChild);

		popped = true;

	}else{

		removeElements();

	}

}



function removeElements(){

	  var child = document.getElementById('popunder');

	  var parent = document.getElementById('get-started-main');

	  parent.removeChild(child);

	  var child = document.getElementById('popup');

	  parent.removeChild(child);

	  popped = false;

}



var showtos = false;

var tosUnderCode = "<div id='tos-popunder' class='tos-popunder'> </div>";

var tosUpCode;

function cleanTOS(){

	  showHideMain('show')

	  var child = document.getElementById('tos-popunder');

	  var parent = document.getElementById('leftbar');

	  parent.removeChild(child);

	  var child = document.getElementById('tos-popup');

	  parent.removeChild(child);

	  showtos = false;

}



function showTOS(){

	if(!showtos){

		tosUpCode = "<div id='tos-popup' class='tos-popup'>" + document.getElementById('Terms').innerHTML + "</div>";

		showHideMain('hide');

		var div = document.createElement('div');

		div.innerHTML = tosUnderCode;

		document.getElementById('leftbar').appendChild(div.firstChild);	

		div.innerHTML = tosUpCode;

		document.getElementById('leftbar').appendChild(div.firstChild);

		showtos = true;

	}else{

		cleanTOS();

	}

}



function showHideMain(action){

	var elem = document.getElementsByTagName('div');

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

		if ((elem[i].className.indexOf("left") != -1)&&(elem[i].className.indexOf("main") != -1)){

			if(action == 'hide'){

				elem[i].style.visibility = "hidden";

			}else if(action =='show'){

				elem[i].style.visibility = "visible";

			}

		}else if(elem[i].className.indexOf("subnavigation") != -1){

			if(action == 'hide'){

				elem[i].style.visibility = "hidden";

			}else if(action =='show'){

				elem[i].style.visibility = "visible";

			}

		}

	}

}





/* Community Functions */



function artselect(id,max){

	for(x=0;x<max;x++){

		document.getElementById('art'+x).style.display = 'none';		

	}

	document.getElementById(id).style.display = '';	

	document.getElementById(id).removeAttribute('style');

}





/*  GET-STARTED-NOW FUNCTIONS */

var mix = true;

var mastering = false;

var mastonly = false;

var revision = false;

var promo = false;

var promocode = "";

var valid = false;

function select(item){

	if(item == "mastering"){

		mastering = true;

	}else if(item == "mix"){

		mix = true;

		hide_mastering_only();

	}else if(item == "revision"){

		revision = true;

	}

	calctotal();

}



function hide_mastering_only(){

	mastonly = false;

	mastering = true;

	//document.getElementById("mast1").style.display = '';             

	document.getElementById("mast1").style.display = 'none';

	document.getElementById("a2").style.display = ''; 

	document.getElementById("a2").removeAttribute('style');

}



function show_mastering_only(){

	mastonly = true;

	mastering = false;

	document.getElementById("mast1").style.display = ''; 

	document.getElementById("mast1").removeAttribute('style');

	document.getElementById("a1").style.display = 'none';

	document.getElementById("a2").style.display = 'none';

}



function deselect(item){

	if(item == "mastering"){

		mastering = false;

	}else if(item == "mix"){

		mix = false;

		show_mastering_only();

		if(revision){

			document.getElementById('b1').style.display = ''; 

			document.getElementById('b1').removeAttribute('style');

			document.getElementById('b2').style.display = 'none';

			deselect('revision');

		}

	}else if(item == "revision"){

		revision = false;

	}

	calctotal();

}





function mix_click(elem){

	if(!mix){

		document.getElementById('mix2').style.display = ''; 

		document.getElementById('mix2').removeAttribute('style');

		elem.style.display = 'none';

		select('mix');

	}else{

		document.getElementById('mix1').style.display = ''; 

		document.getElementById('mix1').removeAttribute('style');

		elem.style.display = 'none';

		deselect('mix');

	}

}



function mastering_click(elem){

		if(!mastering){

			document.getElementById('a2').style.display = ''; 

			document.getElementById('a2').removeAttribute('style');

			elem.style.display = 'none';

			select('mastering');

		}else if(mix){

			document.getElementById('a1').style.display = ''; 

			document.getElementById('a1').removeAttribute('style');

			elem.style.display = 'none';

			deselect('mastering');

		}

}



function revision_click(elem){

	if(mix){

		if(!revision){

			document.getElementById('b2').style.display = ''; 

			document.getElementById('b2').removeAttribute('style');

			elem.style.display = 'none';

			select('revision');

		}else{

			document.getElementById('b1').style.display = ''; 

			document.getElementById('b1').removeAttribute('style');

			elem.style.display = 'none';

			deselect('revision');

		}

	}

}



function validate(){

	var n = document.getElementById("name_f").value;

	var l = document.getElementById("name_l").value;

	var e = document.getElementById("mailaddress").value;

	//var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	

	valid = true;

	if(n.length < 2){

		valid = false;

	}

	if(l.length < 2){

		valid = false;

	}

	if(!checkEmail(e)){

		valid = false;

	}

	

	if(valid){

		document.getElementById("buynow").src = "img/buy-now.png";

		return true;

	}else{

		document.getElementById("buynow").src = "img/buy-now-grey.png";

		return false;

	}

}





function checkEmail(email) {

	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	return filter.test(email);

}



function validateEmail ( emailField, errorMsg ) {

 emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;

 if( !emailpat.test( emailField.value ) ) {

  alert( errorMsg);

  emailField.focus();

  emailField.select();

  return false;

 }

 return true;

}



function dosubmit(){

	if(validate()){

  		document.infoform.submit();

		//alert("Form Submitted");

		//location.href = url;

	}else{

		alert("Please fill in all mandatory fields");	

	}

}



/* Contact Form AJAX functions */

function contact_submit(){

	var n = document.getElementById("name").value;

	var m = document.getElementById("message").value;

	var e = document.getElementById("con-email").value;

	

	var good = true;

	if(n.length < 2) good = false;

	if(m.length < 5) good = false;

	if(!checkEmail(e)) good = false;

	

	if(good){

		var params = "name="+n+"&message="+m+"&email="+e;

		SubmitForm("email_help.php?"+params);

	}else{

		alert("Please ensure all fields are filled out correctly.");

	}

}



function SubmitForm(url){

	xmlhttp=null;

	if(window.XMLHttpRequest){

		xmlhttp=new XMLHttpRequest();

	}else if (window.ActiveXObject){

		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	}

	if (xmlhttp!=null){

		xmlhttp.onreadystatechange=form_reply;

		xmlhttp.open("GET",url,true);

		xmlhttp.send(null);

	}else{

		alert("Your browser does not support XMLHTTP.");

	}

}



function form_reply(){

	var res = document.getElementById("formResult");

	if (xmlhttp.readyState==4){

		if (xmlhttp.status==200){

			res.innerHTML = xmlhttp.responseText;

		}

	}

}







function sub_submit(){

	var e = document.getElementById("email").value;	

	var good = true;

	if(!checkEmail(e)) good = false;

	if(good){

		var params = "email="+e;

		SubmitEmail("email_subscribe.php?"+params);

	}else{

		alert("Please ensure all fields are filled out correctly.");

	}

}



function SubmitEmail(url){

	xmlhttp=null;

	if(window.XMLHttpRequest){

		xmlhttp=new XMLHttpRequest();

	}else if (window.ActiveXObject){

		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	}

	if (xmlhttp!=null){

		xmlhttp.onreadystatechange=get_reply;

		xmlhttp.open("GET",url,true);

		xmlhttp.send(null);

	}else{

		alert("Your browser does not support XMLHTTP.");

	}

}



function get_reply(){

	var res = document.getElementById("news-response");

	if (xmlhttp.readyState==4){

		if (xmlhttp.status==200){

			document.getElementById("news-text").innerHTML = "Newsletter Subscription";

			res.innerHTML = xmlhttp.responseText;

			// set cookie,and later check for it and replace_news()

			

		}

	}

}



function replace_news(){

	document.getElementById("news-text").innerHTML = "Newsletter Subscription";

	document.getElementById("news-response").innerHTML = "Subscription Successful";

}