



   
var req;


function loadXMLDoc(url)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}



function processReqChange()
{
// only if req shows "complete"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
// ...processing statements go here...
response = req.responseXML.documentElement;


method =
response.getElementsByTagName('method')[0].firstChild.data;


result =
response.getElementsByTagName('result')[0].firstChild.data;


eval(method + '(\'\', result)');
} else {
alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
}


function checkName(input, response)
{
if (response != '' && document.getElementById('username').value !== ''){
// Response mode
message1 = document.getElementById('nameCheck');
if (response == 1){
message1.className = 'error';
message1.innerHTML = 'That name is not available, please try another.';
}else{
message1.className = 'success';
message1.innerHTML = 'That name is available.';
}
}else{

if (input != '' && input.length > 3){
// Input mode
url =
'checkUserName.php?q=' + input;
loadXMLDoc(url);
}
else { document.getElementById('nameCheck').className = 'hidden'; }
}

}

function populate(input,page)
{
if(input != '') 
{
message1 = document.getElementById('printNums');
document.getElementById('printHeader').className = '';
document.getElementById('printSubmit').className = '';
 var lowerInput = ( 20 * (page - 1) ) + 1;
 var upperInput = lowerInput + 19;
 if(upperInput > input) upperInput = input;
	
 var nums = Math.round(((upperInput - lowerInput) + 1) / 2);
var html = '';
var count = 0;
for ( var x = lowerInput; x <= upperInput; x++) 
{
	if (count == 0) html = html + '<div align="right" style="width:100px;float:left;padding-right:10px;">';
	html = html + x + '. <input type="text" name="pic' + x + '" size="4"><br>';
	count++;
	if (count == nums) { html = html + '</div>'; count = 0; }
	
}
html = html + '<div style="clear:both;">';
/*
if(lowerInput > 1) {
	var page2 = page;
	page2--;
	html = html + '<div style="float:left;display:inline;padding-top:10px;";><a href="javascript:populate(' + input + ',' + page2 + ')"><-Previous 20</div>';
}
if(upperInput < input) {
	var page2 = page;
	page2++;
	html = html + '<div style="float:right;display:inline;padding-top:10px;";><a href="javascript:populate(' + input + ',' + page2 + ')">Next 20-></div>';
}
*/
html = html + '</div>';	
message1.innerHTML = html;
}
}


function albumLinkEdit(func,albumID) 
{
if (func == "Add" ) {
	alert("Add album here");
}
if (func == "Edit" ) {
	alert("Edit album here");
}
if (func == "Remove" ) {
	document.getElementById(albumID).className = 'hidden';
	//phpCall('phpfunctions.php?action=removeAlbum&album=Wedding');
	setTimeout("phpCall('phpfunctions.php?action=listAlbums')",2000);
}

}
	
function phpContentCall(url,div) {

var xmlhttp = false;
        
if (window.XMLHttpRequest) {
        //Intiate the object
        xmlhttp = new XMLHttpRequest();
        //Set the mime type
        xmlhttp.overrideMimeType('text/xml');
}
else if (window.ActiveXObject) {
        //Intiate the object
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
	
if(url !== "") {
		xmlhttp.open('GET',url, true);
                
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                               
				document.getElementById(div).innerHTML = xmlhttp.responseText + ' ';
				
			}
		};
		xmlhttp.send(null);  
	}
}

function phpFunctionCall(url,div) {

var xmlhttp = false;
        
if (window.XMLHttpRequest) {
        //Intiate the object
        xmlhttp = new XMLHttpRequest();
        //Set the mime type
        xmlhttp.overrideMimeType('text/xml');
}
else if (window.ActiveXObject) {
        //Intiate the object
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
	
if(url !== "") {
		xmlhttp.open('GET',url, true);
                
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                               
				activateMsg(xmlhttp.responseText + ' ','green');
				
			}
		};
		xmlhttp.send(null);  
	}
}

function toggleMenu(show, hide) {
    toShow = document.getElementById(show);
    toHide = document.getElementById(hide);
    if(toShow.className == 'hidden') { toShow.className = ''; toHide.className = 'hidden'; }
    else { toShow.className = 'hidden'; }
}

function toggleOne(id) {
    toChange = document.getElementById(id);
    if(toChange.className == 'hidden') { toChange.className = ''; }
    else { toChange.className = 'hidden'; }
}

function addEmail(email) {
	if(email != '') { phpCall("playroom/phpfunctions.php?action=addEmail&address="+email); }
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}