var IE = false;
if (navigator.appName == "Microsoft Internet Explorer"){IE = true}


function voteChart(frm){
var getstr = "?";
var votechk='';
xchartname = frm.chartname.value;
 foundx=false   
for (var i=0; i < frm.chrtx.length; i++)
   {
   if (frm.chrtx[i].checked)
      {
      var voteid = frm.chrtx[i].value; 
      foundx=true     
      }
   }
if(!foundx){
alert('Please check your song.');
     return ;
     }
 if(IE){ window.document.body.scroll = 'no'; }
scroll(0,0);				
document.getElementById('bgfader').style.left=0;
document.getElementById('bgfader').style.top=0;
//document.getElementById('bgfader').style.width= screen.width ;
//document.getElementById('bgfader').style.height= myHeight;
document.getElementById('bgfader').style.visibility = "visible"; 

var cx = 300
var cy = 200
document.getElementById('popMessage').style.visibility = "visible"; 
document.getElementById('popMessage').style.left = cx;  
document.getElementById('popMessage').style.top = cy;  
document.getElementById('popFormResult').style.visibility = "visible";  
document.getElementById('popFormResult').innerHTML = '<img src=/imgx/loader.gif border=0>' 

 getstr += "id=" + voteid + "&cname=" + xchartname ;
 //alert(getstr);
sendRequest('/charts/vote.asp', getstr);
}

function sendRequest(url, parameters) {
      http_ajax = getHTTPObj();

      if (!http_ajax) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_ajax.onreadystatechange = handleResponse;
      http_ajax.open('GET', url + parameters, true);
      http_ajax.send(null);
   }

function handleResponse() {
 
//alert(http_ajax.responseText);
      if (http_ajax.readyState == 4) {
         if (http_ajax.status == 200) {
            result_get = http_ajax.responseText;
            reS = /Result :/i;    //Create regular expression pattern.        
           rS = result_get.search(reS); // search for success result
           result = result_get             
		
			if (rS==0){ //if result is successfull then show it in blue color			   
				var reSS = result.substr(8);	
				//alert(reSS);						 				
				document.getElementById('popFormResult').align = 'center';							
				document.getElementById('popFormResult').style.color= '#003399'						 
				document.getElementById('popFormResult').innerHTML = reSS + '<br>'; 
				//document.getElementById('popFormResult').innerHTML = '<img src=/imgx/loader.gif border=0>'
				//count = 0
				//closeThis(count,reSS)									         
				}else{
				//alert(result);		
				// show any other responces
				document.getElementById('popFormResult').innerHTML = 'Error : ' + result;    
				}				 
         } else {
          document.getElementById('popFormResult').style.visibility = "visible";   
            document.getElementById('popFormResult').innerHTML = 'There was a problem with the request.' ;
         }
      }
   }

function viewVote(){

 if(IE){ window.document.body.scroll = 'no'; }
scroll(0,0);				

document.getElementById('bgfader').style.left=0;
document.getElementById('bgfader').style.top=0;
//document.getElementById('bgfader').style.width= screen.width ;
//document.getElementById('bgfader').style.height= myHeight;
document.getElementById('bgfader').style.visibility = "visible"; 

var cx = 300
var cy = 200
document.getElementById('popMessage').style.visibility = "visible"; 
document.getElementById('popMessage').style.left = cx;  
document.getElementById('popMessage').style.top = cy;  
document.getElementById('popFormResult').style.visibility = "visible";  
document.getElementById('popFormResult').innerHTML = '<img src=/imgx/loader.gif border=0>'

    http_ajax = getHTTPObj();

      if (!http_ajax) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_ajax.onreadystatechange = handleViewResponse;
      http_ajax.open('GET', 'viewvote.asp', true);
      http_ajax.send(null);


}

function handleViewResponse() {


		
//alert(http_ajax.responseText);
      if (http_ajax.readyState == 4) {
         if (http_ajax.status == 200) {
            result_get = http_ajax.responseText;   
           result = result_get    
                   
			document.getElementById('popFormResult').innerHTML = result_get;    
		}				 
          else {         
            document.getElementById('popFormResult').innerHTML = 'There was a problem with the request.' ;
         }
      }
   }


function  closeLayer() {
//alert('s');
 if(IE){ window.document.body.scroll = 'yes'; }
 
 //document.getElementById('popFormTD').innerHTML = ''
 document.getElementById('popFormResult').style.visibility = "hidden"; 
 document.getElementById('popMessage').style.visibility = "hidden";  
 //document.getElementById('popFormResult').innerHTML =  '';
 document.getElementById('bgfader').style.visibility = "hidden"; 	
 location.reload();
  } 

function closeThis(count)
	{
	if (count < 10) 
	{
		count = count + 1
		setTimeout("closeThis()",500)
	}
	else
	{
	 closepopForm();
	location.reload();
	 
	}
}

function getHTTPObj() {
    var xmlhttp;
         if (window.XMLHttpRequest) { // Mozilla, Safari,...
         xmlhttp = new XMLHttpRequest();
         if (xmlhttp.overrideMimeType) {
         	// set type accordingly to anticipated content type         
            xmlhttp.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
	return xmlhttp;
}