var xmlHttp;
var q_array=new Array();
var q_pos=0;
var curelm="";
var show=1;

var nxt_btnonclick;
var prv_btnonclick;

var online=0;
var paper=0;
var comment_scr=new Array();
var rate_scr=new Array();

function show_drop_list(obj)
{
objs=document.getElementById('s');
objs.style.display='block';

}

function show_drop_menu(mname)
{
document.getElementById(mname).style.display='block';
}

function hide_drop_menu()
{
if(curelm!='result_mnu' &&  document.getElementById('result_mnu') && document.getElementById('result_mnu').style.display=='block')
document.getElementById('result_mnu').style.display='none';

if(curelm!='admin_mnu' && document.getElementById('admin_mnu') && document.getElementById('admin_mnu').style.display=='block')
document.getElementById('admin_mnu').style.display='none';

}

function show_left_menu(val)
{
	if(document.getElementById(val).style.display=='block')
	hide_left_menu();
	else
	document.getElementById(val).style.display='block';
}
function hide_left_menu()
{
//if(curelm!='year_qq_set' && curelm!='year_qq_set0' && curelm!='year_qq_set1' && curelm!='year_qq_table' && 
	 if(document.getElementById('year_qq_set') && document.getElementById('year_qq_set').style.display=='block')
		document.getElementById('year_qq_set').style.display='none';
		
//	if(curelm!='doh_sel_set' && curelm!='sel_doh' && curelm!='doh_table' && document.getElementById('doh_sel_set'))
	if(document.getElementById('doh_sel_set') && document.getElementById('doh_sel_set').style.display=='block')
		document.getElementById('doh_sel_set').style.display='none';		
		
}
function hide_drop_list()
{
//	hide_left_menu();
//	hide_drop_menu();
if(((show==1 && curelm!='optval' && curelm!='down_arrow') || show==0) && document.getElementById('s'))
{
objs=document.getElementById('s');
objs.style.display='none';
show=1;
}
else
return;
}
function mover_chback(obj)
{
obj.style.background='#C5CED7';
}
function mout_chback(obj)
{
obj.style.background='';
}
function click_option(obj,ph)
{
show=0;
document.getElementById('optval').innerHTML=obj.innerHTML;
objs=document.getElementById('s');
objs.style.display='block';
save_rating(ph,obj.innerHTML);
hide_drop_list();
}


function mover_chback_left(obj)
{
obj.style.background='#FFFFFF';
obj.style.color='#F3892A';
}
function mout_chback_left(obj)
{
obj.style.background='';
obj.style.color='#FFFFFF';
}

function showtofrom(e){

 var evt=window.event || e
  var toElement=evt.srcElement || evt.target;
  if(toElement.id)
  curelm=toElement.id;
  else
  curelm="";

 }

document.onmouseover=showtofrom;
document.onclick=hide_drop_list;

	function watermark() {
 
		var obj = document.getElementById("shadow");
 
		var lngObjHeight = 0;
		var lngObjWidth =0; 
		var lngWinHeight;
		var lngWinWidth;
		var lngXOffset;
		var lngYOffset;
		// Netscape implementation
		if(navigator.appName == "Netscape") {
			var lngObjHeight =window.innerHeight;
			var lngObjWidth =window.innerWidth; 
			lngWinHeight = window.innerHeight;
			lngWinWidth = window.innerWidth;
			lngYOffset = window.pageYOffset;
			lngXOffset = window.pageXOffset;
 
			obj.style.top = ( lngWinHeight + lngYOffset - lngObjHeight );
			obj.style.left = ( lngWinWidth + lngXOffset - lngObjWidth );
		}
 
		// MSIE implementation
		if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Mac") == -1) {
			var lngObjHeight =document.body.clientHeight;
			var lngObjWidth =document.body.clientWidth; 
			lngWinHeight = document.body.clientHeight;
			lngWinWidth = document.body.clientWidth;
			lngYOffset = document.body.scrollTop;
			lngXOffset = document.body.scrollLeft;
 
			obj.style.top = ( lngWinHeight + lngYOffset - lngObjHeight );
			obj.style.left = ( lngWinWidth + lngXOffset - lngObjWidth );
		}
 
                var loader1 = document.getElementById("loader1");
 
                var bws = getBrowserHeight();
 
                var left_pos = parseInt((bws.width - 100) / 2);
                var top_pos = parseInt((bws.height - 100) / 2);
				loader1.style.left=parseInt(obj.style.left) + left_pos;
				loader1.style.top=parseInt(obj.style.top) + top_pos;
 


                loader1 = null;
 
 
                 var loader1 = document.getElementById("popup_comment");
 if(loader1){
                var bws = getBrowserHeight();
 
                var left_pos = parseInt((bws.width - 800) / 2);
                var top_pos = parseInt((bws.height - 200) / 2);
				loader1.style.left=parseInt(obj.style.left) + left_pos;
				loader1.style.top=parseInt(obj.style.top) + top_pos;

                loader1 = null;}
 
	}
 
            function getBrowserHeight() {
                var intH = 0;
                var intW = 0;
               
                if(typeof window.innerWidth  == 'number' ) {
                   intH = window.innerHeight;
                   intW = window.innerWidth;
                } 
                else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
                    intH = document.documentElement.clientHeight;
                    intW = document.documentElement.clientWidth;
                }
                else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
                    intH = document.body.clientHeight;
                    intW = document.body.clientWidth;
                }
 
                return { width: parseInt(intW), height: parseInt(intH) };
            }  
 
            function setLayerPosition() {
                var shadow = document.getElementById("shadow");
                var loader1 = document.getElementById("loader1");
                var popup_comment = document.getElementById("popup_comment");
 
                var bws = getBrowserHeight();
                shadow.style.width = bws.width + "px";
                shadow.style.height = bws.height + "px";
 
                loader1.style.left = parseInt((bws.width - 100) / 2);
                loader1.style.top = parseInt((bws.height - 100) / 2);
 if(popup_comment){
                popup_comment.style.left = parseInt((bws.width - 800) / 2);
                popup_comment.style.top = parseInt((bws.height - 200) / 2);
				popup_comment=null;
}
                shadow = null;
                loader1 = null;

            }
 
 
            function showLayer() {
                setLayerPosition();
 
                var shadow = document.getElementById("shadow");
                var loader1 = document.getElementById("loader1");
 
                shadow.style.display = "block"; 
                loader1.style.display = "block";
 
               shadow = null;
               loader1 = null;             watermark();
               window.onscroll=watermark;
            }
            
            function hideLayer() {
                var shadow = document.getElementById("shadow");
                var loader1 = document.getElementById("loader1");
 
                shadow.style.display = "none"; 
                loader1.style.display = "none";
 
                shadow = null;
                loader1 = null; 
              window.onScroll='';
			  

            }

            function showLayerPopup() {
                setLayerPosition();
 
                var shadow = document.getElementById("shadow");
                var loader1 = document.getElementById("popup_comment");
 
                shadow.style.display = "block"; 
                loader1.style.display = "block";
 
               shadow = null;
               loader1 = null;             watermark();
               window.onscroll=watermark;
            }
            
            function hideLayerPopup() {
                var shadow = document.getElementById("shadow");
                var loader1 = document.getElementById("popup_comment");
 
                shadow.style.display = "none"; 
                loader1.style.display = "none";
 
                shadow = null;
                loader1 = null; 
              window.onScroll='';
			  
  			  cmndval=document.forms[0].comm.value;			  
  			  document.getElementById("view_comments").innerHTML=document.getElementById("inner_popup").innerHTML;
			  document.getElementById("view_comments").style.display='block';
			  document.getElementById("inner_popup").innerHTML='';
  			  document.forms[0].comm.value=cmndval;
			  
            }

