function debug($obj) {
 if (window.console && window.console.log)
window.console.log($obj);
};
window.onload =function(){
    new Ajax.Request( "/app/xml/background.php?rand="+Math.random(), { 
						asynchronous: true, 
						method: "get",
						onComplete:function(d)
						{
							
							var image = d.responseXML.documentElement.getElementsByTagName("image")[0].getAttribute("img");
							var bd = document.getElementsByTagName("body");
							bd[0].setAttribute("style","background-image:url("+image+")");
							bd[0].style.setAttribute("cssText","background-image:url("+image+")");
							
						}
						});
	};

function openMNMPic(picSrc)
{
    $("mnm_link").href = picSrc;
    $("mnm_link").onclick();
}

function changeRiderPic(picSrc)
{
    Effect.Fade("riderImg", {duration:0.5, afterFinish:function(){
        $("riderImg").src = picSrc;
        Effect.Appear("riderImg", {duration:1.0});
    }});
}

function changeStoryPic(picSrc)
{
    Effect.Fade("storyPic", {duration:1.0, afterFinish:function(){
        $("storyPic").src = '';
        Effect.Appear("storyPic", {duration:1.0});
        $("storyPic").src = picSrc;
    }});
}

function sendContactForm()
{
    $("err_msg").hide();
    $("confirm_msg").show();
    $("err_msg").innerHTML = "&nbsp;";
    $("confirm_msg").innerHTML = "&nbsp;";
    
    if ($("email").value == "" || $("email").value.indexOf("@") == -1 || $("email").value.indexOf(".") == -1 ) {
        $("err_msg").show();
        $("confirm_msg").hide();
        $("err_msg").innerHTML = "Please enter a valid email.";
        $("email").focus();
        return;
    }
    
    new Ajax.Updater("confirm_msg", "/app/actions/sendContactForm.php", { 
						asynchronous: true, 
						method: "post", 
						parameters: $("frm_contact").serialize()
						});
}



function adduseremail()
{
    $("err_msg_mail").hide();
    $("confirm_msg_mail").show();
    $("err_msg_mail").innerHTML = "&nbsp;";
    $("confirm_msg_mail").innerHTML = "&nbsp;";
    
    if ($("email_mail").value == "" || $("email_mail").value.indexOf("@") == -1 || $("email_mail").value.indexOf(".") == -1 ) {
        $("err_msg_mail").show();
        $("confirm_msg_mail").hide();
        $("err_msg_mail").innerHTML = "Please enter a valid email.";
        $("email_mail").focus();
        return;
    }
    
    new Ajax.Updater("confirm_msg_mail", "/app/actions/adduseremail.php", { 
						asynchronous: true, 
						method: "post", 
						parameters: $("mailist").serialize()
						});
	$("confirm_msg_mail").style.color ="#8CC642";
}
