var xmlhttp;
var progressText1="<div style=\"width:530px;height:350px;font-size:16px;color:#ed0e0f;margin:auto;padding-top:170px;text-align:center;\">";
var progressText2="<div>Requesting...<br/>";
var progressText3="<img src=\"Images/ALoader.gif\"></img></span></div></div>";
var progressText;

function createXMLHttpRequest()
{var XHRtype;
if (window.XMLHttpRequest)
	{//Firefox, Opera, IE7, etc.
	XHRtype=new XMLHttpRequest();}
	else if (window.ActiveXObject)
	{//for IE6, IE5
	XHRtype=new ActiveXObject("Microsoft.XMLHTTP");
	if(XHRtype==null) {XHRtype= new ActiveXObject("Msml2.XMLHTTP");}
	}
return XHRtype;
}

function loadURL(url,id)
{xmlhttp=null;
progressText=progressText1+progressText2+progressText3;
document.getElementById(id).innerHTML=progressText;
xmlhttp=createXMLHttpRequest();
	if (xmlhttp!=null)
	{xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState<=1)
			{progressText2="<div>Initializing...<br/>";
			progressText=progressText1+progressText2+progressText3;
			document.getElementById(id).innerHTML=progressText;
			}
		else if(xmlhttp.readyState==2)
			{progressText2="<div>Requesting...<br/>";
			progressText=progressText1+progressText2+progressText3;
			document.getElementById(id).innerHTML=progressText;}
		else if(xmlhttp.readyState==3)
			{progressText2="<div>Processing...<br/>";
			progressText=progressText1+progressText2+progressText3;
			document.getElementById(id).innerHTML=progressText;}
		else if(xmlhttp.readyState==4)
			{progressText2="<div>Loading...<br/>";
			progressText=progressText1+progressText2+progressText3;
			document.getElementById(id).innerHTML=progressText;
			if (xmlhttp.status==200)
				{$('#'+id).fadeIn('slow',0.0);
				document.getElementById(id).innerHTML=xmlhttp.responseText;
				$('#'+id).fadeIn('fast',1.0);}
			else
				{progressText2="<div>Problem in retrieving the Data. Try after some time.<br/>If problem persists then check your connection.<br/>";
				progressText=progressText1+progressText2+progressText3;
				document.getElementById(id).innerHTML=progressText;}
			}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);}
	else
	{document.getElementById('T1').innerHTML=progressText1+"Your browser does not support XMLHTTP.</div>";}
}

function state_Change1()
{if(xmlhttp.readyState<=1)
	{progressText2="<div>Initializing...<br/>";
	progressText=progressText1+progressText2+progressText3;
	document.getElementById('T1').innerHTML=progressText;}
else if(xmlhttp.readyState==2)
	{progressText2="<div>Requesting...<br/>";
	progressText=progressText1+progressText2+progressText3;
	document.getElementById('T1').innerHTML=progressText;}
else if(xmlhttp.readyState==3)
	{progressText2="<div>Processing...<br/>";
	progressText=progressText1+progressText2+progressText3;
	document.getElementById('T1').innerHTML=progressText;}
else if(xmlhttp.readyState==4)
	{progressText2="<div>Loading...<br/>";
	progressText=progressText1+progressText2+progressText3;
	document.getElementById('T1').innerHTML=progressText;
	if (xmlhttp.status==200)
		{document.getElementById('T1').innerHTML=xmlhttp.responseText;}
	else
		{progressText2="<div>Problem in retrieving the Data. Try after some time.<br/>If problem persists then check your connection.<br/>";
		progressText=progressText1+progressText2+progressText3;
		document.getElementById('T1').innerHTML=progressText;}
	}
}

var min=10;
var max=20;
function increaseFontSize(Id) {
	//var p = document.getElementById('T1').getElementByTagName('p');
	//for(i=0;i<p.length;i++){
		p=document.getElementById('T1');
		if(p.style.fontSize){
		var s = parseInt(p.style.fontSize.replace("px",""));}
		else{var s = 12;}
	if(s!=max){s += 1;}
	p.style.fontSize = s+"px";
	//p[i].style.lineHeight=s+"px";
	}
//var s=parseInt($('#'+Id).css('font-size').replace('px',''));
//if(s!=max){s=s+1;}
//$('#'+Id+' p').css("font-size",s+"px");
//}
function decreaseFontSize(){
	var p = document.getElementById('T1');
	
		if(p.style.fontSize){
		var s = parseInt(p.style.fontSize.replace("px",""));
		}else{
		var s = 12;
		}
		if(s!=min){s -= 1;}
		p.style.fontSize = s+"px"
		//p[i].style.lineHeight=(s+1)+"px";
}
//$().ready(function(){$('#menu').$('ul')});

