// JavaScript Document



//************* Ajax *****************
function GetXmlHttpObject()
{
	var xmlHttp=null;
	//document.getElementById("ajax_loading").style.visibility = "visible";
	try{
	// Firefox, Opera 8.0+, Safari
		xmlHttp= new XMLHttpRequest();
	}
	catch (e){
	// Internet Explorer
		try{  //Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");			
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");			
		}
		/*var ms = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
        for (var i in ms) {
         try {
        	 xmlHttp = ActiveXObject(ms[i]);
        	 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        	 xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");

        	 
                break;
          } catch(e) {
        	  
          }
        }*/
		
	}
	return xmlHttp;
}


function reloadLinkArray(page, mode)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=reloadLinkArray";
	url= url+'&page='+page;
	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('importantLinks').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('importantLinks').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function reloadSectorPid(pid)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_sector.php?m=sector&mode=sector_pid";
	url=url+"&pid="+pid;	
	
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('list_sector').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('list_sector').innerHTML = "<img src=../images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}
function reload_sectors(sectorid)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_sector.php?m=sector&mode=sectors";
	url=url+"&sectorid="+sectorid;	
	
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4)
			{			
				document.getElementById('sector_content').innerHTML = xmlHttp.responseText;
				
				$$('input.DatePicker').each( function(el){
					new DatePicker(el);
				});

				
			}
			else
			{
				document.getElementById('sector_content').innerHTML = "<img src=../images/loading.gif>";
			}		
			
		}
	
	xmlHttp.send(null);
}

function outputSectors(sectorid,menuid)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	//var url="ajax_controller.php?mode=resource";
	var url="ajax_subcontroller.php?mode=resource";
	url=url+"&sectorid="+sectorid;
	url=url+"&menuid="+menuid;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
		{
			if(xmlHttp.readyState == 4)
			{			
				document.getElementById('outputsectors').innerHTML = xmlHttp.responseText;
				$$('input.DatePicker').each( function(el){
					new DatePicker(el);
				});

				
			}
			else
			{
				document.getElementById('outputsectors').innerHTML = "<img src=images/loading.gif>";
			}		
			
		}
	
/*	if((document.getElementById('listSectorsTohide'))!=null){
		
		document.getElementById('listSectorsTohide').style.display ='none';
	
	}*/
	
	
	xmlHttp.send(null);
}

function reloadPid(id)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_sector.php?m=law&mode=menu_id";
	url=url+"&id="+id;	
	
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('ListSector').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('ListSector').innerHTML = "<img src=../images/loading.gif>";
		}		
		
	}

	xmlHttp.send(null);
}