window.onresize = setLayerPosition;

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function disp_questionnaire_details()
{
url='questionnaire_details_fr.php?ph='+document.forms[0].pharm.value+'&qq_name='+document.forms[0].qq_name.value+'&rnd='+Math.random()+'&year='+document.forms[0].year.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
    {
		document.getElementById("questionnair_dis_div").innerHTML=xmlHttp.responseText;
     }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function disp_area(obj,arean)
{
	if(document.getElementById('saved_info').style.display!='none')
	lv=1;
	else
	lv=2;
	
	document.getElementById('pharm_info').style.display='none';
	document.getElementById('report_info').style.display='none';
	document.getElementById('saved_info').style.display='none';
	document.getElementById(arean).style.display='block';
	document.getElementById('ph_info').className='sbmenu';
	document.getElementById('q_info').className='sbmenu';
	document.getElementById('saved_rep').className='sbmenu';
	obj.className='sbmenu_selected';

	if(document.getElementById('q_info').style.display=='none' && arean=='report_info')
	{
		if(lv==2)
			disp_area(document.getElementById('ph_info'),'pharm_info');		
		else
			disp_area(document.getElementById('saved_rep'),'saved_info');
	}

}


 
 
function disp_question(ph,q)
{
var url,url1;

/*	if(q!=0)
	{
	document.getElementById("q_info").innerHTML="&nbsp;&nbsp;Result - Q"+q+" &nbsp;<img src=\"images/pcCloseButton.png\" onclick=\"document.getElementById('q_info').style.display='none';\">&nbsp;&nbsp;";
	document.getElementById("q_info").style.display=inline_block();
	}*/

if(IsNumeric(q))
{
url="top_navigation.php?ph="+ph+"&q="+q+"&randval="+Math.random(); 
url1="link.php?ph="+ph+"&q="+q+"&randval="+Math.random(); 
}
else
{
url="top_navigation.php?ph="+ph+"&q="+q+"&s=1&randval="+Math.random(); 
url1="link.php?ph="+ph+"&q="+q+"&s=1&randval="+Math.random(); 
}
var xmlHttp3; 

	xmlHttp3=GetXmlHttpObject();
	if (xmlHttp3==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 


  xmlHttp3.onreadystatechange=function()
    {
    if(xmlHttp3.readyState==4)
      {/*
		  txt_all=(xmlHttp3.responseText).split("*****");
		  
		  if(document.forms[0].comm){
		  		  comm=(txt_all[1]).split("***");
		  
		document.forms[0].comm.value=comm[0];
		
		strarr=comm[1].split(",");
if(strarr[0]=="" || strarr[0]=="none"  || strarr[0]=="x")
{
document.getElementById('comment_container').style.visibility='visible';
document.getElementById('optval').innerHTML="Select a rating";
}
else
{
document.getElementById('comment_container').style.visibility='visible';
document.getElementById('optval').innerHTML=strarr[0];
}
		  }
*/
		  if((xmlHttp3.responseText).search("<b>Warning</b>:")>=0 || (xmlHttp3.responseText).search("<script>location.href='home.php'</script>")>=0)
		  {
			  page_redirect()
			  return;
		  }
		  
	document.getElementById("top_information").innerHTML=document.getElementById('top_nav_top').innerHTML+xmlHttp3.responseText;
	document.getElementById("top_information").style.display="block";
	
	for(i=0;i<q_array.length;i++)
{
document.getElementById('td_'+q_array[i]).className='style_top';
}
document.getElementById('td_'+q).className='style_top_sel';


	
//	set_nblinks(url1);
//	get_rate(ph,q,s);
//	get_comments(ph,q);
//	document.getElementById("view_comments").style.display="block";
      }
    }

	xmlHttp3.open("GET",url,true);
	xmlHttp3.send(null);
} 

function disp_comment(ph,q,s)
{
var url;
document.forms[0].nocomment.checked=false;
document.f1.nocomment.checked=false;
url="view_comment.php?ph="+ph+"&q="+q+"&randval="+Math.random(); 
var xmlHttp4;

	xmlHttp4=GetXmlHttpObject();
	if (xmlHttp4==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 


  xmlHttp4.onreadystatechange=function()
    {
    if(xmlHttp4.readyState==4)
      {
	document.getElementById("view_comments").innerHTML=xmlHttp4.responseText;
	document.getElementById("view_comments").style.display="block";

      }
    }

	xmlHttp4.open("GET",url,true);
	xmlHttp4.send(null);
} 



function get_rate(ph,q)
{
var url;
if(IsNumeric(q))
url="get_rate.php?ph="+ph+"&q="+q+"&randval="+Math.random(); 
else
url="get_rate.php?ph="+ph+"&q="+q+"&randval="+Math.random()+"&s=1"; 

var xmlHttp5;

	xmlHttp5=GetXmlHttpObject();
	if (xmlHttp5==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 


  xmlHttp5.onreadystatechange=function()
    {
    if(xmlHttp5.readyState==4)
      {
		  if((xmlHttp5.responseText).search("<b>Warning</b>:")>=0 || (xmlHttp5.responseText).search("<script>location.href='home.php'</script>")>=0)
		  {
			  page_redirect();
			  return;
		  }
		  
	var rate=xmlHttp5.responseText;

strarr=rate.split(",");


/*if(strarr[0]=="none")
{
document.getElementById('comment_container').style.visibility='hidden';
}
else */if(strarr[0]=="" || strarr[0]=="none")
{
document.getElementById('comment_container').style.visibility='visible';
document.getElementById('optval').innerHTML="Select a rating";
}
else
{
document.getElementById('comment_container').style.visibility='visible';
document.getElementById('optval').innerHTML=strarr[0];
}

/*if(strarr[1]=="true")
document.forms[0].sel_final.checked=true;
else
document.forms[0].sel_final.checked=false;

	if(strarr[2]>4)
	document.forms[0].final_but.disabled=false;
	else
	document.forms[0].final_but.disabled=true;
	
	*/
	
/*if(strarr[1]>4)
document.getElementById('final_button_div').style.display='block';
else
document.getElementById('final_button_div').style.display='none';
*/
      }
    }

	xmlHttp5.open("GET",url,true);
	xmlHttp5.send(null);
}


function add_comments()
{
if(document.forms[0].nocomment.disabled==false)
{
var url,parameters;
url="save_comments.php"
ph=document.forms[0].ph.value;
q=document.forms[0].q.value;
rate=document.forms[0].rate.value;
if(document.forms[0].nocomment.checked)
comm="No comments";
else
comm=document.forms[0].comm.value;
parameters="ph="+encodeURI(ph)+"&q="+encodeURI(q)+"&rate="+encodeURI(rate)+"&comm="+encodeURI(comm);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 


  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	var rte=xmlHttp.responseText;
	
/*	if(rte=="Comments and Rating Saved" || rte=="Comments Saved")
	{
	alert(rte);
	//disp_next();
	}
	else
	{
		 alert(rte);
		document.forms[0].comm.disabled=false;
	}*/
      }
    }

	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}
} 




function set_benmark(obj,val)
{
//showLayer();
var url;

ca_check='';
na_check='';
ba_check='';
pa_check='';
pya_check='';

if(val=='ca_check')
{
	ca_check=obj.checked;
if(ca_check)
selectall(document.getElementsByName('ca_check[]'));
else
unselectall(document.getElementsByName('ca_check[]'));
}

if(val=='na_check')
{
	na_check=obj.checked;
if(na_check)
selectall(document.getElementsByName('na_check[]'));
else
unselectall(document.getElementsByName('na_check[]'));
}

if(val=='ba_check')
{
	ba_check=obj.checked;
if(ba_check)
selectall(document.getElementsByName('ba_check[]'));
else
unselectall(document.getElementsByName('ba_check[]'));
}

if(val=='pa_check')
{
	pa_check=obj.checked;
if(pa_check)
selectall(document.getElementsByName('pa_check[]'));
else
unselectall(document.getElementsByName('pa_check[]'));
}

if(val=='pya_check')
{
	pya_check=obj.checked;
if(pya_check)
selectall(document.getElementsByName('pya_check[]'));
else
unselectall(document.getElementsByName('pya_check[]'));
}


url="setph_ben.php?ca_check="+ca_check+"&na_check="+na_check+"&pa_check="+pa_check+"&ba_check="+ba_check+"&pya_check="+pya_check+"&randval="+Math.random();

	xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
	var ph=document.forms[0].pharm.value;
//	var q=document.forms[0].q.value;
//	disp_benbut(ph,q);
showLayer();
change_charts(ph);
      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}

function change_charts(ph)
{

	url='all_charts.php?year='+document.forms[0].year.value+'&randval='+Math.random();
var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
		  if((xmlHttpe.responseText).search("<b>Warning</b>:")>=0)
		  {
			  page_redirect()
			  return;
		  }
		  
  		if(document.getElementById('chart'))
		lfmargin=document.getElementById('chart').style.marginLeft;
		else
		lfmargin='256px';
		document.getElementById('all_charts').innerHTML=xmlHttpe.responseText;
		document.getElementById('chart').style.marginLeft='1000 px';
		document.getElementById('chart').style.marginLeft=lfmargin;
		document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

	if(document.getElementById('container_'+q_array[q_pos-1]))
{
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
	for(var sleepi=0;sleepi<10;sleepi++)
	sleepi=sleepi;
	
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-2;
}


gotochart(ph,q_array[q_pos]);

//disp_nxt_prv_btn();
      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   

function inline_block()
{
	if(navigator.appName=='Microsoft Internet Explorer')
return 'inline';
else
return 'inline-block';
}

function movel(lp)
{
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-10+'px';
lp-=10;

if(document.getElementById('container_'+q_array[q_pos+1]))
{
if(document.getElementById('container_'+q_array[q_pos+1]).style.top == '')
document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos+2]))
	document.getElementById('container_'+q_array[q_pos+2]).style.zIndex=-1;

document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=2;
if((lp/10)%2==0)
document.getElementById('container_'+q_array[q_pos+1]).style.top=parseInt(document.getElementById('container_'+q_array[q_pos+1]).style.top)+1+'px';

document.getElementById('container_'+q_array[q_pos]).style.zIndex=-1;

if((lp/10)%2==0)
document.getElementById('container_'+q_array[q_pos]).style.top=parseInt(document.getElementById('container_'+q_array[q_pos]).style.top)-1+'px';

}

if(lp==0)
{
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-27+'px';
if(document.getElementById('container_'+q_array[q_pos]))
{
//	document.getElementById('container_'+q_pos).style.top='50px';
document.getElementById('container_'+q_array[q_pos]).style.zIndex=-1;
document.getElementById('container_'+q_array[q_pos]).style.top='0px';
}
q_pos++;

	if(document.getElementById('container_'+q_array[q_pos+1]))
{
	document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-1;
	for(var sleepi=0;sleepi<10;sleepi++)
	sleepi=sleepi;
	
	document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-2;
}

disp_nxt_prv_btn();

/*document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='50px';
*/

return;
}
else
setTimeout('movel('+lp+')',1);

}
function mover(lp)
{
		
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+10+'px';
lp-=10;

if(document.getElementById('container_'+q_array[q_pos-1]))
{
if(document.getElementById('container_'+q_array[q_pos-1]).style.top == '')
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';
	
document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=2;
if((lp/10)%2==0)
document.getElementById('container_'+q_array[q_pos-1]).style.top=parseInt(document.getElementById('container_'+q_array[q_pos-1]).style.top)+1+'px';
document.getElementById('container_'+q_array[q_pos]).style.zIndex=-1;
if((lp/10)%2==0)
document.getElementById('container_'+q_array[q_pos]).style.top=parseInt(document.getElementById('container_'+q_array[q_pos]).style.top)-1+'px';
}

if(lp==0)
{
	document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+27+'px';
	if(document.getElementById('container_'+q_array[q_pos]))
{
//	document.getElementById('container_'+q_pos).style.top='50px';
document.getElementById('container_'+q_array[q_pos]).style.zIndex=-1;
document.getElementById('container_'+q_array[q_pos]).style.top='0px';
}
	
	q_pos--;


/*	document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='50px';*/
	
	if(document.getElementById('container_'+q_array[q_pos-1]))
{
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
	for(var sleepi=0;sleepi<10;sleepi++)
	sleepi=sleepi;
	
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-2;
}

	
disp_nxt_prv_btn();
	return;
}
else
setTimeout('mover('+lp+')',1);
}
function disp_nxt_prv_btn()
{
for(i=0;i<q_array.length;i++)
{
if(document.getElementById('ext_space_'+q_array[i]))
{document.getElementById('ext_space_'+q_array[i]).innerHTML='';
document.getElementById('ext_space1_'+q_array[i]).innerHTML='';}

}

if(document.getElementById('ext_space_'+q_array[q_pos])){
document.getElementById('ext_space_'+q_array[q_pos]).innerHTML='<br><br><br>';
document.getElementById('ext_space1_'+q_array[q_pos]).innerHTML='<br><br><br>';
}
//if(parseInt(document.getElementById('chart').style.marginLeft)==114)
if(q_pos==0)
document.getElementById('prv_btn').style.display='none';
else
document.getElementById('prv_btn').style.display='block';

if(q_pos==q_array.length-1)
document.getElementById('nxt_btn').style.display='none';
else
document.getElementById('nxt_btn').style.display='block';

document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';

if(document.getElementById('container_'+q_array[q_pos+1])){
	document.getElementById('mask_next').style.display='block';
	document.getElementById('mask_next').style.zIndex=1;

	document.getElementById('mask_next').style.height=document.getElementById('container_'+q_array[q_pos+1]).clientHeight;

	document.getElementById('mask_next').style.left=document.getElementById('container_'+q_array[q_pos+1]).offsetLeft-3;
	document.getElementById('mask_next').style.top=document.getElementById('container_'+q_array[q_pos+1]).offsetTop-3;
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
	document.getElementById('mask_next').style.top=parseInt(document.getElementById('mask_next').style.top)-34;


}
if(document.getElementById('container_'+q_array[q_pos-1])){
	document.getElementById('mask_prev').style.display='block';
	document.getElementById('mask_prev').style.zIndex=1;


	document.getElementById('mask_prev').style.height=document.getElementById('container_'+q_array[q_pos-1]).clientHeight;

	if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Mac") == -1)
	{
		document.getElementById('mask_prev').style.left='-2px';
	}
	document.getElementById('mask_prev').style.top=document.getElementById('container_'+q_array[q_pos-1]).offsetTop-3;
	
	document.getElementById('mask_prev').style.height=document.getElementById('mask_prev').style.height;
	
}


document.getElementById("nxt_btn").onclick=nxt_btnonclick;
document.getElementById("prv_btn").onclick=prv_btnonclick;

}
function set_questionnaire(val)
{
	var txt="<br><table align='center' cellapdding=0 cellspacing=0><tr>";
ph=document.forms[0].pharm.value;
q_array=[];
strarr=val.split(",");
for(i=0;i<strarr.length-1;i++)
{
	q_array[i]=strarr[i];
	
	txt+="<td id='td_"+q_array[i]+"' onclick=\"gotochart('"+ph+"','"+q_array[i]+"');\" class='style_top'>"+q_array[i]+"</td>";
	if(i!=strarr.length-2)
	txt+="<td >-</td>";
	
}
txt+="</tr></table>";

//document.getElementById('top_nav').innerHTML=txt;

}