function searchGoogle()
{//http = createXMLHttpRequest();
cx="partner-pub-9146228250709930:fkjy0p-8vbh";
ie="ISO-8859-1";
sa="Search"
q=document.getElementById('QS').value;
searchString="http://www.google.co.in/cse?cx="+cx+"&ie="+ie+"&q="+q+"&sa="+sa;
var newWindow = window.open(searchString,'_blank');
newWindow.focus();
//http.onreadystatechange = state_Change1();
//http.open('GET',searchString,true);
//http.send(null);
}
function openURL(url)
{var newWindow=window.open(url,'_blank');
newWindow.focus();
}
$(document).ready(function()
{
$('#Register').click(function(){showPopup('Content/register.txt')});
$('#Login').click(function(){showLogin()});
$('#LoginB').mouseleave(function(){$('#LoginBox').fadeOut('slow');});
//loadURL('Content/Projects/Centres/Dhanbad/Centre1.html','T1');
loadURL('Content/home.html','T1');          //by default home page-------
$('#EduNews').load('Content/News/NoticeBoard.html');
ajaxLoad('Content/News/SDCNews.html','SDCNews');
ajaxLoad('Content/News/HTNews.html','HTNews');

//ajaxLoad('Content/News/ProjectNews.html','ProjectNews');
/*$('#Sliding2').mouseover(function(){$('#Pre').show('slow');
								$('#Nex').show('slow');//$('#Sliding2 li img').css('width',220+'px');
								}).mouseout(function(){$('#Pre').hide('slow');
								$('#Nex').hide('slow');//$('#Sliding2 li img').css('width',275+'px');
						});*/
//$('#SpSlider').carousel('#LS','#RS','scroll');
$('#Sliding2').carousel('#previous','#next');
function slide(){
$('#next').click();
}
//$('#SponsorTheChild').hover($('#SpSlider').hover());
$jScroller.config.refresh = 1;
$jScroller.add("#imgSlider","#Sliding","left",1);
  $jScroller.start();

var intervalId = window.setInterval(slide, 3500);

});

//var logintoggle=-1;
function showLogin()
{/*
if(logintoggle==0){$('#LoginBox').fadeTo('fast',0.9);logintoggle=1;}
	else if(logintoggle==1){$('#LoginBox').fadeTo('slow',0.0);logintoggle=0;}
	else{$('#LoginBox').css('display','block');
		$('#LoginBox').fadeTo('fast',0.9);logintoggle=1;
	}*/
	$("#LoginBox").css({"opacity": "0.90"});
	$('#LoginBox').slideToggle('fast');
}

function ajaxLoad(url,id)
{
$('#'+id).load(url);
//$('#'+id).ajaxStart(progressText);
}

function showPopup(url)
{/*
$('#Popup').slideToggle('fast');
$('#PopupContent').css('display','block');*/
ajaxLoad(url,'PopupContent');
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#PopupContent").height();
var popupWidth = $("#PopupContent").width();
//centering
$("#PopupContent").css({
"top": (windowHeight-202)/2,
"left": (windowWidth-734)/2
});
//only need force for IE6

$("#Popup").css({
"height": windowHeight
});
$("#Popup").css({"opacity": "0.75"});
$("#Popup").show("fast");
$("#PopupContent").show("fast");
}

/*function animateSlide()
{p=$('#Sliding');
var s= parseInt($('#Sliding').css('left').replace('px',''));
if(
$('#Sliding').animate({left:1px},'slow');
}
*/
//$(document).ready(setInterval(animateSlide,500));
/*
var query = new Object();
	window.location.search.replace(
	new RegExp( "([^?=&]+)(=([^&]*))?", 'g' ),
		function( $0, $1, $2, $3 ){
			query[ $1 ] = $3;
		}
	);
	easing = query['e'] || 'Expo';
	
	function loadEasing(e) {
		location.href = location.pathname+'?e='+e;
	}
	
	function setEasing(e) {
		loadLamps(e);
	}

function loadLamps(easing) {
$('#menu').lavaLamp({
	fx: 'easeInOut'+easing,
	speed: 1000,
	returnHome: true,
	homeLeft: -100,
	homeTop: -25,
	homeWidth:1134px,
	homeHeight:45px
	});
	}*/

var hlRotate = function(){
currHL=(oldHL+1)%hlCount;
}

function closeDiv()
{$('#Popup').hide('slow');
$('#PopupContentWrapper').hide('slow');
$('#PopupContent').hide('slow');
}
//$(document).ready($("#Sliding").jCarouselLite({
  //  auto: 800,
    //speed: 1000
//}));



/*
stepcarousel.setup({
	galleryid: 'mygallery', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:false, persist:true},
	defaultbuttons: {enable: true, moveby: 1, leftnav: ['http://i34.tinypic.com/317e0s5.gif', -5, 80], rightnav: ['http://i38.tinypic.com/33o7di8.gif', -20, 80]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})
*/
function doLogin()
{
var uname,pass
uname=document.getElementById('uname1').value;
pass=document.getElementById('pass1').value;
var turl="http://www.kartavya.org/test3_old/inputs.asp?uname="+uname+"&pass="+pass+"&fwpage=index.asp&curpage=logform";
var neww = window.open(turl,'_blank');
neww.focus();
}
function GGUrlOpen(url)
{targeturl="http://groups.google.com/group/"+url+"/";
var newWindow = window.open(targeturl,'_blank');
newWindow.focus();
}