var isIE = false;
var doc="document.";
var st="";

if(navigator.appName == "Microsoft Internet Explorer")	{ doc += "all."; st=".style"; isIE=true; }

/*  Start Of Alpha Class  */

function Colour(r,g,b){
	this.Red = r;
	this.Green = g;
	this.Blue = b;
}

function SetOpacity(opacity){
var r, g, b;
	if(opacity>0 && opacity<100){
		r = parseInt(this.FgColour.Red + (this.DelC.Red*(100-opacity))/100);
		g = parseInt(this.FgColour.Green + (this.DelC.Green*(100-opacity))/100);
		b = parseInt(this.FgColour.Blue + (this.DelC.Blue*(100-opacity))/100);
		this.Target.style.color = "rgb("+r+","+g+","+b+")";
	}
	else if(opacity>=100)
		this.Target.style.color = "rgb("+this.FgColour.Red+","+this.FgColour.Green+","+this.FgColour.Blue+")";
	else if(opacity<=0)
		this.Target.style.color = "rgb("+this.BgColour.Red+","+this.BgColour.Green+","+this.BgColour.Blue+")";
	this.Opacity = opacity;
}

function Alpha(object,FgC,BgC){
	this.Target = object;	// The object being affected.
	this.BgColour = BgC;	// Background Colour.
	this.FgColour = FgC;	// Foreground Colour.
	// Delta Colour (Difference of FgC and BgC)
	this.DelC = new Colour((BgC.Red - FgC.Red), (BgC.Green - FgC.Green), (BgC.Blue - FgC.Blue));
	this.Opacity = 100;
	this.SetOpacity = SetOpacity;
}

/*  End Of Alpha Class  */

var Part_1;
var Part_2;
var Inc=true;
var CurrentQuote=0;
function Swing(){
var Quotes1 = new Array("असतो मा।", "तमसो मा।", "मृत्‌र्यो मा।");
var Quotes2 = new Array("सदगमय॥", "ज्योतिर्गमय॥", "अमृतंगमय॥");
//		alert(Part_1.Opacity);
	if(Part_1.Opacity >= 100){
		Part_2.Target.innerHTML = Quotes2[CurrentQuote];
		CurrentQuote++;
		if(CurrentQuote > Quotes1.length-1) CurrentQuote = 0;
		Inc = false;
	}
	else if(Part_1.Opacity <= 0){
		Part_1.Target.innerHTML = Quotes1[CurrentQuote];
		Inc = true;
	}
	if(Inc){
		Part_1.SetOpacity(Part_1.Opacity + 10);
		Part_2.SetOpacity(Part_2.Opacity - 10);
	}
	else{
		Part_1.SetOpacity(Part_1.Opacity - 10);
		Part_2.SetOpacity(Part_2.Opacity + 10);
	}

	if(Part_1.Opacity == 100 || Part_1.Opacity == 0)
		setTimeout("Swing()", 3000);
	else
		setTimeout("Swing()", 75);
}

var morn_time = 2;
var Morning = false;
function fadin(){
var fc,bc;
	if (isIE){
		document.all.title_img.filters.item(0).duration = morn_time;
		document.all.title_img.filters.item(0).Apply()
		document.all.title_img.filters.item(0).Play() 
		document.all.title_img.style.visibility = "visible";
		fc=new Colour(255,255,224);
		bc=new Colour(102,0,0);
		Part_1=new Alpha(document.all.part1,fc,bc);
		Part_2=new Alpha(document.all.part2,fc,bc);
		Part_1.SetOpacity(0);
		Part_2.SetOpacity(100);
		setTimeout("Swing();Morning = true;", morn_time*1000);
		
	}
	else
		document.title_img.visibility = "visible";
}

var Back_Pose = -80;
function scrollitems(){
	Back_Pose += 4;
//	eval(doc + "back_screen" + st + ".top = '" + Back_Pose + "px'");
	eval("document.body.style.backgroundPosition = '0px " + Back_Pose + "px'");
	if(Back_Pose < 0)
		setTimeout("scrollitems()",100);
	else
		fadin();
}

function init(){
	eval(doc + "title_img" + st + ".visibility='hidden'");
	eval(doc + "back_screen" + st + ".top='-80px';");
	scrollitems();
}


var X_Pos=1;
var Y_Pos=1;
var Max_Width=1;
var Max_Height=1;
var Delta=1;
var Current_Pos=0;
var Follow_Mouse=false;
function Set_Pos(x, y){
	X_Pos=document.body.scrollLeft + x;
	Y_Pos=document.body.scrollTop + y;
}

function Revolve(){
	Max_Width=window.document.body.offsetWidth/6;
	Max_Height=window.document.body.offsetHeight/6;
	if(!Follow_Mouse)
		Set_Pos(Max_Width*3, Max_Height)
	for(var index=0; index<14; index++){
		Left_Pos=X_Pos+Max_Width*Math.sin((Current_Pos+index*3)/10)*Math.sin(Current_Pos/200);
		Top_Pos=Y_Pos+Max_Height*Math.sin((Current_Pos+index*4)/12)*Math.cos(400+Current_Pos/200);
		document.getElementById('Star'+index).style.left=Left_Pos;
		document.getElementById('Star'+index).style.top=Top_Pos;
	}

	Current_Pos+=Delta;
	if(!Morning)
		setTimeout("Revolve()",50);
	else
		for(var index=0; index<14; index++){
			document.getElementById('Star'+index).style.left=-50;
			document.getElementById('Star'+index).style.top=-50;
		}
}

function Handle_Mouse(){
	Set_Pos(event.x, event.y)
}

function init_revolve(){
var Part_Color=new Array('ff00ff','00ff00','0000ff','ffffff','fff000','ff00ff','00ff00','0000ff','ffa000','FF0000','ffffff','fff000','ffa000','FF0000');
var Particles='';
	Particles+='<div id="Galaxy" style="position:absolute;top:0px;left:0px;z-index:10;">';
	for(var index=0; index<14; index++){
			Particles+='<div id="Star'+ index + '" style="position:relative;width:' + ((index<7)?1:(index<13)?2:3) + 'px;height:' + ((index<7)?1:(index<13)?2:3) + 'px;background:#' + Part_Color[index] + ';font-size:' + ((index<7)?1:(index<13)?2:3) + 'px;visibility:visible"></div>';
	}
	Particles+='</div>';
	document.write(Particles);

	if(Follow_Mouse)
		document.onmousemove=Handle_Mouse;
	Revolve();
}
