// JavaScript Document
var enamer=0;
var team_name;
var flag=0;
var selected=0;
var pre=0;
var dflag=0;
var timer,timer1;
var clk=0;
var clk1=0;
var ret;
var ext=25;
var MAX=280;
var MIN=40;
var tick=40;
var tick1=16;
var m1,m2,m3,m4,m5;
var inc1,inc2,inc3,inc4,inc5;
m1=m2=m3=m4=m5=0;
inc1=inc2=inc3=inc4=inc5=0;
var marg=new Array(100,70,100,90,100);
var bcol=new Array("#800f13","#006287","#782C00","#376100","#767000");
var qsParm = new Array();
var op=0;
var cluster=0;
var e=0;
var userexist=0;
var loadpage = '';
function qs() {
	var query = top.location.href.substring((top.location.href.indexOf('?')+1), top.location.href.length);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
if(key=="cluster")cluster=parseInt(val);
if(key=="event")e=parseInt(val);
if(key=="page")op=parseInt(val);
if(key=="userexist")userexist =parseInt(val);
if(key == 'load') {op = -1; loadpage=val;}
}
}
}
function loading1(toload)
{
 if(toload==-2 || toload==-3)toload=-1;
 document.getElementById('bet'+toload).innerHTML="<div align=center><img src='images/loading.gif' /></div>";
}
function loadit(nowload)
{
   	if(nowload==-2 || nowload==-3)nowload=-1;
	document.getElementById("bet"+nowload).innerHTML=top.frames["hiddenFrame"].document.body.innerHTML;
	//if(nowload==4){initLightbox(); }
	if(nowload==4){TB_init(); }
	if(nowload==2 ){
		last=0;
		cld=0;
		if(cluster!=0 && e==0)
		{
		cl_expand(cluster);
		cld=cluster;
		}
		}
}
function onLoad()
{
	for(i=1;i<=5;i++)
	document.getElementById("thr"+i).style.height=(MIN+ Math.random()*MAX).toString()+'px';
	dflag=0;
	clearTimeout(timer);
	clk=0;
	increment(2);
	qs();
	if(selected!=op)
		loading1(op);
	if(op!=0)top.frames['hiddenFrame'].location='m'+op+'.php';	
	if(e!=0)top.frames['hiddenFrame'].location='events/c'+cluster+'e'+e+'.php';
	if(userexist!=0) document.getElementById('ifuserexist').style.visibility='visible';
	if(loadpage != '') top.frames['hiddenFrame'].location=loadpage+'.php';
}
var x=0;
function increment(id)
{
    if(selected==id)return;
	
	len1=document.getElementById("thr1").style.height;
	len2=document.getElementById("thr2").style.height;
	len3=document.getElementById("thr3").style.height;
	len4=document.getElementById("thr4").style.height;
	len5=document.getElementById("thr5").style.height;
	num1=parseInt(len1.substr(0,len1.indexOf("p")));
	num2=parseInt(len2.substr(0,len2.indexOf("p")));
	num3=parseInt(len3.substr(0,len3.indexOf("p")));
	num4=parseInt(len4.substr(0,len4.indexOf("p")));
	num5=parseInt(len5.substr(0,len5.indexOf("p")));
	if(flag==0)
	{
		m1=MIN+Math.random()*MAX;
    	m2=MIN+Math.random()*MAX;
		m3=MIN+Math.random()*MAX;
		m4=MIN+Math.random()*MAX;
	    m5=MIN+Math.random()*MAX;
		switch(id)
		{
		  case 1:m1=MIN+MAX+ext;
		  		 break;
		  case 2:m2=MIN+MAX+ext;
		  		 break;
		  case 3:m3=MIN+MAX+ext;
		  		 break;
		  case 4:m4=MIN+MAX+ext;
		  		 break;
		  case 5:m5=MIN+MAX+ext;
		  		 break;
		}
		flag=id;
	}
	if(clk<tick)
	{
	    inc1=(m1-num1)/(tick-clk);
		inc2=(m2-num2)/(tick-clk);
		inc3=(m3-num3)/(tick-clk);
		inc4=(m4-num4)/(tick-clk);
		inc5=(m5-num5)/(tick-clk);
		num1+=inc1;
	    num2+=inc2;
	    num3+=inc3;
	    num4+=inc4;
		num5+=inc5;
	    len1=num1+'px';
	    len2=num2+'px';
	    len3=num3+'px';
	    len4=num4+'px';
	    len5=num5+'px';
		for(i=1;i<=5;i++)
		if(i!=selected)
        	document.getElementById("thr"+i).style.height=eval("len"+i);
       	clk++;				
		timer=setTimeout("increment("+id+")",1);
	}
}
function decrement(id)
{
	if(selected==id)return;
	if(dflag==0)
	{
	   len1=document.getElementById(("thr"+id)).style.height;
	   num1=parseInt(len1.substr(0,len1.indexOf("p")));
	   m1=MIN+ Math.random()*num1;
	   dflag=1;
	}
	if(clk<tick)
	{
	   inc1=(m1-num1)/(tick-clk);
	   num1+=inc1;
	   len1=num1+'px';
	   document.getElementById(("thr"+id)).style.height=len1;
	   clk++;
	   timer=setTimeout("decrement("+id+")",1);
	}
}
function newpage(id)
{
   if(clk1==tick1)
  {
    clearTimeout(timer1);
    
    if(pre!=0 && pre!=-1 && pre!=-2 && pre!=-3)
    {
	document.getElementById(("img"+pre)).style.height="100%";
    document.getElementById(("tab"+pre)).style.cursor="pointer";		
    }
	if(id!=0 && id!=-1 && id!=-2 && id!=-3)
	{
	document.getElementById(("tab"+id)).style.cursor="default";
	document.getElementById(("bot"+id)).src="images/cxt"+id+".gif";
	}
	return;
	
  }
 
  if(clk1<tick1)
  {
  if(id!=0 && id!=-1 && id!=-2 && id!=-3)
  {
  var high=document.getElementById(("thr"+id)).style.height;
  var numhigh=parseInt(high.substr(0,high.indexOf("p")));
  numhigh+=((MIN+MAX+ext-numhigh)/(tick1-clk1));
  document.getElementById(("thr"+id)).style.height=numhigh+'px';
  
  var mar=document.getElementById(("bot"+id)).style.marginTop;
  var nummar=parseInt(mar.substr(0,mar.indexOf("p")));
  nummar+=(-marg[id-1]-nummar)/(tick1-clk1);
  document.getElementById(("bot"+id)).style.marginTop=nummar+'px';
  if(clk1==12)loadit(id);
  }
  if((id==-1 || id==-2 || id==-3) && clk1==12)loadit(id);
  if((pre==-1 || pre==-2 || pre==-3)&& clk1==0)document.getElementById(("bet-1")).innerHTML= "";
  if(pre!=0 && pre!=-1 && pre!=-2 && pre!=-3)
  {
    if(clk1==0)document.getElementById(("bet"+pre)).innerHTML= "";
	high=document.getElementById(("thr"+pre)).style.height;
    numhigh=parseInt(high.substr(0,high.indexOf("p")));
    numhigh=numhigh+((ret-numhigh)/(tick1-clk1));
    document.getElementById(("thr"+pre)).style.height=numhigh+'px';
    mar=document.getElementById(("bot"+pre)).style.marginTop;
    nummar=parseInt(mar.substr(0,mar.indexOf("p")));
    nummar-=nummar/(tick1-clk1);
    document.getElementById(("bot"+pre)).style.marginTop=nummar+'px';
  }
 
 if(id!=0 && id!=-1 && id!=-2 && id!=-3)
  {
  var wid=document.getElementById(("img"+id)).style.width;
  var numwid=parseInt(wid.substr(0,wid.indexOf("p")));
  numwid+=2;
  document.getElementById(("img"+id)).style.width=numwid+'px';
  document.getElementById(("topimg"+id)).style.width=numwid+'px';
  }
  if(pre!=0 && pre!=-1 && pre!=-2 && pre!=-3)
  {
  var wid=document.getElementById(("img"+pre)).style.width;
  var numwid=parseInt(wid.substr(0,wid.indexOf("p")));
  numwid-=2;
  document.getElementById(("img"+pre)).style.width=numwid+'px';
  document.getElementById(("topimg"+pre)).style.width=numwid+'px';
  }
  dontchang=-1;
  if(i!=-1){ i=-1;dontchang=i;}
  for(i=-1;i<=5;i++)
  {
	  if(i!=0)
	  {  
    wid=document.getElementById(("bet"+i)).style.width;
	numwid=parseInt(wid.substr(0,wid.indexOf("p")));
	if(id==0 && i!=pre && !(i==5|| i==-1 || i==-2 || i==-3))
	   numwid+=6;
	else if(i==id)
	numwid+=(652-numwid)/(tick1-clk1);
	else if(i==pre && id==0 && (i==5|| i==-1 || i==-2 || i==-3))
		numwid-=numwid/(tick1-clk1);
	else if(i==pre && id==0)
	  numwid-=(numwid-96)/(tick1-clk1);
	  else if (i==pre)
	    numwid-=numwid/(tick1-clk1);
	else if(pre==0&& !(i==5 || i==-1 || i==-2 || i==-3))numwid-=6;
	document.getElementById(("bet"+i)).style.width=numwid+'px';
	  }
  }
  if(dontchang!=-1)i==dontchang;
  timer1=setTimeout("newpage("+id+")",5);
  clk1++;
  }
    
}
function replay(id)
{
  clearTimeout(timer);
  if(id==selected && id==-1)
  document.getElementById("bet-1").innerHTML=top.frames["hiddenFrame"].document.body.innerHTML;
  if(id==selected)return;
  pre=selected;
  selected=id;
  if(id!=0 && id!=-1 && id!=-2 && id!=-3)
  {
  document.getElementById(("img"+id)).style.width="4px";
  document.getElementById(("topimg"+id)).style.width="4px";
  }
  if(pre!=0 && pre!=-1 && pre!=-2 && pre!=-3)
  document.getElementById(("bot"+pre)).src="images/txt"+pre+".gif";  
  clk1=0;
  ret=MIN+Math.random()*MAX;
  newpage(id);
  
}

