/**
 * JavaScript Document
 * Generic javascript/Ajax for Magic Memories Online Services - Request pages off the refresh.
 * 
 * CHECK ALBUM CODE VALID OR NOT
 * This file check the param for valid email address and  force of the password
 * and send urls by object XMLHttpRequest to right pages and return always something for the <div>
 * 
 * CHANGELOG
 *
 * 10 Jan 2008 - Leandro Carvalho
 *
 * @author Leandro Carvalho <leandro@magicmemories.co.nz>
 * @copyright 10 Jan 2008
 */
 
function checkParamCode(url,where)
{
	req = null;

	var url	= url
	
	if(where == "form"){
		var word = document.albumModify.album_code_new.value;
		var url 		= url+word
	}
	
	// If more tham 3 digits...
	if(word.length < 4){
		document.getElementById('validated').innerHTML = "must be four letters and/or numbers";
		return false;
	} else  {
		var url = url
	}


	// Find objectives (Mozilla/Safari)
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = validCode;
		req.open("GET",url,true);
		req.send(null);
	// Find objetives ActiveX (IE)
	 } else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	  	if (req) {
			req.onreadystatechange = validCode;
			req.open("GET",url,true);
			req.send();
		}
	}
}

// Force of the password
function validCode()
{

	//when loading process print loading...
	if(req.readyState == 1) {
		document.getElementById('validated').innerHTML = "<span style='font-size:10px; color:#999999;'>validating...</span>";
	}
	
	// just when complete process
	if (req.readyState == 4) {
		// just when return "OK"
		if (req.status ==200) {
			// find div id="strength" and input value
			 document.getElementById('validated').innerHTML = req.responseText;
		} else {
			alert("attention! " + req.statusText);
		}
	}

}