function reloadMenuContent(id,limit)
{
	
	
	if(limit==undefined){
		limit=2;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=menucontent";
	url=url+"&id="+id;	
	url=url+"&page="+limit;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{						
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function reloadgallery(page, mode)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=gallery";
	url= url+'&page='+page;
	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function filter(sector,menu,option)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	//var url="ajax_controller.php?mode=filter";
	var url="ajax_subcontroller.php?mode=filter";
	url= url+'&sector='+sector;
	url= url+'&menu='+menu;
	url= url+'&option='+option;

	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			//document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			document.getElementById('relatedLaw').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			//document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
			document.getElementById('relatedLaw').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}



function reloadContactForm(id)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=contactForm";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			/*document.getElementById('mainBodyField').innerHTML = xmlHttp.responseText;
			var ids = [ "name", "organization", "feedback" ];
			control_language.makeTransliteratable(ids);
			call_jquery();*/
			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function getsector(sectorid)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=resource";
	url=url+"&sectorid="+sectorid;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('mainBodyField').innerHTML = xmlHttp.responseText;
		
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}



function white_space(field)
{
     //field.value = (field.value).replace(/^\s*|\s*$/g,'');
	 return field.replace(/^\s*|\s*$/g,'');
}






function reloadHomeContent(id,field,tot_id)
{
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=home";
	url=url+"&id="+id;	
	
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			for(var i=0; i<tot_id; i++)
			{
				if(i!=field)
				{
					var content = document.getElementById('homeContent_field_'+i).innerHTML;
					//alert(content);
					var substr = content.substr(0,150);
					document.getElementById('homeContent_field_'+i).innerHTML = substr;
					//document.getElementById('homeContent_field_'+i).style.display = "none";
				}
				
			}
			//document.getElementById('homeContent_field_'+field).style.display = "block";
			document.getElementById('homeContent_field_'+field).innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('homeContent_field_'+field).innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function checkFeedback()
{
	var feedback = document.feedback_frm.feedback.value;
		
	if(feedback == "")
	{
		/*document.getElementById("err_feedback").style.color = "#FF0000";*/
		document.getElementById("err_feedback").innerHTML = "Please enter feedback";		
		document.feedback_frm.feedback.focus();
		return false;
	}
	document.getElementById('err_feedback').style.display="none";
	return true;
	
}
function checkSecurityCode()
{
	var security_code = document.feedback_frm.security_code.value;
	
	if(security_code == "")
	{
		/*document.getElementById("err_code").style.color = "#FF0000";*/
		document.getElementById("err_code").innerHTML = "Please enter security code";		
		document.feedback_frm.security_code.focus();
		return false;
	}
	document.getElementById('err_code').style.display="none";
	return true;
	
}





function reloadLoginForm(id)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=LoginForm";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}


function addFeedback()
{

	var name = document.feedback_frm.name.value;
	var subject = document.feedback_frm.subject.value;
	var organization = document.feedback_frm.organization.value;
	//var country = document.feedback_frm.country.value;
	var feedback = document.feedback_frm.feedback.value;
	//var committee = document.feedback_frm.committee.value;	
	
//	for (var i=0; i < document.feedback_frm.citizen.length; i++)
//   	{
//   		if (document.feedback_frm.citizen[i].checked)
//      {
//      	var rad_val = document.feedback_frm.citizen[i].value;
//		break;
//      }
//   	}

	var security_code = document.feedback_frm.security_code.value;
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	//alert("terst");
	//alert(committee);
	var url="ajax_controller.php?mode=feed";
	url=url+"&feedback="+feedback;	
	url=url+"&name="+name;
	url=url+"&subject="+subject;
	//url=url+"&committee="+committee;
	url=url+"&organization="+organization;
	//url=url+"&citizen="+rad_val;	
	url=url+"&security_code="+security_code;
	
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			//document.getElementById('feeback_result_field').innerHTML = xmlHttp.responseText;
			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('feeback_result_field').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}


function addComFeedback()
{

	var name = document.feedback_frm.name.value;
	var subject = document.feedback_frm.subject.value;
	var organization = document.feedback_frm.organization.value;
	var country = document.feedback_frm.country.value;
	var feedback = document.feedback_frm.feedback.value;
	var cid = document.feedback_frm.cid.value;	
	
	for (var i=0; i < document.feedback_frm.citizen.length; i++)
   	{
   		if (document.feedback_frm.citizen[i].checked)
      {
      	var rad_val = document.feedback_frm.citizen[i].value;
		break;
      }
   	}

	var security_code = document.feedback_frm.security_code.value;
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	//alert("terst");
	//alert(committee);
	var url="ajax_controller.php?mode=feed";
	url=url+"&feedback="+feedback;	
	url=url+"&name="+name;
	url=url+"&subject="+subject;
	url=url+"&cid="+cid;
	url=url+"&organization="+organization;
	url=url+"&citizen="+rad_val;	
	url=url+"&security_code="+security_code;
	
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('feeback_result_field').innerHTML = xmlHttp.responseText;
		}
		else
		{
			document.getElementById('feeback_result_field').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function UserLogin()
{

	var username = document.feedback_frm.username.value;
	var password = document.feedback_frm.password.value;
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=login";
	url=url+"&username="+username;	
	url=url+"&password="+password;
	
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			//document.getElementById('feeback_result_field').innerHTML = xmlHttp.responseText;
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}



function reloadProfile(id)
{

	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="ajax_controller.php?mode=profile";
	url=url+"&id="+id;	
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function reloadNews(id)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=news";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}


function reloadNewsPage(id)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=ListNews";
	url=url+"&page="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('news').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('news').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}



function reloadSubMenu(field,id)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=submenu";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('submenu_field_'+field).innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('submenu_field_'+field).innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}



function searchcontent(id)
{
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=searchcontent";
	url=url+"&id="+id;	
	
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function reloadStaffContent(id)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=menucontent";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function reloadLawContent(id)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	//var url="ajax_controller.php?mode=readmoreLaw";
	var url="ajax_subcontroller.php?mode=readmoreLaw";
	url=url+"&id="+id;	

	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			//document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			document.getElementById('relatedLaw').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			//document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
			document.getElementById('relatedLaw').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function reloadNotice(id)
{
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=notice";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}





function reloadReadmoreProfile(page, mode)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode="+mode+"&page="+page;
			
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}


function reloadNewsArray(page, mode)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode="+mode+"&page="+page;
			
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('newsColumn').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('newsColumn').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function viewAllNotice(page, mode)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode="+mode+"&page="+page;
			
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('notice_board').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('notice_board').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

function viewAllArticle(page, mode)
{

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode="+mode+"&page="+page;
			
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{					
			document.getElementById('article').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('article').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}

/*function reloadContent(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_reloadContent.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}*/

function reloadContent(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	if(id==1){
		var url="ajax_tab_creator.php?id="+id;	
		//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('home_tabs').style.display = 'none';
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
					countries.setpersist(false)
					countries.setselectedClassTarget("link") //"link" or "linkparent"
					countries.init()
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	}else{	
			var url="ajax_reloadContent.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					document.getElementById('home_tabs').style.display =  "none";
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	}
	xmlHttp.send(null);
	
}

function reloadHoeDoContent(){
	
	
	var ids= document.getElementById('howdoi').value;
	if(ids==''){
			return false;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_reloadHoeDoContent.php?id="+ids;
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			//alert(xmlHttp.responseText);
			document.getElementById('updates').innerHTML = xmlHttp.responseText;
			document.getElementById('home_tabs').style.display =  "none";
			
		}
		else
		{
			document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
	
}

function Toggle(id){
	
	
	//document.getElementById("updates").childNodes[0].nodeValue;
	//alert(document.getElementById("Parent").childNodes.length);
	//alert(document.getElementById('updates').getElementsByTagName("div").length);
	
	var lengths= document.getElementById('updates').getElementsByTagName("div").length;
	for(i=1;i<=lengths;i++){
		if(i == id){
			
			document.getElementById("toggle"+i).style.display='block';
			//togglePannelAnimatedStatus(document.getElementById("toggle"+i),50,50);
			
			
		}else{
			document.getElementById("toggle"+i).style.display='none';
			
			
		}
	}

}

function ToggleGallery(id){
	
	if( document.getElementById("galspanHid"+id).style.display == 'none' ){
		document.getElementById("galspanHid"+id).style.display = 'block';
	}else{
		document.getElementById("galspanHid"+id).style.display = 'none';
	}
	
	
	var lengths= document.getElementById('updates').getElementsByTagName("span").length;
	togglePannelAnimatedStatus(document.getElementById("galspan"+id),50,50);

	

}


function togglePannelAnimatedStatus(content, interval, step)
{
    // wait for another animated expand/collapse action to end
    
    
        currentContent = content;
        var expand = (content.style.display=="none");
        if (expand)
            content.style.display = "block";
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
       // toggleChevronIcon(content);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus(" + interval + "," + step + "," + max_height + "," + step_height + ")", interval);
    
}

function togglePannelAnimatingStatus(interval, step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus(" + interval + "," + step + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}

// change chevron icon into either collapse or expand
function toggleChevronIcon(content)
{
    var chevron = content.parentNode
        .firstChild.childNodes[1].childNodes[0];
    var expand = (chevron.src.indexOf("expand.gif")>0);
    chevron.src = chevron.src
        .split(expand ? "expand.gif" : "collapse.gif")
        .join(expand ? "collapse.gif" : "expand.gif");
}



function reloadLink(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_reloadLink.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					document.getElementById('home_tabs').style.display =  "none";
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}

function reloadGalleryLightbox(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_reloadGalleryLightbox.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{								
					document.getElementById('imagecontent').innerHTML = xmlHttp.responseText;					
					center('overlayss','mybox');										
					
				}
				else
				{
					//document.getElementById('mainBodyField').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}



function reloadFedback(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_feedback.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					document.getElementById('home_tabs').style.display =  "none";
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}

function reloadComFedback(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_controller.php?mode=reloadComFeedback";
			url = url+"&id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('mainBodyField').innerHTML = xmlHttp.responseText;
					//document.getElementById('home_tabs').style.display =  "none";
					var ids = [ "name", "organization", "feedback" ];
					control_language.makeTransliteratable(ids);
					call_jquery();
					
				}
				else
				{
					document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}

function reloadForms(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_onlineForm.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					document.getElementById('home_tabs').style.display =  "none";
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}

function reloadFaq(id){
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	
			var url="ajax_faq.php?id="+id;
	
			//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
			xmlHttp.onreadystatechange = function()
			{
				if(xmlHttp.readyState == 4)
				{			
					//alert(xmlHttp.responseText);
					document.getElementById('updates').innerHTML = xmlHttp.responseText;
					document.getElementById('home_tabs').style.display =  "none";
					
				}
				else
				{
					document.getElementById('updates').innerHTML = "<img src=images/loading.gif>";
				}		
				
			}
	
	
	xmlHttp.send(null);
	
}


function doSearch(offset,serachtxt,mode){
 	if(serachtxt==''){
		return false;
	}
	//serachtxt	= document.getElementById('s').value;
	document.getElementById('s').value='';
	
	
xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=search";
	url=url+"&id="+serachtxt;
	url=url+"&page="+offset;
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);

}

function SearchResource(id)
{
	
	xmlHttp=GetXmlHttpObject();
	//xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    
	 
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="ajax_controller.php?mode=resource";
	url=url+"&id="+id;		
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			//alert(xmlHttp.responseText);
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);
}


function SearchProfile(offset,searchbyname,searchbyparty){
  
	
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=searchProfile";
	url=url+"&searchbyname="+searchbyname;
	url=url+"&searchbyparty="+searchbyparty;
	url=url+"&offset="+offset;
	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);

}



function getArchive(tbl){
  
	
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=archive";
	url=url+"&tbl="+tbl;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);

}

function showArchive(page,mode){	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?page="+page+"&mode=showArchive";
	
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);

}

function reloadArticle(id){	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	var url="ajax_controller.php?mode=reloadArticle";
	url=url+"&id="+id;	
		
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{			
			document.getElementById('wlecometext').innerHTML = xmlHttp.responseText;
			
		}
		else
		{
			document.getElementById('wlecometext').innerHTML = "<img src=images/loading.gif>";
		}		
		
	}
	xmlHttp.send(null);

}


function ToggleCountry(conrol,val){
	
	document.getElementById(conrol).style.display = val;
	
/*	if(document.getElementById(conrol).style.display =='none'){
		document.getElementById(conrol).style.display='block';
	}else{
		document.getElementById(conrol).style.display='none';
	}*/
}



	
function hideDiv(frmDiv,Msgbox)
{
	document.getElementById('overlayss').style.display='none';
	document.getElementById(frmDiv).style.display='none';
	//document.getElementById(Msgbox).style.display='none';
	
	document.getElementById('howdoi').style.display =  "block";
	document.getElementById('tricktxt').style.display =  "none";
}
	
function BrowserInfo()	
{
	if(navigator.userAgent.indexOf("Opera")!=-1){
	return 2;
	}else
	if(navigator.userAgent.indexOf("MSIE")!=-1){
		return 3;
	}else
	  if(navigator.userAgent.indexOf("Firefox")!=-1){
		return 19;
	  }
}
		
function getPageSizeWithScroll()
{ 
	if (window.innerHeight && window.scrollMaxY) {// Firefox         
	  yWithScroll = window.innerHeight + window.scrollMaxY;         
	  xWithScroll = window.innerWidth + window.scrollMaxX;     
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac         
	  yWithScroll = document.body.scrollHeight;         
	  xWithScroll = document.body.scrollWidth;     
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
	  yWithScroll = document.body.offsetHeight;         
	  xWithScroll = document.body.offsetWidth;       
	}     
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);     
	// alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll ); 
	return yWithScroll; 
} 

function center(Divname,Formbox)
{

//alert(document.getElementById(Divname).screenY);

	var my_width  = 0;
	var my_height = 0;
	var decreaseWidth = 0;
	decreaseWidth = BrowserInfo();
	
	if ( typeof( window.innerWidth ) == 'number' ){
		my_width  = window.innerWidth;
		my_height = window.innerHeight;
	}else if ( document.documentElement && 
			 ( document.documentElement.clientWidth ||
			   document.documentElement.clientHeight ) ){
		my_width  = document.documentElement.clientWidth;
		my_height = document.documentElement.clientHeight;
	}
	else if ( document.body && 
			( document.body.clientWidth || document.body.clientHeight ) ){
		my_width  = document.body.clientWidth;
		my_height = document.body.clientHeight;
	}
	my_new_height = getPageSizeWithScroll();

	
	
	document.getElementById(Divname).style.position = 'absolute';
	document.getElementById(Divname).style.zIndex   = 99;
	document.getElementById(Divname).style.display='block';
	
	document.getElementById(Formbox).style.position = 'absolute';
	document.getElementById(Formbox).style.zIndex   = 99;
	//document.getElementById(Formbox).style.display='block';
	gradient(Formbox, 0);
	fadein(Formbox);
 
	
	var scrollY = 0;
	
	if ( document.documentElement && document.documentElement.scrollTop ){
		scrollY = document.documentElement.scrollTop;
	}else if ( document.body && document.body.scrollTop ){
		scrollY = document.body.scrollTop;
	}else if ( window.pageYOffset ){
		scrollY = window.pageYOffset;
	}else if ( window.scrollY ){
		scrollY = window.scrollY;
	}
	
	
	var divWidth = document.getElementById(Formbox).offsetWidth;
	var divHeight = document.getElementById(Formbox).offsetHeight;
	
	

	
	var setX = ( my_width  - divWidth  ) / 2;
	var setY = ( my_height - divHeight ) / 2 +scrollY;
	
	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;
	

	
	document.getElementById(Divname).style.left = 0 + "px";
	document.getElementById(Divname).style.top  = 0 + "px";
	//document.getElementById(Divname).style.height= (my_new_height + my_height - 270)+ "px";
	//document.getElementById(Divname).style.width= (my_width - decreaseWidth) + "px";
	document.getElementById(Divname).style.height= (my_new_height)+ "px";
	document.getElementById(Divname).style.width= (my_width) + "px";
	
	
	
	document.getElementById(Formbox).style.left = setX + "px";
	document.getElementById(Formbox).style.top  = setY + "px";
	//element.style.left = setX + "px";
	//element.style.top  = setY + "px";*/
}
	
	
function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}
	

function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}

var control_language;

function TranslateLanguage() 
{
//alert("test");

var options = {
				sourceLanguage: 'en', // or google.elements.transliteration.LanguageCode.ENGLISH,
				destinationLanguage: ['hi'], // or [google.elements.transliteration.LanguageCode.HINDI],
				shortcutKey: 'ctrl+g',
				transliterationEnabled: true
				
			};
// Create an instance on TransliterationControl with the required
// options.

//alert(typeof control_language);
if(typeof control_language=='undefined')
{
	control_language = new google.elements.transliteration.TransliterationControl(options);
}
// Enable transliteration in the textfields with the given ids.
var ids = [ "name", "organization", "feedback" ];
control_language.makeTransliteratable(ids);


}



function showWizard(output)
{
	//alert("test");
	//jQuery('#jqi').width('550');
	//JOUE('div').attr( {width: ('80px'} );
		
	
	var temp = {
	
	
		state0: {
			html:'<p>Please click on the download link to download questionaire.</p><p><a href=\'ajax_controller.php?mode=downloadQuestion&q='+output+'\'>Download >></a></p>',
			buttons: {Cancel: 0},
			focus: 1,
			submit:function(v,m,f)
			{ 
				if(v==0) 
				{
				jQuery.ImpromptuClose()
				}
				else if(v==1)
				{
					$.ajax({
					type: 'POST',
					url: 'ajax_controller.php?mode=downloadQuestion&q='+output,
					success: function(data) 
					{
						//alert(data);
						jQuery.ImpromptuClose();
						//alert("Email sent successfully");
				
					}
					});
		
		//$.ImpromptuGoToState('state1');//go forward	
		//return true;
				}
		
				return false; 
			}
		}
		,
		
		state1: {
		
			html:'<p>Are u sure you want to email this post.</p>',
			buttons: {Back:-1, Finish:1},
			focus: 1,
			submit:function(v,m,f)
			{ 
				if(v==0) 
				{
					jQuery.ImpromptuClose()
				}
				else if(v==-1)
				{
					$.ImpromptuGoToState('state0');//go back
				}
				else if(v==1)
				{
					str = "";
					$.each(f,function(i,obj){
					str += i + " - <em>" + obj + "</em><br />";
					});	
				
					$.ajax({
					type: 'POST',
					url: 'ajax_controller.php?mode=sendQuestion&q='+str,
					success: function() 
					{
						jQuery.ImpromptuClose();
						alert("Email sent successfully");					
					}
					});
				
				//$.ImpromptuGoToState('state1');//go forward	
				//return true;
				}
			
				return false; 
			}
		}
	
	}
	
	$.prompt(temp,{
		callback: function(v,m,f){
		var str = "Your questions has been emailed successfully";
		//$.prompt(str);
		}
	
	});
	
	
			
}


	
	
	