//2nd
var tr_id=1;
function optran()
{
  if(tr_id>5)tr_id=1;
  crossfade(document.getElementById('tr_top'), 'images/top/tran'+tr_id+'.jpg', '2', 'Accessible Website Menu [white]');
  tr_id++;
  
  tr_timer=setTimeout("optran()",1000);
}
oped=1;
cld=0;
last=0;
nowopen=0;
var cl_in=new Array(330,430,430,330,330,330,550,125);
var newopen=0;
function open7()
{
       replay(2);
	   oped=0;
}
function nowopenit()
{
   document.getElementById("bet2").innerHTML=top.frames["hiddenFrame"].document.body.innerHTML;
   last=0;
   cld=nowopen;
   if(nowopen!=0)
   {
   cl_expand(nowopen);
   MM_swapImage('ct'+nowopen,'','images/clus'+nowopen+'x.gif',1) 
   nowopen=0;
   }
}
function cl_expand(id)
{
   if(id==last)return;
   document.getElementById("space").style.display="none";
   if(last==0)
   {
     for(var i=id+1;i<=8;i++)
     {
        var x1=document.getElementById('ct'+i).style.top;
	    x2=parseInt(x1.substr(0,x1.indexOf('px')));
        x2+=cl_in[id-1];
	    document.getElementById('ct'+i).style.top=x2+'px';
	 }
   }
   else
   {
   if(last<id)
   {
   for(var i=last+1;i<=id;i++)
   {
      var x1=document.getElementById('ct'+i).style.top;
	  x2=parseInt(x1.substr(0,x1.indexOf('px')));
      x2-=cl_in[last-1];
	  document.getElementById('ct'+i).style.top=x2+'px';
	}
	for(;i<=8;i++)
	{
  	  var x1=document.getElementById('ct'+i).style.top;
	  x2=parseInt(x1.substr(0,x1.indexOf('px')));
      x2+=cl_in[id-1]-cl_in[last-1];
	  document.getElementById('ct'+i).style.top=x2+'px';
	}
	}
	else
	{
	for(i=id+1;i<=last;i++)
	{
	  var x1=document.getElementById('ct'+i).style.top;
	  x2=parseInt(x1.substr(0,x1.indexOf('px')));
	   x2+=cl_in[id-1];
	  document.getElementById('ct'+i).style.top=x2+'px';
	}
	for(;i<=8;i++)
	{
	  var x1=document.getElementById('ct'+i).style.top;
	  x2=parseInt(x1.substr(0,x1.indexOf('px')));
	   x2-=cl_in[last-1]-cl_in[id-1];
	  document.getElementById('ct'+i).style.top=x2+'px';
	}
	}
	}
 
   document.getElementById('cl'+id).height=parseInt(cl_in[id-1]+10)+'px';
   if(last!=0)
   {
     document.getElementById(('cl'+last)).height='10px';
	 document.getElementById('ct'+last).src='images/clus'+last+'.gif';
   }
   if(last!=0)
	{
	  document.getElementById("menu"+last).style.visibility="hidden";
	  document.getElementById("menu"+last).innerHTML="";
	}
	document.getElementById("menu"+id).style.visibility="visible";
	document.getElementById("menu"+id).innerHTML="<iframe src='cl"+id+".php' width=100% height=100% frameborder=0></iframe>";
	last=id;
	cld=0;
}
function op_exp(opx)
{
	var op_expl=document.getElementById('opt'+opx).src;
	var op_expm=op_expl.substr(op_expl.indexOf('down'),op_expl.length);
	if(op_expm=='down.gif')
		MM_swapImage('opt'+opx,'','images/downx.gif',1); 
	else 
		MM_swapImage('opt'+opx,'','images/upx.gif',1);
}
function op_exph(opx)
{
	var op_expl=document.getElementById('opt'+opx).src;
	var op_expm=op_expl.substr(op_expl.indexOf('down'),op_expl.length);
	if(op_expm=='downx.gif')
		MM_swapImage('opt'+opx,'','images/down.gif',1); 
	else 
		MM_swapImage('opt'+opx,'','images/up.gif',1);
}
function op_expc(opx)
{
	var op_expl=document.getElementById('opt'+opx).src;
	var op_expm=op_expl.substr(op_expl.indexOf('down'),op_expl.length);
	if(op_expm=='downx.gif')
	{
		document.getElementById('op'+opx).style.display='';
		document.getElementById('opt'+opx).src='images/upx.gif';
	}
	else
	{
		document.getElementById('op'+opx).style.display='none';
		document.getElementById('opt'+opx).src='images/downx.gif';
	}
}
function onClickCheck(thisform)
{
/*alert(thisform.Branch.selectedIndex);
if(thisform.Branch.selectedIndex == 0)
	alert("true");
else
	alert('false');
/*if(!thisform.email.value.replace( /[\w\-\+]+(\.[\w\-\+]+)*@([\w\-áàäçéèêñóòôöüæøå]+\.)+[a-z]+/i, "" ))
alert(thisform.email.value.replace( /[\w\-\+]+(\.[\w\-\+]+)*@([\w\-áàäçéèêñóòôöüæøå]+\.)+[a-z]+/i, "" ));*/
if(thisform.Username.value == '')
	{//document.getElementById('User').style.visibility='visible';
	 alert('username required');
	 return false;	 
	}
 if(thisform.Password.value == '')
 	{window.alert('password required');
	 return false;
	}
 if(thisform.Password.value != thisform.VPassword.value)
 	{window.alert('password mismatch');
	 return false;
	}
	//alert("bye");
 if(thisform.email.value == '' )
 	{window.alert('email required');
	 return false;
	}
 if(thisform.email.value.replace( /[\w\-\+]+(\.[\w\-\+]+)*@([\w\-áàäçéèêñóòôöüæøå]+\.)+[a-z]+/i, "" ))
 	{window.alert('email not in proper format');
	 return false;
	}	
 if(thisform.FName.value == '')
 	{window.alert('name required');
	 return false;
	}
 if(thisform.CollegeName.selectedIndex == 0 && thisform.CollegeName1.value == '')
 	{window.alert('college name');
	 return false;
	}
 if(thisform.Branch.selectedIndex == 0)
 	{window.alert('select branch');
	 return false;
	}
 if(thisform.CurrentYear.selectedIndex == 0)
 	{window.alert('select year');
	 return false;
	}
 return true;
}