Array.prototype.findIndex = function(value){
var ctr = "";
for (var i=0; i < this.length; i++) {
// use === to check for Matches. ie., identical (===), ;
if (this[i] == value) {
return i;
}
}
return ctr;
};

/*function gotonext(ph)
{
q=q_array[q_pos+1];

disp_question(ph,q);
//get_comments(ph,q);
//get_rate(ph,q);
//document.getElementById('mask_prev').style.display='none';
//document.getElementById('mask_next').style.display='none';

cur_q=q_pos;
if(cur_q==q_array.length-2)
{
	q_prv=0;
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}
else
{
	q_prv=0;
	q_bprv=0;
	q_anxt=q_array[q_pos+2];
	q_nxt=q_array[q_pos+1];
}
get_four_images(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"next",0);

//movel(400);
}

function gotoprev(ph)
{
	q=q_array[q_pos-1];

disp_question(ph,q);
//get_comments(ph,q);
//get_rate(ph,q);
//document.getElementById('mask_prev').style.display='none';
//document.getElementById('mask_next').style.display='none';

cur_q=q_pos;
if(cur_q==1)
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=0;
}
else
{
	q_prv=q_array[q_pos-1];
	q_bprv=q_array[q_pos-2];
	q_anxt=0;
	q_nxt=0;
}
get_four_images(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"prev",0);

//mover(400);
}
*/

function gotonext(ph)
{
	
	nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";
	
q=q_array[q_pos+1];

disp_question(ph,q);
get_comments(ph,q);
get_rate(ph,q);
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';
movel(400);
}

function gotoprev(ph)
{
	
	nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";
	
	q=q_array[q_pos-1];

disp_question(ph,q);
get_comments(ph,q);
get_rate(ph,q);
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';
mover(400);
}

function gotochart(ph,q)
{

val=q_array.findIndex(q);

disp_question(ph,q);
get_comments(ph,q);
get_rate(ph,q);

hideLayer();

if(val==q_pos)
{
	nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";
	
document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';
setTimeout('disp_nxt_prv_btn()',200);
}
else if(val>q_pos)
{

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='0px';

dist=((val-q_pos)-1)*427;

nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";

q_pos=val-1;

if(document.getElementById('container_'+q_array[q_pos+1]))
document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos-1]))
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='20px';


document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-dist+'px';

movel(400);


	}
else
{
	
if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='0px';

dist=((q_pos-val)-1)*427;

nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";

q_pos=val+1;


if(document.getElementById('container_'+q_array[q_pos+1]))
{
	document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-1;
}
if(document.getElementById('container_'+q_array[q_pos-1]))
{
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
}

if(document.getElementById('container_'+q_array[q_pos]))
{
	document.getElementById('container_'+q_array[q_pos]).style.top='20px';
	document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
}
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+dist+'px';


mover(400);

}


}


