// JavaScript Document


function login()
{
document.getElementById("status").style.visibility = "visible";
document.getElementById("result").innerHTML=''
var username=document.getElementById("user").value;
var pass =document.getElementById("password").value;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="adminlogindb.php"
url=url+"?username=" + username
url=url+"&password=" + pass;
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=Status
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function Status()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("status").style.visibility = "hidden";
if(xmlHttp.responseText=='1')
{
	
document.getElementById("yes").style.visibility = "visible";
window.location="http://www.globaltcsd.com/branch/home.php"
}
else
{
document.getElementById("result").innerHTML=xmlHttp.responseText;
document.getElementById("password").value='';
}
}
}
// Common files
function QpaperDownload()
{

PageLoding('Page');

xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {	
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var url="Q_PaperDownloadfile.php"
	xmlHttp.onreadystatechange=CerPageResult;
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);
}



function Cpicker(id) {
					$('#'+id).ColorPicker({
								onChange: function (hsb, hex, rgb) {
										$('#'+id).val('#' + hex);
										$('#'+id).css('background-color','#' + hex);
										}
								});
						  
						   }
						   
						   
						   


function datepid(id)
{
dateset(id)
 $('#'+id).DatePicker({
	format:'Y/m/d',
	date: $('#'+id).val(),
	current: $('#'+id).val(),
	starts: 1,
	position: 'r',
	onBeforeShow: function(){
		$('#'+id).DatePickerSetDate($('#'+id).val(), true);
	},
	onChange: function(formated, dates){
		$('#'+id).val(formated);
		if ($('#closeOnSelect input').attr('checked')) {
			$('#'+id).DatePickerHide();
		}
	}
});
}

	   
var Exh=0;
var Colh=0;
var flag=0;
var Objh=350;
var tv=350;
var tv1=0;
function setfun()
{	if(flag==0){expand();flag=1;}
	else{collaps();flag=0;}}
	
function collaps()
	{if(Objh-parseInt(Exh)>0)
	{Exh=Exh+10;
	document.getElementById("Expmenu").style.height=Objh-parseInt(Exh)+"px"
	document.getElementById("Expmenu1").style.height=parseInt(tv1+Exh)+"px"
	Ctime=setTimeout("collaps()",30);}
	else{document.getElementById("Expmenu").style.height=0+"px";clearTimeout(Ctime);Exh=0;}
}
function expand()
{if(Colh<Objh)
		{Colh=Colh+10;
		document.getElementById("Expmenu").style.height=parseInt(Colh)+"px"
		document.getElementById("Expmenu1").style.height=parseInt(tv-Colh)+"px"
		Ct=setTimeout("expand()",30);}
		else{clearTimeout(Ct);Colh=0;}
}

function statusshowt(sid,bid)
{
	document.getElementById(sid).innerHTML='<img src="images/status.gif" id="imgstatus" style="visibility:visible;" />'
	document.getElementById(bid).disabled=true;

}
function statusshowf(sid,bid)
{
	document.getElementById(sid).innerHTML='<img src="images/status.gif" id="imgstatus"  style="visibility:hidden;" />'
	document.getElementById(bid).disabled=false;

}

//...............................................

function dateset(id)
{
		var d = new Date();
		var curr_date = d.getDate();
		var curr_month = d.getMonth();
		curr_month++;
		var curr_year = d.getFullYear();
		var dt=curr_year+'/'+ curr_month +'/'+ curr_date;
		document.getElementById(id).value=dt;	
}
	

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 PageLoding(ID)
{	
	
	document.getElementById(ID).innerHTML='<img src="images/pagelader.gif" />';
	
}
function CloseWindow(Id)
{
	document.getElementById(Id).innerHTML='';	
}
function SubpageResult() 
{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 		
		 
			 document.getElementById("SubPage").innerHTML=xmlHttp.responseText; 
			 tblcolouring()
			
		 } 
}