﻿// JScript File


function DreamcatcherWindow(mininame) 
{
    var windowName = "DreamcatcherWindow";
    var params = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=1, width=700, height=625";  
    window.open("http://dreamcatcher.wizards.com/mini.aspx?name="+mininame, windowName , params);
}    



function checkit() 
{ 
	var user_input = ''; 

    if (document.getElementById('db_name1').checked) 
    { 
        user_input = document.getElementById('db_name1').value;   
    } 
    else if (document.getElementById('db_name2').checked)
    	    { 
        user_input = document.getElementById('db_name2').value;   
    }
    else if (document.getElementById('db_name3').checked)
    { 
        user_input = document.getElementById('db_name3').value;   
    }
    else if (document.getElementById('db_name4').checked)
    { 
        user_input = document.getElementById('db_name4').value;   
    }
	    
	if (user_input == "")
	{
	    alert("You must select a name");
	    return;
	}
	
	var user_input2 = ''; 
	if (document.getElementById('db_flavortext').checked) 
    { 
        user_input2 = document.getElementById('db_flavortext').value;   
    } 
    else if (document.getElementById('db_flavortext2').checked)
    { 
        user_input2 = document.getElementById('db_flavortext2').value;   
    }
    else if (document.getElementById('db_flavortext3').checked)
    { 
        user_input2 = document.getElementById('db_flavortext3').value;   
    }
    else if (document.getElementById('db_flavortext4').checked)
    { 
        user_input2 = document.getElementById('db_flavortext4').value;   
    }
	
    if (user_input2 == '')
	{
        alert("You must select flavor text");
        return;
	}
	
	var url = "poll.aspx?doc="+ QString("doc") +"&result=" + user_input + "|" + user_input2;
	submitVote(url) ;
	//window.location.href = url ;
	
	document.getElementById('pollExit').style.display = "" ;
}

function submitVote(url)
{
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try 
     {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (E) 
      {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
    {
	    try 
	    {
		    xmlhttp = new XMLHttpRequest();
	    } 
	    catch (e) 
	    {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest)
    {
	    try 
	    {
		    xmlhttp = window.createRequest();
	    } 
	    catch (e) 
	    {
		    xmlhttp=false;
	    }
    }
    
     xmlhttp.open("GET", url, true);
     xmlhttp.onreadystatechange=function() 
     {
     }
     
     xmlhttp.send(null)
}	
	
function QString(qsParam) 
{
  qsParam = qsParam.toLowerCase() ;
  nvString = "&" + location.search.substring(1, location.search.length) + "&"
  nvString = nvString.toLowerCase() ;
  paramBegin = nvString.indexOf("&" + qsParam + "=")
  if (paramBegin != -1) 
  {
    valBegin = (paramBegin*-1-qsParam.length-2)*-1
    qsVal = nvString.substring(valBegin, nvString.indexOf("&", valBegin))
    if (qsVal != "") {return unescape(qsVal)}
     else {return ""}
  }
  else {return ""}
}