function get_comments(ph,q)
{
var url;

if(IsNumeric(q))
{
url="get_comments.php?ph="+ph+"&q="+q+"&randval="+Math.random(); 
}
else
{
url="get_comments.php?ph="+ph+"&q="+q+"&s=1&randval="+Math.random();
}
var xmlHttp3; 

	xmlHttp3=GetXmlHttpObject();
	if (xmlHttp3==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 


  xmlHttp3.onreadystatechange=function()
    {
    if(xmlHttp3.readyState==4)
      {
		  
		  if((xmlHttp3.responseText).search("<b>Warning</b>:")>=0 || (xmlHttp3.responseText).search("<script>location.href='home.php'</script>")>=0)
		  {
			  page_redirect()
			  return;
		  }
		  
		  comm=(xmlHttp3.responseText).split("***");
		  
		document.forms[0].comm.value=comm[0];
		
		strarr=comm[1].split(",");
if(strarr[0]=="" || strarr[0]=="none"  || strarr[0]=="x")
{
document.getElementById('comment_container').style.visibility='visible';
document.getElementById('optval').innerHTML="Select a rating";
}
else
{
document.getElementById('comment_container').style.visibility='visible';
document.getElementById('optval').innerHTML=strarr[0];
}
		
      }
    }

	xmlHttp3.open("GET",url,true);
	xmlHttp3.send(null);
} 

function view_options(oval,opt_type,panel)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		document.getElementById(panel).innerHTML=xmlHttp.responseText;
      }
    }
	xmlHttp.open("GET",'options.php?rand='+Math.random()+'&qq_option_no='+oval+"&opt_type="+opt_type,true);
	xmlHttp.send(null);
}


function disp(val)
{
	document.getElementById("sub_num").style.display='none';
	document.getElementById("opt_num").style.display='none';
	
	if(val=='sub_no'){
		document.getElementById("sub_num").style.display='block';
		document.getElementById("subquestions").style.display='block';
		document.getElementById("options").style.display='none';
		document.getElementById("options").innerHTML='';
		document.getElementById("qq_option_no").selectedIndex=0;
		document.getElementById("smiley_opt").style.display='none';
	}
	else if(val=='opt_no'){
		if(document.add_questions.response_type.value=='Smiley'){
		document.getElementById("opt_num").style.display='none';
		document.getElementById("smiley_opt").style.display='block';
		}
		else{
		document.getElementById("smiley_opt").style.display='none';	
		document.getElementById("opt_num").style.display='block';			
		}
		document.getElementById("options").style.display='block';
		
		document.getElementById("subquestions").style.display='none';
		document.getElementById("subquestions").innerHTML='';
		document.getElementById("sub_no").selectedIndex=0;
		
	}

}

function view_sub_questions(sval)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		document.getElementById('subquestions').innerHTML=xmlHttp.responseText;
      }
    }
	xmlHttp.open("GET",'subquestions.php?rand='+Math.random()+'&no_sub='+sval+'&typ='+document.add_questions.response_type.value,true);
	xmlHttp.send(null);
}

function preview_question(sval)
{
document.getElementById('prview_ques_lib').innerHTML='';
if(sval=='')
return;

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		document.getElementById('prview_ques_lib').innerHTML=xmlHttp.responseText;
      }
    }
	xmlHttp.open("GET",'get_lib_question.php?rand='+Math.random()+'&qlink_id='+sval,true);
	xmlHttp.send(null);
}

function delete_questions(sval)
{

var a=confirm("This Question will be deleted from your Questionnaire, Click OK to Continue");

if(a==false)
return;

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
//		document.getElementById('questionnaire').innerHTML=xmlHttp.responseText;
		location.reload(true);
		//location='';
      }
    }
	xmlHttp.open("GET",'delete_questions.php?rand='+Math.random()+'&qlinkid='+sval,true);
	xmlHttp.send(null);
}

function move_questions(sval,up_down)
{



	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
//		  alert(xmlHttp.responseText);
//		document.getElementById('questionnaire').innerHTML=xmlHttp.responseText;
		location.reload(true);
		//location='';
      }
    }
	xmlHttp.open("GET",'move_questions.php?rand='+Math.random()+'&qlinkid='+sval+'&up_down='+up_down,true);
	xmlHttp.send(null);
}

function save_comment(ph,commv)
{
	q=q_array[q_pos];
	
if(IsNumeric(q))
{
url="save_comments.php?ph="+ph+"&q="+q+"&randval="+Math.random()+'&comm='+commv; 
}
else
{
url="save_comments.php?ph="+ph+"&q="+q+"&s=1&randval="+Math.random()+'&comm='+commv;
}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
//		  alert(xmlHttp.responseText);
      }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function save_rating(ph,rate)
{
	q=q_array[q_pos];
	
if(IsNumeric(q))
{
url="save_ratings.php?ph="+ph+"&q="+q+"&randval="+Math.random()+'&rate='+rate; 
}
else
{
url="save_ratings.php?ph="+ph+"&q="+q+"&s=1&randval="+Math.random()+'&rate='+rate;
}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
//		  alert(xmlHttp.responseText);
      }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function select_final(obj,ph)
{
	q=q_array[q_pos];
	
if(IsNumeric(q))
{
url="save_sel_ques.php?ph="+ph+"&q="+q+"&randval="+Math.random()+'&sel='+obj.checked; 
}
else
{
url="save_sel_ques.php?ph="+ph+"&q="+q+"&s=1&randval="+Math.random()+'&sel='+obj.checked;
}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
//		  alert(xmlHttp.responseText);
/*	if(xmlHttp.responseText>4)
	document.forms[0].final_but.disabled=false;
	else
	document.forms[0].final_but.disabled=true;
	*/
/*document.getElementById('final_button_div').style.display='block';
else
document.getElementById('final_button_div').style.display='none';*/
      }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function select_all_none(obj,objid)
{
	val=obj.innerHTML.toLowerCase();
	
	if(val=='<u>select all</u>'){
	checkval=true;
	obj.innerHTML='<u>Unselect All</u>';
	}
	else{
	checkval=false;
	obj.innerHTML='<u>Select All</u>';
	}
	
		pObj=document.getElementsByName(objid);

		if (pObj.length)
		{
			for (var iCount=0; iCount<pObj.length; iCount++)
				pObj [ iCount ].checked =checkval;
		}
		else
		{
			pObj.checked=checkval;
		}

}
function select_doh(ph,val,obj)
{
q=q_array[q_pos];
var qold;
switch(val)
{
	case '1st area':
	qold='first_doh';
	break;
	case '2nd area':
	qold='second_doh';
	break;
	case '3rd area':
	qold='third_doh';
	break;
	case 'Need Improving':
	qold='need_doh';
	break;
}

qoq=document.getElementById(qold).innerHTML;

obj.selectedIndex=0;
if(qoq.replace('&nbsp;','')!='')
{
	ans=confirm('Would you  like to replace question '+qoq.replace('&nbsp;','')+' with '+q+' in your final letter?');

if(!ans)
return;

}
field=qold.replace('_doh','');

var url='doh_letter_table.php?ph='+ph+'&dohfield='+field+'&'+field+'='+q+'&qq_name='+document.forms[0].qq_name.value+'&rnd='+Math.random()+'&year='+document.forms[0].year.value;


	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  document.getElementById("doh_table").innerHTML=xmlHttp.responseText;
		  
		  if((document.getElementById('first_doh').innerHTML).replace('&nbsp;','')!='' && (document.getElementById('second_doh').innerHTML).replace('&nbsp;','')!='' && (document.getElementById('third_doh').innerHTML).replace('&nbsp;','')!='' && (document.getElementById('need_doh').innerHTML).replace('&nbsp;','')!='')
	{	  	document.forms[0].final_but.disabled=false;
	document.forms[0].final_but.style.background="url('images/submit_button_bg.gif')";
	}
	else
	{
		document.forms[0].final_but.disabled=true;
		document.forms[0].final_but.style.background="url('images/submit_button_bg_gray.gif')";
	}

      }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
};

