// JavaScript Document



			var _user = '_';
			var _pass = '_'
			var _artist = '_'
			var _website = '_'
			var _location = '_'
			var startSection = 'accountSettings'; 
			var currLayer = "#layer1";

function fade(){
	alert("got to fade" +  currLayer);
 $(currLayer).animate({
				 opacity: .5
				},1500)	
}
function changeBg(url){
		//alert("bgChange");
		//alert(url);
		
		if(currLayer == "#layer1"){
			currLayer="#layer2";
			$("#layer2").html('<img class="bgImg" onload="fade()" src="'+url+'"  /> ');
			
				$("#layer1").animate({
				 opacity: 0
				},2000)
				
				/*
				$("#layer2").animate({
				 opacity: 0.4
				},700)
			*/
		}else{
			 currLayer="#layer1";
			$("#layer1").html('<img class="bgImg" onload="fade()"  src="'+url+'"  /> ');
			$("#layer2").animate({
				 opacity: 0
				},2000)
				
				/*
				$("#layer1").animate({
				 opacity: 0.4
				},700)
					*/
		 }
		/*$(currLayer).animate({
				 opacity: 0
				 
		},700, function(){ 
				 
				  
		}); */
		
		
	}	
	
	
function confrimUpload(term){
				if(term == 'yes'){  
					document.getElementById("flashapp").acceptedTerms(); 
					
					loadHtml("donationAsk.html");
					$("#submit").hide();
				}else{
					//document.getElementById('data_Hldr').style.visibility = 'hidden'; 
					//document.getElementById('data_Hldr').style.display = 'none';
					$("#swf_content").css('visibility', 'visible');
					 $("#bg").css('visibility', 'visible');
					 $("#data_Hldr").css('visibility', 'hidden');
					$("#data_Hldr").hide(); 
					
				}
				
				
}
			
function gotoUpload(){
				////alert($('#myMusic'));
				//document.getElementById("flashapp").showApp();
				$("#swf_myTracks").hide();
				//$("#swf_contact").hide();
				$("#swf_content").css('visibility', 'visible'); 
				document.getElementById('flashapp').changeView('upload'); 
				 closeAll();
}
function gotoPlayer(){ 
				$("#swf_myTracks").hide();
				//$("#swf_contact").hide();
				$("#swf_content").css('visibility', 'visible'); 
				document.getElementById('flashapp').changeView('listen'); 
				 
				 closeAll();
}
			
function gotoLogin(){ 
				$("#swf_myTracks").hide();
				//$("#swf_contact").hide();
				$("#swf_content").css('visibility', 'visible'); 
				document.getElementById('flashapp').changeView('login'); 
				 closeAll();
}  
			
function loggedIn(userPublic, user, pass, id, artist, website, location){
			 	 
				_user = user;
				_pass = pass;
				_artist = artist;
				_website = website;
				_location = location 
				 
				document.getElementById('loginVerification').style.visibility = 'visible';
				document.getElementById("loginVerification").style.display = 'block'; 
			 	document.getElementById("loginVerification").innerHTML = "You're logged in " + userPublic ;
				//alert("$  " +$setCookies);
				//$setCookies(user, pass, id, artist, website, location);
				//MAIN SWF
				document.getElementById('flashapp').loginExternal(user, pass, id, artist, website, location);
				//ADD IP 11/5/09 
				//VISITOR TRACKING
				$.post("mediator.php?do=loggedIn&JSON=true", {user:_user},
				  function(data){
				//	alert('logged in response ' + data['response']);
				  }, "json"); 
				
			
				
				
}
			
			
			
			
function  loginUser(user, pass, id, artist, website, location){
				 _user = user;
				 _pass = pass;
				 _artist = artist;
				 _website = website;
				 _location = location 
			 document.getElementById("flashapp").loginMyTracks(user, pass, id, artist, website, location); 
				 
}
			
