/*
    mailing list
    shopping cart
    mp3 streaming
    video streaming
    pic viewer
    forums
    user comments
    blog
    transition effects
    logo design
    custom graphics
    media services
    motion graphics
    animation
    user generated content
    news and information w/auto mail
*/

var questTotal=0;
//var questAnswers=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var questAnswers=[];
//var questIds=["mailing_list","shopping_cart","mp3_streaming","video_streaming","pic_viewer","forums","user_comments","user_generated_content","blog","transition_effects","news_auto_mailing","logo_design","custom_graphics","media_services","motion_graphics","animation"];
var questIds=[];

//loads previous settings, in case a user switches away from a page, and then comes back to it.  they shouldn't have to re click everything
function questLoad()
{
    for (var t=0;t<questTotal;t++) {
    
        
    
    }
    
}

function questSave()
{
    
}

function questClick(id)
{
    for (var t=0;t<questTotal;t++) {
        
        if (questIds[t]==id) {
        
            //flip
            if (questAnswers[t]==0) {
            
                questAnswers[t]=1;
                assocImage(id, "checkboxon");
            
            } else {
            
                questAnswers[t]=0;
                assocImage(id, "checkboxoff");
            
            }
            
            break;
        
        }
    
    }
    
}

function questOnEnter(id, qtext)
{
	//alert(id+" "+qtext);
	if (document.getElementById(id).value==qtext) {
	
		document.getElementById(id).value="";
	
	}
	
}

function questOnExit(id, qtext)
{
    if (document.getElementById(id).value=="") {
    
        document.getElementById(id).value=qtext;
    
    }
    
}

function questSubmit()
{
    if (document.getElementById("questname").value!="full name" && ( document.getElementById("questemail").value!="email address" || document.getElementById("questphone").value!="phone number" ) ) {
    
        //alert(document.getElementById("questname").value +" " +document.getElementById("questemail").value+" "+document.getElementById("questphone").value);

        //get checkbox values and create param list
        var e="";
        for (var t=0;t<questTotal;t++) {
        
            //alert( curImageAssoc(questIds[t]) );
            
            if ( curImageAssoc(questIds[t]) == "checkboxon" ) {
            
                e=e+encodeURI("`"+questIds[t]+"=true");
            
            } else {
            
                e=e+encodeURI("`"+questIds[t]+"=false");
            
            }
        
        }
    
        var url="proc.php";
        var vars="m=contactmod`c=quest";
        var f=["questname", "questemail", "questphone", "questwhatdoyouneed"];
        
        ddCommandExt(url, vars, f, e, questSubmitDone);
        
    } else {
    
        alert("Not enough information was supplied to complete the form.  You must specify at least your name and your phone number or email address.");
    
    }
}

function questSubmitDone()
{
    var response="";
    if (xhttp.readyState==4 || xhttp.readyState=="complete"){
        
        response=xhttp.responseText;

				//alert(response);
				
        var cBlock=response.split("(~)");
        
        
        if (cBlock[0]=="ok") {
        
            if (cBlock[1]=="1") {
            
                alert("Your request has been sent.  For assured delivery, please add 'csehenuk@hotmail.com' to your address book.  We will contact you soon.  Thanks!");
                
                loadBody("home");
            
            } else {
            
                alert(cBlock[1]);
            
            }
            
        } else {
        
            if (response.length==0)
                alert("there was a server error.  please try again.");
            else {
            
                if (response.match("( ! )")!=null) {
                    
                    document.getElementById("debug").innerHTML="<div style=\"background:darkred; color:white; padding:10px;\">"+response+"</div>";
                
                } else {

                    if (cBlock[0]=="alert") {
                    
                        alert(cBlock[1]);
                    
                    } else 
                
                        alert("server error:\n\n"+response);
                }
                
            }
            
        }
        
    }
    
}