/***/
function click_option_left(ph,obj)
{
var val=obj.innerHTML;
q=q_array[q_pos];

extpos="";

empty_field="";

chk_q=document.getElementById('first_doh').innerHTML;
chk_q=chk_q.replace('&nbsp;','');
if(q==chk_q)
{
//	alert("You have already added this question in your final letter");
//	return;
extpos="1st";
empty_field="first";
}

chk_q=document.getElementById('second_doh').innerHTML;
chk_q=chk_q.replace('&nbsp;','');
if(q==chk_q)
{
//	alert("You have already added this question in your final letter");
//	return;
extpos="2nd";
empty_field="second";
}

chk_q=document.getElementById('third_doh').innerHTML;
chk_q=chk_q.replace('&nbsp;','');
if(q==chk_q)
{
//	alert("You have already added this question in your final letter");
//	return;
extpos="3rd";
empty_field="third";
}


chk_q=document.getElementById('need_doh').innerHTML;
chk_q=chk_q.replace('&nbsp;','');
if(q==chk_q)
{
//	alert("You have already added this question in your final letter");
//	return;
extpos="Need Improving";
empty_field="need";
}

var qold;
switch(val)
{
	case '1st area':
	qold='first_doh';
	break;
	case '2nd area':
	qold='second_doh';
	break;
	case '3rd area':
	qold='third_doh';
	break;
	case 'Need Improving':
	qold='need_doh';
	break;
}

qoq=document.getElementById(qold).innerHTML;

if(qoq.replace('&nbsp;','')!='')
{
	if(extpos!="")
	ans=confirm('You have already selected this question, would you like to insert this as '+(val.split(' '))[0]+' place?');
	else
	ans=confirm('Would you  like to replace question '+qoq.replace('&nbsp;','')+' with '+q+' in your final letter?');

if(!ans)
return;
}
else if(extpos!=""){

ans=confirm('You have already selected this question, would you like to insert this as '+(val.split(' '))[0]+' place?');

if(!ans)
return;
}

field=qold.replace('_doh','');

var url='doh_letter_table.php?ph='+ph+'&dohfield='+field+'&'+field+'='+q+'&qq_name='+document.forms[0].qq_name.value+'&rnd='+Math.random()+'&year='+document.forms[0].year.value+'&empty_field='+empty_field;


	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  document.getElementById("doh_table").innerHTML=xmlHttp.responseText;
		  
		  		  
		  if((document.getElementById('first_doh').innerHTML).replace('&nbsp;','')!='' && (document.getElementById('second_doh').innerHTML).replace('&nbsp;','')!='' && (document.getElementById('third_doh').innerHTML).replace('&nbsp;','')!='' && (document.getElementById('need_doh').innerHTML).replace('&nbsp;','')!='')
		  	document.forms[0].final_but.disabled=false;
	else
	document.forms[0].final_but.disabled=true;
	
		  hide_left_menu();
		  
		  if(document.forms[0].comm)
		  {
			  cmndval=document.forms[0].comm.value;
			  document.getElementById("inner_popup").innerHTML=document.getElementById("view_comments").innerHTML;
			  document.getElementById("inner_popup_txt").innerHTML="You have selected the results from question <b>"+q+"</b> to be including in your final DoH letter, please enter brief comments to describe your performance in this area. These comments will be used to create the DoH letter. When you have finished click on the close icon to continue.";
			  document.getElementById("view_comments").innerHTML='';
			  document.getElementById("view_comments").style.display='none';
			  document.forms[0].comm.value=cmndval;
			  showLayerPopup();
		  }
		  //alert(document.getElementById("view_comments").offsetTop);
		  
		  //document.forms[0].comm.focus();
		  
      }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


/***/

function finalize_report(ph)
{
var first_doh=document.getElementById('first_doh').innerHTML;
var second_doh=document.getElementById('second_doh').innerHTML;
var third_doh=document.getElementById('third_doh').innerHTML;
var need_doh=document.getElementById('need_doh').innerHTML;
var error=0;
var url='final_step2.php?ph='+ph+'&qq_type='+document.forms[0].qq_name.value+'&rnd='+Math.random()+'&year='+document.forms[0].year.value;

if(first_doh.replace('&nbsp;','')!='')
url+='&first='+first_doh.replace('&nbsp;','');
else
error=1;

if(second_doh.replace('&nbsp;','')!='')
url+='&second='+second_doh.replace('&nbsp;','');
else
error=1;

if(third_doh.replace('&nbsp;','')!='')
url+='&third='+third_doh.replace('&nbsp;','');
else
error=1;

if(need_doh.replace('&nbsp;','')!='')
url+='&need='+need_doh.replace('&nbsp;','');
else
error=1;

if(error==1)
{
	alert('Please Select Questions for DoH Letter');
	return;
}

document.location=url;

}

function check()
{var s1=0;
op=document.forms[0].pwd.value;
np=document.forms[0].newpass.value;
cp=document.forms[0].conpass.value;

if(op=="")
{
alert("Please type your old password");
document.forms[0].pwd.focus();
return false;
}
if(np=="")
{
alert("Please type your new password");
document.forms[0].newpass.focus();
return false;
}
if (np!=cp)
{
mesg ="Please verify your new password and confirm password";
alert(mesg);
forms[0].conpass.focus();
return false;
}

else if (np==cp || np!="" || cp!="")
{
return true;
//document.review.submit();
}

return true;
}

function change_pass()
{
if(!check())
return false;

var url='account_change.php';
var parameters;

parameters="conpass="+document.forms[0].conpass.value+"&usn="+document.forms[0].usn.value+"&usid="+document.forms[0].usid.value+"&pwd="+document.forms[0].pwd.value+"&newpass="+document.forms[0].newpass.value+"&pid="+document.forms[0].pid.value+"&type="+document.forms[0].type.value;


	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	 
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  document.forms[0].conpass.value=document.forms[0].newpass.value=document.forms[0].pwd.value='';
			document.getElementById('msg_pass').innerHTML=xmlHttp.responseText;
      }
    }
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}



/*function gotonext_all(ph)
{
q=q_array[q_pos+1];

disp_question(0,q);

cur_q=q_pos;
if(cur_q==q_array.length-2)
{
	q_prv=0;
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}
else
{
	q_prv=0;
	q_bprv=0;
	q_anxt=q_array[q_pos+2];
	q_nxt=q_array[q_pos+1];
}
get_four_images_all(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"next",0);

}

function gotoprev_all(ph)
{
	q=q_array[q_pos-1];

disp_question(0,q);

cur_q=q_pos;
if(cur_q==1)
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=0;
}
else
{
	q_prv=q_array[q_pos-1];
	q_bprv=q_array[q_pos-2];
	q_anxt=0;
	q_nxt=0;
}
get_four_images_all(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"prev",0);

}
*/

/***********/

function set_benmark_head(obj,val)
{
var url;

ca_check='';
na_check='';
ba_check='';
pa_check='';
pya_check='';

if(val=='ca_check')
{
	ca_check=obj.checked;
if(ca_check)
selectall(document.getElementsByName('ca_check[]'));
else
unselectall(document.getElementsByName('ca_check[]'));
}

if(val=='na_check')
{
	na_check=obj.checked;
if(na_check)
selectall(document.getElementsByName('na_check[]'));
else
unselectall(document.getElementsByName('na_check[]'));
}

if(val=='ba_check')
{
	ba_check=obj.checked;
if(ba_check)
selectall(document.getElementsByName('ba_check[]'));
else
unselectall(document.getElementsByName('ba_check[]'));
}

if(val=='pa_check')
{
	pa_check=obj.checked;
if(pa_check)
selectall(document.getElementsByName('pa_check[]'));
else
unselectall(document.getElementsByName('pa_check[]'));
}

if(val=='pya_check')
{
	pya_check=obj.checked;
if(pya_check)
selectall(document.getElementsByName('pya_check[]'));
else
unselectall(document.getElementsByName('pya_check[]'));
}


url="setph_ben_head.php?ca_check="+ca_check+"&na_check="+na_check+"&pa_check="+pa_check+"&ba_check="+ba_check+"&pya_check="+pya_check+"&randval="+Math.random();

	xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
		  showLayer();
	change_charts_head();

//gotochart_all(ph,q_array[q_pos]);
      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}

function set_benmark_buy(obj,val)
{
var url;

ca_check='';
na_check='';
ba_check='';
pa_check='';
pya_check='';

if(val=='ca_check')
{
	ca_check=obj.checked;
if(ca_check)
selectall(document.getElementsByName('ca_check[]'));
else
unselectall(document.getElementsByName('ca_check[]'));
}

if(val=='na_check')
{
	na_check=obj.checked;
if(na_check)
selectall(document.getElementsByName('na_check[]'));
else
unselectall(document.getElementsByName('na_check[]'));
}

if(val=='ba_check')
{
	ba_check=obj.checked;
if(ba_check)
selectall(document.getElementsByName('ba_check[]'));
else
unselectall(document.getElementsByName('ba_check[]'));
}

if(val=='pa_check')
{
	pa_check=obj.checked;
if(pa_check)
selectall(document.getElementsByName('pa_check[]'));
else
unselectall(document.getElementsByName('pa_check[]'));
}

if(val=='pya_check')
{
	pya_check=obj.checked;
if(pya_check)
selectall(document.getElementsByName('pya_check[]'));
else
unselectall(document.getElementsByName('pya_check[]'));
}



url="setph_ben_buy.php?ca_check="+ca_check+"&na_check="+na_check+"&pa_check="+pa_check+"&ba_check="+ba_check+"&pya_check="+pya_check+"&randval="+Math.random();

	xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
showLayer();
change_charts_buy();

//gotochart_buy(ph,q_array[q_pos]);

      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}

