// load player objects
loadPlayer("FlashFeature", "settings.xml", "mp3gallery_feature.xml");
loadPlayer("FlashDoc", "settings.xml", "mp3gallery_doc.xml");
loadPlayer("FlashGames", "settings.xml", "mp3gallery_games.xml");


// jQuery code for displaying music player sections

$(function() {
		$(".musicSection h3").hover(
			function() {
				$(this).addClass("hoverh3");
			},
			function() {
				$(this).removeClass("hoverh3");
			}).click(function() {
								
				if(!$(this).parent().is(".topSection")) {
					$(".musicPlayer").hide();         // close music player
					
					// put this section above the current topSection, remove class from current topSection and add to this one
					$(".topSection").before($(this).parent()).removeClass("topSection");
					$(this).parent().addClass("topSection");
				}
				
				$(this).removeClass("hoverh3");  // turn off highlight
				$(".topSection .musicPlayer").height(300).show();		// show the new player
				$("html, body").scrollTop(230);    // center the player, more or less
			});
			
		//setBackgrounds('inquiryForm');			
});


// function to load the mp3 gallery/player for this section 
function loadPlayer(currentID, currentXMLFile, currentContentXMLFile) {
			// JAVASCRIPT VARS
			// the path to the SWF file
			var swfPath = "player/preview_lj2.swf";   
			swfPath += "?t=" + Date.parse(new Date());   // uncomment this line to activate cache buster
			
			// stage dimensions
			var stageW = "100%";//560//"100%"; // minimum is 450
			var stageH = 300;//400;//"100%"; // minimum is 260
			
			
			// ATTRIBUTES
		    var attributes = {};
		    //attributes.id = 'FlashComponent';
		    attributes.id = currentID;
		    attributes.name = attributes.id;
		    
			// PARAMS
			var params = {};
			params.bgcolor = "#333333";
			params.allowfullscreen = "true";
			params.allowScriptAccess = "always";			
			//params.wmode = "transparent";
			

		    /* FLASH VARS */
			var flashvars = {};
			
			/// if commented / delete these lines, the component will take the stage dimensions defined 
			/// above in "JAVASCRIPT SECTIONS" section or those defined in the settings xml			
			flashvars.componentWidth = stageW;
			flashvars.componentHeight = stageH;							
			
			/// path to the content folder(where the xml files, images or video are nested)
			/// if you want to use absolute paths(like "http://domain.com/images/....") then leave it empty("")
            // Also, if you want the embed code to work correctly you'll need to set the an absolute path for pathToFiles, like this: http://www.yourwebsite.dom/.../mp3gallery/
			flashvars.pathToFiles = "player/mp3gallery/";
			//flashvars.xmlPath = "xml/settings.xml";
			flashvars.xmlPath = "xml/" + currentXMLFile;
			//flashvars.contentXMLPath = "xml/mp3gallery.xml";
			flashvars.contentXMLPath = "xml/" + currentContentXMLFile;
						
			/** EMBED THE SWF**/
			swfobject.embedSWF(swfPath, attributes.id, stageW, stageH, "9.0.124", "player/js/expressInstall.swf", flashvars, params, attributes);
			if(swfmacmousewheel) swfmacmousewheel.registerObject(attributes.id);
			
}

function setBackgrounds(formid) {
	var form = document.getElementById(formid);
	for (i=0; i < form.length; i++) {
		if(form.elements[i].id != "submit") {
			form.elements[i].onfocus = whiteBackground;
			form.elements[i].onblur = yellowBackground;
		}
	}
}

function whiteBackground() {
	this.style.backgroundColor = "#fff";
}

function yellowBackground() {
	this.style.backgroundColor = "#ffffc0";
}

function validateInquiry() {
	
	// check name fields
	if(document.getElementById("name").value.length == 0) {
		alert("Please enter your name");
		document.getElementById("name").focus();
		return false;
	}
	
	// email
	test_exp = /^[A-z0-9\._-]+@[A-z0-9][A-z0-9-]*(\.[A-z0-9_-]+)*\.([A-z]{2,6})$/;
	if (!test_exp.test(document.getElementById("email").value)) {
		alert("Please enter a valid email address");
		document.getElementById("email").focus();
		return false;
	}
	
	// comments
	if(document.getElementById("comment").value.length == 0) {
		alert("You didn't enter any comment or question");
		document.getElementById("comment").focus();
		return false;
	}	
}




