var dcheck = false;
function checkTheme()
{
	var f = document.FormTheme;
	if(dcheck == false)
	{
		alert("Please choose a theme");
		return false;
	}else if(f.color.item(0).selected){
		alert("Please Select Color");
		return false;
	}
	return true;
}
function getHTTPObject() 
{
	  var xmlhttp;

	  if(window.XMLHttpRequest)
	  {
			xmlhttp = new XMLHttpRequest();
	  }
	  else if (window.ActiveXObject)
	  {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  
			if (!xmlhttp)
			{
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			}

	  }
		return xmlhttp;
}
  
  function setTheme(myThemeId) {
	dcheck = true;
	var url = 'scripts/set_theme.php';
    new Ajax.Request(url, {  
      method:'get',  
      parameters: 'theme='+myThemeId,
        onSuccess: function(oXHR, Json) {  
          var theme = oXHR.responseText;
		  
			$('theme1').removeClassName('redBox');
			$('theme2').removeClassName('redBox');
			$('theme3').removeClassName('redBox');
			$('theme4').removeClassName('redBox');
			$('theme'+myThemeId).addClassName('redBox');
          	$('theme-select').addClassName('show');
          	$('themeSuccess').innerHTML = 'you have selected '+theme;
        },  
        onFailure:function(){ alert('Something went wrong...') }  
    }); 
	setColorTheme(myThemeId); 
	return false;
  }
  
  var provhttp=null;
function setColorTheme(myThemeId)
{
		var colorurl="scripts/set_color.php?";
		provhttp = getHTTPObject();
		var params = "id="+myThemeId;
		provhttp.open("POST",colorurl,true);
		
		provhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		provhttp.setRequestHeader("Content-length", params.length);
		provhttp.setRequestHeader("Connection", "close");
		
		provhttp.onreadystatechange = handleColorTypeHttpResponse;
		provhttp.send(params);
}
function handleColorTypeHttpResponse()
{ 
	if(provhttp.readyState != 4 || provhttp.readyState !="complete") 
	{		
		document.getElementById('divcolor').innerHTML = '<img src="images/ajaxwipe.gif" border="0" />';
	}
	if(provhttp.readyState == 4 || provhttp.readyState =="complete") 
	{
		var results =  provhttp.responseText;	
		document.getElementById('divcolor').innerHTML= results;					
	}
}