function change_charts_head()
{
	url='all_charts_head.php?year='+document.forms[0].year.value+'&randval='+Math.random();
var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
		  if((xmlHttpe.responseText).search("<b>Warning</b>:")>=0)
		  {
			  page_redirect()
			  return;
		  }
		  
  		if(document.getElementById('chart'))
		lfmargin=document.getElementById('chart').style.marginLeft;
		else
		lfmargin='256px';

		document.getElementById('all_charts').innerHTML=xmlHttpe.responseText;
		document.getElementById('chart').style.marginLeft='1000 px';
		document.getElementById('chart').style.marginLeft=lfmargin;
		document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

	if(document.getElementById('container_'+q_array[q_pos-1]))
{
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
	for(var sleepi=0;sleepi<10;sleepi++)
	sleepi=sleepi;
	
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-2;
}
gotochart_all(ph,q_array[q_pos]);

//disp_nxt_prv_btn();
      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}

function change_charts_buy()
{
	url='all_charts_buy.php?year='+document.forms[0].year.value+'&randval='+Math.random();
var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
		  if((xmlHttpe.responseText).search("<b>Warning</b>:")>=0)
		  {
			  page_redirect()
			  return;
		  }
		  
  		if(document.getElementById('chart'))
		lfmargin=document.getElementById('chart').style.marginLeft;
		else
		lfmargin='256px';
		document.getElementById('all_charts').innerHTML=xmlHttpe.responseText;
		document.getElementById('chart').style.marginLeft='1000 px';
		document.getElementById('chart').style.marginLeft=lfmargin;
		document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

	if(document.getElementById('container_'+q_array[q_pos-1]))
{
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
	for(var sleepi=0;sleepi<10;sleepi++)
	sleepi=sleepi;
	
	document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-2;
}
gotochart_all(ph,q_array[q_pos]);
//disp_nxt_prv_btn();
      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}

/*****************/


function get_four_images(ph,q_bprv,q_prv,cur_q,q_nxt,q_anxt,slideopt,not_nxt_prv,val,dist)
{
nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";

	
//	var url="get_four_images.php?q="+q_bprv+"&q="+q_prv+"&q="+cur_q+"&q="+q_nxt+"&q="+q_anxt+"&ph="+ph+"&&randval="+Math.random();

//	var url="get_four_images.php?q="+q+"&ph="+ph+"&&randval="+Math.random();
var rnd=parseInt(Math.random()*100);

var parameters="q1="+q_bprv+"&q2="+q_prv+"&q3="+cur_q+"&q4="+q_nxt+"&q5="+q_anxt+"&ph="+ph+"&randval="+Math.random()+"&rnd="+rnd;
//alert(parameters);
//	return;
	
	var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {

		ret_txt=(xmlHttpe.responseText).split("*****");
		if(q_bprv!=0)
		{
			$part=ret_txt[0].split("########");
			document.getElementById('graph_'+(q_array[q_pos-2])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos-2])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos-2])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos-2])).borderColor='#ECECEC';
			
		}
		if(q_prv!=0)
		{
			$part=ret_txt[1].split("########");
			
			if(slideopt=="prev")
			$part[0]=$part[0].replace("gray","");
			
			document.getElementById('graph_'+(q_array[q_pos-1])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos-1])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos-1])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos-1])).borderColor='#ECECEC';
				
			if(slideopt=="prev")
			{
				document.getElementById('total_'+(q_array[q_pos-1])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos-1])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos-1])).borderColor='#AFD8F8';
			}
			
		}
		if(cur_q!=0)
		{
			
			$part=ret_txt[2].split("########");
			
			if(slideopt=="same")
			$part[0]=$part[0].replace("gray","");

			document.getElementById('graph_'+(q_array[q_pos])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos])).borderColor='#ECECEC';
			
			if(slideopt=="same")
			{
				document.getElementById('total_'+(q_array[q_pos])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos])).borderColor='#AFD8F8';
			}
			
		}
		if(q_nxt!=0)
		{
			$part=ret_txt[3].split("########");
			
			if(slideopt=="next")
			$part[0]=$part[0].replace("gray","");
			
			document.getElementById('graph_'+(q_array[q_pos+1])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos+1])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos+1])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos+1])).borderColor='#ECECEC';
				
			if(slideopt=="next")
			{
				document.getElementById('total_'+(q_array[q_pos+1])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos+1])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos+1])).borderColor='#AFD8F8';
			}
			
		}
		if(q_anxt!=0)
		{
			$part=ret_txt[4].split("########");
			document.getElementById('graph_'+(q_array[q_pos+2])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos+2])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos+2])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos+2])).borderColor='#ECECEC';
			
		}
		
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';

if(not_nxt_prv==1 && slideopt=="next")
{

if(document.getElementById('container_'+q_array[val]))
document.getElementById('container_'+q_array[val]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos+1]))
document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos-1]))
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-dist+'px';


}
else if(not_nxt_prv==1 && slideopt=="prev")
{
	if(document.getElementById('container_'+q_array[val]))
document.getElementById('container_'+q_array[val]).style.top='0px';


if(document.getElementById('container_'+q_array[q_pos+1]))
{
	document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-1;
}
if(document.getElementById('container_'+q_array[q_pos-1]))
{
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
}

if(document.getElementById('container_'+q_array[q_pos]))
{
	document.getElementById('container_'+q_array[q_pos]).style.top='20px';
	document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
}
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+dist+'px';



}
		sleep(1000);
		
		if(slideopt=="next")
		movel(400);
		else if(slideopt=="prev")
		mover(400);
		else if(slideopt=="same")
		disp_nxt_prv_btn();
		

      }
    }
	xmlHttpe.open("POST",'get_four_images.php',true);
	xmlHttpe.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpe.setRequestHeader("Content-length", parameters.length);
	xmlHttpe.setRequestHeader("Connection", "close");
	xmlHttpe.send(parameters);
	
}

/*
function gotochart(ph,q)
{

val=q_array.findIndex(q);

disp_question(ph,q);



if(val==q_pos)
{
document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

if(q_pos==0)
{
	q_prv=0;
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}
else if(q_pos==q_array.length-1)
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=0;
}
else
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}

get_four_images(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"same");

}
else if(val>q_pos)
{
	
	if(val==(q_pos+1))
	{
		gotonext(ph);
		return;
	}
dist=((val-q_pos)-1)*407;

cur_q=val-1;
q_pos=val-1;
if(cur_q==q_array.length-2)
{
	q_prv=q_array[val-2];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[val];
}
else
{
	q_prv=q_array[val-2];
	q_bprv=0;
	q_anxt=q_array[val+1];
	q_nxt=q_array[val];
}
get_four_images(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"next",1,val,dist);


	}
else
{
	
	if(val==(q_pos-1))
	{
		gotoprev(ph);
		return;
	}
	
	dist=((q_pos-val)-1)*407;
	
cur_q=val+1;
q_pos=val+1;
if(cur_q==1)
{
	q_prv=q_array[val];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[val+2];
}
else
{
	q_prv=q_array[val];
	q_bprv=q_array[val-1];
	q_anxt=0;
	q_nxt=q_array[val+2];
}
	
get_four_images(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"prev",1,val,dist);

	}
}*/

function selectall(obj)
{
		pObj=obj;

		if (pObj.length)
		{
			for (var iCount=0; iCount<pObj.length; iCount++)
				pObj [ iCount ].checked =true;
		}
		else
		{
			pObj.checked=true;
		}

}

function unselectall(obj)
{
		pObj=obj;

		if (pObj.length)
		{
			for (var iCount=0; iCount<pObj.length; iCount++)
				pObj [ iCount ].checked =false;
		}
		else
		{
			pObj.checked=false;
		}

}