function showLoader(on){
				/*
				if(on == 1){
					  
				//$(loadingFlash).text( "loading ...");	 
				
				$('#loadingHolder').animate({ 
					opacity: 1
										 },
					300);
				
				 $('#loadingHolder').animate({
					left:'1500px',
					opacity: 0
										 },
					900, function(){
						$('#loadingHolder').css('left', '0%');
					$('#loadingHolder').css('opacity', '0');
			$('#loadingHolder').css('filter', 'alpha(opacity=0)');	
					});
					
		 
			 //centerObject("loadingHolder", 227, 67);
				}else{
					 
			//	 $('#loadingHolder').remove();	
					
				}*/
			}
			function goMyMusic(){
				showLoader(1);
				startSection = 'accountSettings';  
				//$("#swf_contact").hide();
				//$("#swf_content").css('visibility', 'hidden');
				//$("#swf_myTracks").show();
				//MAIN SWF
				document.getElementById('flashapp').changeView('myAccount'); 
				
				
				
			} 
			
			function goContact(){
				startSection = 'contact';  
				//$("#swf_contact").hide();
				//$("#swf_content").css('visibility', 'hidden');
				//$("#swf_myTracks").show();
				//MAIN SWF
				document.getElementById('flashapp').changeView('contact'); 
					
			}
			function goMyUploads(){
				showLoader(1);
				startSection = 'uploads';  
				//$("#swf_contact").hide();
				//$("#swf_content").css('visibility', 'hidden');
				//$("#swf_myTracks").show();
				//MAIN SWF
				document.getElementById('flashapp').changeView('myAccount');  
				
			} 
			
			function goFAQ(){ 
				showLoader(1);
				startSection = 'faq';
				//$("#swf_myTracks").show();
				//$("#swf_content").css('visibility', 'hidden');
 
				//$("#swf_contact").hide();
				//MAIN SWF
				document.getElementById('flashapp').changeView('faq'); 
					 
			} 
			
			
			
			//show my tracks
			
			/*
			function changeSection(){
				//MAIN SWF
				document.getElementById('flashapp').changeSection(startSection); 
			}*/
			
			function openCloseContact(show) {
				if (show == 1) { 
					//$("#swf_contact").show();
					$("#swf_myTracks").hide(); 
					//MAIN SWF
					//document.getElementById('flashapp').hideMyTacks();  
					//$("#swf_content").css('visibility', 'hidden');

					
				} else {
				// Hide popup
				//$("#swf_contact").hide();
					$("#swf_content").css('visibility', 'visible');
				}
				 
			}
			
			function closeAll(){
					$("#swf_content").css('visibility', 'visible');
					$("#swf_myTracks").hide();
					//MAIN SWF
					//document.getElementById('flashapp').hideMyTacks();  
					//$("#swf_contact").hide();
					 
			}
			 
			function pauseResumePlayer(){
				document.getElementById("flashapp").gomyTracks();
				
			}
			 
			function centerObject(obj, objWidth, objHeight, dir){
			
				if(dir == "h"){
					var newXLoc = (document.body.clientWidth/2) - (objWidth/2); 
					document.getElementById(obj).style.left = newXLoc; 	 
				}else if(dir == "v"){ 
					var newYLoc = (document.body.clientHeight/2) - (objHeight/2); 	
					document.getElementById(obj).style.top = newYLoc; 
				}else if(dir!= "h" && dir != "v"){
					var newXLoc = (document.body.clientWidth/2) - (objWidth/2);
					var newYLoc = (document.body.clientHeight/2) - (objHeight/2); 
					document.getElementById(obj).style.left = newXLoc; 	
					document.getElementById(obj).style.top = newYLoc; 
				}
			}		
			window.onresize = function() {  
					//placeSwf();
			}

			//makeSwf('testi', 'asdfad');
			function makeJpeg(image){
			
			 centerObject("jpegDiv", 10, 10,"h");
			 //explorer gets confused and trys to open a jpg if the 
			 //url ends in .jpg
			 image = image.replace(".jpg", "/jpg");
				 var swfContent = 
					"<object width='10' height='10' id='MakeJpeg'>" +
					"<param name=movie value='MakeJpeg.swf?"+image+"'>" +
					"<param name=quality value=high>" +
					"<param name=wmode value=transparent>" +
					"<embed src='MakeJpeg.swf?"+image+"' quality=high wmode=transparent width='10' height='10' name='mySwf' type='application/x-shockwave-flash'>"+
					"</embed>" +
					"</object>";
					document.getElementById("jpegDiv").innerHTML = swfContent;
					//alert("Begining sizing");
			}
			
			function conversionFinished(file){
				
				 var removeContent ="";
					document.getElementById("jpegDiv").innerHTML = removeContent;
					
					if(startSection != 'uploads'){ 
						document.getElementById("myTracks").imgConverted(file);
						//alert("Finished sizing");
						document.getElementById("flashapp").imgConverted(file);
					}else{
						//alert('finished conversion' + file);
						
					}
					 
			}
			
			// loadHtml('legal_TOS.htm', 500, 300);
		 // confrimUpload();
			 function loadHtml(dataUrl, dataWdth, dataHght){ 
			$("#submit").show();
			 $("#data_Hldr").css('visibility', 'visible');
			 	$("#data_Hldr").show(); 
			 ////$("#swf_content").css('visibility', 'hidden');
			 //$("#bg").css('visibility', 'hidden');
			 	//$setLegal();
				$("#data_Hldr").center();
				$('div.htmlHldr a').live('click', function (){
					//$(this).html(''); 
					//alert('got here');
					 $.ajax({
						  url: $(this).attr("href"),
						  cache: false,
						  success: function(html){
							$("div.htmlHldr").html(html);
						  }
						});
		 
					return false; 
					 
					 
													
				});
				$.ajax({
				  url: dataUrl,
				  cache: false,
				  success: function(html){
					$("div.htmlHldr").html(html);
				  }
				});
				
			}
			 
	function showNav(){ 
	   $("#menu").animate({
				 opacity: 1
				},1000);
	   
	   
	   $(".subLinks").animate({
				 opacity: 1
				},1000);
  }
			
			window.name="livestewmainwindow"; 
		 //	//alert('window.name=' + window.name);
			///window.resizeTo(screen.availWidth, screen.availHeight);
			//window.moveTo(0, 0);