function get_four_images_all(ph,q_bprv,q_prv,cur_q,q_nxt,q_anxt,slideopt,not_nxt_prv,val,dist)
{

nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";
	
var rnd=parseInt(Math.random()*10);

var parameters="q1="+q_bprv+"&q2="+q_prv+"&q3="+cur_q+"&q4="+q_nxt+"&q5="+q_anxt+"&ph="+ph+"&randval="+Math.random()+"&rnd="+rnd;
	
	var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
		  
		ret_txt=(xmlHttpe.responseText).split("*****");
		if(q_bprv!=0)
		{
			$part=ret_txt[0].split("########");
			document.getElementById('graph_'+(q_array[q_pos-2])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos-2])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos-2])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos-2])).borderColor='#ECECEC';
			
		}
		if(q_prv!=0)
		{
			$part=ret_txt[1].split("########");
			
			if(slideopt=="prev")
			$part[0]=$part[0].replace("gray","");
			
			document.getElementById('graph_'+(q_array[q_pos-1])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos-1])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos-1])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos-1])).borderColor='#ECECEC';
				
			if(slideopt=="prev")
			{
				document.getElementById('total_'+(q_array[q_pos-1])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos-1])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos-1])).borderColor='#AFD8F8';
			}
			
		}
		if(cur_q!=0)
		{
			
			$part=ret_txt[2].split("########");
			
			if(slideopt=="same")
			$part[0]=$part[0].replace("gray","");

			document.getElementById('graph_'+(q_array[q_pos])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos])).borderColor='#ECECEC';
			
			if(slideopt=="same")
			{
				document.getElementById('total_'+(q_array[q_pos])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos])).borderColor='#AFD8F8';
			}
			
		}
		if(q_nxt!=0)
		{
			$part=ret_txt[3].split("########");
			
			if(slideopt=="next")
			$part[0]=$part[0].replace("gray","");
			
			document.getElementById('graph_'+(q_array[q_pos+1])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos+1])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos+1])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos+1])).borderColor='#ECECEC';
				
			if(slideopt=="next")
			{
				document.getElementById('total_'+(q_array[q_pos+1])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos+1])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos+1])).borderColor='#AFD8F8';
			}
			
		}
		if(q_anxt!=0)
		{
			$part=ret_txt[4].split("########");

			document.getElementById('graph_'+(q_array[q_pos+2])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos+2])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos+2])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos+2])).borderColor='#ECECEC';
			
		}
		
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';

if(not_nxt_prv==1 && slideopt=="next")
{

if(document.getElementById('container_'+q_array[val]))
document.getElementById('container_'+q_array[val]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos+1]))
document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos-1]))
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-dist+'px';


}
else if(not_nxt_prv==1 && slideopt=="prev")
{
	if(document.getElementById('container_'+q_array[val]))
document.getElementById('container_'+q_array[val]).style.top='0px';


if(document.getElementById('container_'+q_array[q_pos+1]))
{
	document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-1;
}
if(document.getElementById('container_'+q_array[q_pos-1]))
{
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
}

if(document.getElementById('container_'+q_array[q_pos]))
{
	document.getElementById('container_'+q_array[q_pos]).style.top='20px';
	document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
}
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+dist+'px';

}
				sleep(1000);
		
		if(slideopt=="next")
		movel(400);
		else if(slideopt=="prev")
		mover(400);
		else if(slideopt=="same")
		disp_nxt_prv_btn();
		

      }
    }
	xmlHttpe.open("POST",'get_four_images_all.php',true);
	xmlHttpe.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpe.setRequestHeader("Content-length", parameters.length);
	xmlHttpe.setRequestHeader("Connection", "close");
	xmlHttpe.send(parameters);
	
}
/*
function gotochart_all(ph,q)
{

val=q_array.findIndex(q);

disp_question(0,q);



if(val==q_pos)
{
document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

if(q_pos==0)
{
	q_prv=0;
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}
else if(q_pos==q_array.length-1)
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=0;
}
else
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}

get_four_images_all(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"same");

}
else if(val>q_pos)
{
	
	if(val==(q_pos+1))
	{
		gotonext(ph);
		return;
	}
dist=((val-q_pos)-1)*407;

cur_q=val-1;
q_pos=val-1;
if(cur_q==q_array.length-2)
{
	q_prv=q_array[val-2];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[val];
}
else
{
	q_prv=q_array[val-2];
	q_bprv=0;
	q_anxt=q_array[val+1];
	q_nxt=q_array[val];
}
get_four_images_all(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"next",1,val,dist);


	}
else
{
	
	if(val==(q_pos-1))
	{
		gotoprev(ph);
		return;
	}
	
	dist=((q_pos-val)-1)*407;
	
cur_q=val+1;
q_pos=val+1;
if(cur_q==1)
{
	q_prv=q_array[val];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[val+2];
}
else
{
	q_prv=q_array[val];
	q_bprv=q_array[val-1];
	q_anxt=0;
	q_nxt=q_array[val+2];
}
	
get_four_images_all(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"prev",1,val,dist);

	}
}


function gotochart_buy(ph,q)
{

val=q_array.findIndex(q);

disp_question(0,q);



if(val==q_pos)
{
document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

if(q_pos==0)
{
	q_prv=0;
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}
else if(q_pos==q_array.length-1)
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=0;
}
else
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}

get_four_images_buy(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"same");

}
else if(val>q_pos)
{
	
	if(val==(q_pos+1))
	{
		gotonext(ph);
		return;
	}
dist=((val-q_pos)-1)*407;

cur_q=val-1;
q_pos=val-1;
if(cur_q==q_array.length-2)
{
	q_prv=q_array[val-2];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[val];
}
else
{
	q_prv=q_array[val-2];
	q_bprv=0;
	q_anxt=q_array[val+1];
	q_nxt=q_array[val];
}
get_four_images_buy(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"next",1,val,dist);


	}
else
{
	
	if(val==(q_pos-1))
	{
		gotoprev(ph);
		return;
	}
	
	dist=((q_pos-val)-1)*407;
	
cur_q=val+1;
q_pos=val+1;
if(cur_q==1)
{
	q_prv=q_array[val];
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[val+2];
}
else
{
	q_prv=q_array[val];
	q_bprv=q_array[val-1];
	q_anxt=0;
	q_nxt=q_array[val+2];
}
	
get_four_images_buy(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"prev",1,val,dist);

	}
}

function gotonext_buy(ph)
{
q=q_array[q_pos+1];

disp_question(0,q);

cur_q=q_pos;
if(cur_q==q_array.length-2)
{
	q_prv=0;
	q_bprv=0;
	q_anxt=0;
	q_nxt=q_array[q_pos+1];
}
else
{
	q_prv=0;
	q_bprv=0;
	q_anxt=q_array[q_pos+2];
	q_nxt=q_array[q_pos+1];
}
get_four_images_buy(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"next",0);

}

function gotoprev_buy(ph)
{
	q=q_array[q_pos-1];

disp_question(0,q);

cur_q=q_pos;
if(cur_q==1)
{
	q_prv=q_array[q_pos-1];
	q_bprv=0;
	q_anxt=0;
	q_nxt=0;
}
else
{
	q_prv=q_array[q_pos-1];
	q_bprv=q_array[q_pos-2];
	q_anxt=0;
	q_nxt=0;
}
get_four_images_buy(ph,q_bprv,q_prv,q_array[q_pos],q_nxt,q_anxt,"prev",0);

}
*/
function get_four_images_buy(ph,q_bprv,q_prv,cur_q,q_nxt,q_anxt,slideopt,not_nxt_prv,val,dist)
{

nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";
	
var rnd=parseInt(Math.random()*10);

var parameters="q1="+q_bprv+"&q2="+q_prv+"&q3="+cur_q+"&q4="+q_nxt+"&q5="+q_anxt+"&ph="+ph+"&randval="+Math.random()+"&rnd="+rnd;
	
	var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
		  
		ret_txt=(xmlHttpe.responseText).split("*****");
		if(q_bprv!=0)
		{
			$part=ret_txt[0].split("########");
			document.getElementById('graph_'+(q_array[q_pos-2])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos-2])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos-2])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos-2])).borderColor='#ECECEC';
			
		}
		if(q_prv!=0)
		{
			$part=ret_txt[1].split("########");
			
			if(slideopt=="prev")
			$part[0]=$part[0].replace("gray","");
			
			document.getElementById('graph_'+(q_array[q_pos-1])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos-1])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos-1])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos-1])).borderColor='#ECECEC';
				
			if(slideopt=="prev")
			{
				document.getElementById('total_'+(q_array[q_pos-1])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos-1])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos-1])).borderColor='#AFD8F8';
			}
			
		}
		if(cur_q!=0)
		{
			
			$part=ret_txt[2].split("########");
			
			if(slideopt=="same")
			$part[0]=$part[0].replace("gray","");

			document.getElementById('graph_'+(q_array[q_pos])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos])).borderColor='#ECECEC';
			
			if(slideopt=="same")
			{
				document.getElementById('total_'+(q_array[q_pos])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos])).borderColor='#AFD8F8';
			}
			
		}
		if(q_nxt!=0)
		{
			$part=ret_txt[3].split("########");
			
			if(slideopt=="next")
			$part[0]=$part[0].replace("gray","");
			
			document.getElementById('graph_'+(q_array[q_pos+1])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos+1])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos+1])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos+1])).borderColor='#ECECEC';
				
			if(slideopt=="next")
			{
				document.getElementById('total_'+(q_array[q_pos+1])).style.background='#DEEEFE';
				document.getElementById('first_tr_'+(q_array[q_pos+1])).style.background='#AFD8F8';
				document.getElementById('data_table_'+(q_array[q_pos+1])).borderColor='#AFD8F8';
			}
			
		}
		if(q_anxt!=0)
		{
			$part=ret_txt[4].split("########");

			document.getElementById('graph_'+(q_array[q_pos+2])).innerHTML="<br><table align='center'><tr><th><img src='"+$part[0]+"' align='center' width='600' height='300'></td></tr></table>"+$part[1];
			
				document.getElementById('total_'+(q_array[q_pos+2])).style.background='#D2D2D2';
				document.getElementById('first_tr_'+(q_array[q_pos+2])).style.background='#ECECEC';
				document.getElementById('data_table_'+(q_array[q_pos+2])).borderColor='#ECECEC';
			
		}
		
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';

if(not_nxt_prv==1 && slideopt=="next")
{

if(document.getElementById('container_'+q_array[val]))
document.getElementById('container_'+q_array[val]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos+1]))
document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos-1]))
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='20px';

document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-dist+'px';


}
else if(not_nxt_prv==1 && slideopt=="prev")
{
	if(document.getElementById('container_'+q_array[val]))
document.getElementById('container_'+q_array[val]).style.top='0px';


if(document.getElementById('container_'+q_array[q_pos+1]))
{
	document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-1;
}
if(document.getElementById('container_'+q_array[q_pos-1]))
{
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
}

if(document.getElementById('container_'+q_array[q_pos]))
{
	document.getElementById('container_'+q_array[q_pos]).style.top='20px';
	document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
}
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+dist+'px';

}
		
				sleep(1000);
		if(slideopt=="next")
		movel(400);
		else if(slideopt=="prev")
		mover(400);
		else if(slideopt=="same")
		disp_nxt_prv_btn();
		

      }
    }
	xmlHttpe.open("POST",'get_four_images_buy.php',true);
	xmlHttpe.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpe.setRequestHeader("Content-length", parameters.length);
	xmlHttpe.setRequestHeader("Connection", "close");
	xmlHttpe.send(parameters);
	
}

function sleep(milliSeconds){
	var startTime = new Date().getTime(); // get the current time
	while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}


function view_DoHLetter(url)
{
	url=url+'?randval='+Math.random();
	var xmlHttpe=GetXmlHttpObject();
	if (xmlHttpe==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
 
  xmlHttpe.onreadystatechange=function()
    {
    if(xmlHttpe.readyState==4)
      {
	document.getElementById('DoH_Preview').style.display='block';
	document.getElementById('DoH_Preview').innerHTML=xmlHttpe.responseText;

      }
    }
	xmlHttpe.open("GET",url,true);
	xmlHttpe.send(null);
}


function gotochart_all(ph,q)
{

hideLayer();

val=q_array.findIndex(q);

disp_question(0,q);


if(val==q_pos)
{
	
		nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";
	
document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
document.getElementById('container_'+q_array[q_pos]).style.top='40px';
disp_nxt_prv_btn();
}
else if(val>q_pos)
{

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='0px';

dist=((val-q_pos)-1)*427;

q_pos=val-1;

if(document.getElementById('container_'+q_array[q_pos+1]))
document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos-1]))
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';

if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='40px';


document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)-dist+'px';

movel(400);



	}
else
{
	
if(document.getElementById('container_'+q_array[q_pos]))
document.getElementById('container_'+q_array[q_pos]).style.top='0px';

dist=((q_pos-val)-1)*427;

q_pos=val+1;


if(document.getElementById('container_'+q_array[q_pos+1]))
{
	document.getElementById('container_'+q_array[q_pos+1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos+1]).style.zIndex=-1;
}
if(document.getElementById('container_'+q_array[q_pos-1]))
{
document.getElementById('container_'+q_array[q_pos-1]).style.top='0px';
		document.getElementById('container_'+q_array[q_pos-1]).style.zIndex=-1;
}

if(document.getElementById('container_'+q_array[q_pos]))
{
	document.getElementById('container_'+q_array[q_pos]).style.top='40px';
	document.getElementById('container_'+q_array[q_pos]).style.zIndex=2;
}
document.getElementById('chart').style.marginLeft=parseInt(document.getElementById('chart').style.marginLeft)+dist+'px';


mover(400);

	}

}

function gotonext_all(ph)
{
q=q_array[q_pos+1];

	nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";

disp_question(ph,q);
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';
movel(400);
}

function gotoprev_all(ph)
{
	q=q_array[q_pos-1];

	nxt_btnonclick=document.getElementById("nxt_btn").onclick;
prv_btnonclick=document.getElementById("prv_btn").onclick;

	document.getElementById("nxt_btn").onclick="";
	document.getElementById("prv_btn").onclick="";

disp_question(ph,q);
document.getElementById('mask_prev').style.display='none';
document.getElementById('mask_next').style.display='none';
mover(400);
}



function gotochart_buy(ph,q)
{

gotochart_all(0,q);

}

function gotonext_buy(ph)
{
gotonext_all(ph);
}

function gotoprev_buy(ph)
{
gotoprev_all(ph);
}

function view_loading()
{
			var obj = document.getElementById("shadow");
 
		var lngObjHeight = 0;
		var lngObjWidth =0; 
		var lngWinHeight;
		var lngWinWidth;
		var lngXOffset;
		var lngYOffset;
		// Netscape implementation
		if(navigator.appName == "Netscape") {
			var lngObjHeight =window.innerHeight;
			var lngObjWidth =window.innerWidth; 
			lngWinHeight = window.innerHeight;
			lngWinWidth = window.innerWidth;
			lngYOffset = window.pageYOffset;
			lngXOffset = window.pageXOffset;
 
			obj.style.top = ( lngWinHeight + lngYOffset - lngObjHeight );
			obj.style.left = ( lngWinWidth + lngXOffset - lngObjWidth );
		}
 
		// MSIE implementation
		if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Mac") == -1) {
			var lngObjHeight =document.body.clientHeight;
			var lngObjWidth =document.body.clientWidth; 
			lngWinHeight = document.body.clientHeight;
			lngWinWidth = document.body.clientWidth;
			lngYOffset = document.body.scrollTop;
			lngXOffset = document.body.scrollLeft;
 
			obj.style.top = ( lngWinHeight + lngYOffset - lngObjHeight );
			obj.style.left = ( lngWinWidth + lngXOffset - lngObjWidth );
		}
	

var loader1=document.getElementById("loader1");

var bws = getBrowserHeight();
var left_pos = parseInt((bws.width - 100) / 2);
var top_pos = parseInt((bws.height - 100) / 2);

obj.style.width = bws.width + "px";
obj.style.height = bws.height + "px";

obj.style.display='block';

loader1.style.left=parseInt(obj.style.left)+left_pos;
loader1.style.top=parseInt(obj.style.top)+top_pos;
loader1.style.display='block';



}
function hide_loading()
{
	var loader=document.getElementById("loader1");
	loader1.style.display='none';
	var obj = document.getElementById("shadow");
	obj.style.display='none';
}
function change_qq_list(year,ph,req)
{
showLayer();
var url="list_qq.php?ph="+ph+"&year="+year+"&rnd="+Math.random()+"&req="+req;

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
 	 alert ("Your browser does not support AJAX!");
 	 return;
 	} 
	  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
    {
		document.getElementById("list_qq_drop").innerHTML=xmlHttp.responseText;
		hideLayer();
     }
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function cancelEvent(e) {
    if (!e) e = window.event;
    if (e.preventDefault) {
        e.preventDefault();
    } else {
        e.returnValue = false;
    }
}
var page_redirect_incr=0;
function page_redirect()
{
	if(page_redirect_incr==0){
	page_redirect_incr++;
	alert("Your session has been expired, Please login again to continue.");
	document.location='logout.php';
	}
}
