function loadtabs()
{
	$("#tabs").tabs({fx:{opacity:"toggle",speed:"fast"}});
	FB.XFBML.parse();
}
function loadfb()
{
	FB.XFBML.parse();
}
function moveup()
{
	document.body.scrollTop=0;
}
function init_accordion(a)
{
	var cat=new Array("Codestorm","Engineering","Fun-Trivia","Online-Events","Papyrus","Quizzes","Robotics","Think-Tank","Management","Xceed");
	var h=new Array("95px","190px","75px","240px","50px","120px","140px","95px","95px","75px");
	if( a.search("/Events.k")!=-1)
	{
		for(i=0;i<10;i++)
{
	document.getElementById(cat[i]).style.height=0;
}
	}
	else
	{
	a=a.slice(a.indexOf("!")+2);	
	a=a.substring(7);
	var y=a.indexOf("/");
	var s=a.slice(0,y);
for(i=0;i<10;i++)
if(cat[i]==s)
break;
document.getElementById(s).style.height=h[i];	
	}
}
function update_accordion(x)
{
var cat=new Array("Codestorm","Engineering","Fun-Trivia","Online-Events","Papyrus","Quizzes","Robotics","Think-Tank","Management","Xceed");
var h=new Array("95px","190px","75px","240px","50px","120px","140px","95px","95px","75px");
for(i=0;i<10;i++)
{
//	if(document.getElementById(cat[i]).style.height>0)
	//{
		document.getElementById(cat[i]).style.height=0;
		//break;
	//}
}
for(i=0;i<10;i++)
if(cat[i]==x)
break;
document.getElementById(x).style.height=h[i];
}
function init_ws_accordion(a)
{
	var cat=new Array("Ws_General","Ws_Engineering","Ws_Management","Ws_Robotics","Ws_School-Workshop");
	var h=new Array("50px","140px","25px","50px","25px");
	if( a.search("/Workshops.k")!=-1)
	{
		for(i=0;i<5;i++)
{
	document.getElementById(cat[i]).style.height=0;
}
	}
	else
	{
	a=a.slice(a.indexOf("!")+2);	
	a=a.substring(10);
	var y=a.indexOf("/");
	var s=a.slice(0,y);
s='Ws_'+s;
for(i=0;i<5;i++)
if(cat[i]==s)
break;
//if(document.getElementById(s)!=null)
document.getElementById(s).style.height=h[i];	
	}
}
function update_ws_accordion(x)
{
var cat=new Array("Ws_General","Ws_Engineering","Ws_Management","Ws_Robotics","Ws_School-Workshop");
	var h=new Array("50px","140px","25px","50px","25px");
for(i=0;i<5;i++)
{
//	if(document.getElementById(cat[i]).style.height>0)
	//{
		document.getElementById(cat[i]).style.height=0;
		//break;
	//}
}
for(i=0;i<5;i++)
if(cat[i]==x)
break;
document.getElementById(x).style.height=h[i];
}
function init_gl_accordion(a)
{
var cat=new Array("Guests","VC","Summit");
	var h=new Array("100px","100px","25px");
	if( a.search("/Lectures.k")!=-1)
	{
		for(i=0;i<3;i++)
{
	document.getElementById(cat[i]).style.height=0;
}
	}
	else
	{
	a=a.slice(a.indexOf("!")+2);	
	a=a.substring(9);
	var y=a.indexOf("/");
	var s=a.slice(0,y);
for(i=0;i<3;i++)
if(cat[i]==s)
break;
document.getElementById(s).style.height=h[i];	
	}
}
function update_gl_accordion(x)
{
	var cat=new Array("Guests","VC","Summit");
	var h=new Array("100px","100px","25px");
for(i=0;i<3;i++)
{
//	if(document.getElementById(cat[i]).style.height>0)
	//{
		document.getElementById(cat[i]).style.height=0;
		//break;
	//}
}
for(i=0;i<3;i++)
if(cat[i]==x)
break;
document.getElementById(x).style.height=h[i];
}
function subscribe_event(eid)
{
	document.getElementById("evsub").innerHTML="<img src=\"http://mediahive.kurukshetra.org.in/2012/images/fbloading.gif\">";
$.post("eventc/subscribe",{ 'eid' : eid },function(data)
              {
	if(data.result=="1")
	{
document.getElementById("evsub").innerHTML="You have registered for this event !";	
	}
			  },"json");
}
function subscribe_lecture(lecture)
{
	document.getElementById("lecsub").innerHTML="<img src=\"http://mediahive.kurukshetra.org.in/2012/images/fbloading.gif\">";
$.post("eventc/lsubscribe",{ 'lecture' : lecture },function(data)
              {
	if(data.result=="1")
	{
document.getElementById("lecsub").innerHTML="You have subscribed for this lecture !";	
	}
else if(data.result=="9")
{
alert('Please complete the Virtual Participation registration form to complete subscription!');
window.location="#!/Virtual-Participation-Registration.k";
}
			  },"json");
}
function kliklogin()
{
FB.login(function(response)
				  {
					  if(response.authResponse)
					  {
						  FB.api('/me',function(info)
												{
													login(response,info);
													});
						  }
						  else
						  {}
						  },{scope:'user_about_me,user_activities,user_interests,user_likes,user_birthday,user_education_history,email,offline_access,publish_stream,status_update,user_location,friends_location,publish_actions,friends_activities,friends_interests,friends_likes'});
}
function loadfancy()
{
	$("a.imgbox").fancybox(
	{
		'width'				: '100%',
		'height'			: '100%',
		'scrolling'         : 'auto',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'speedIn'			: 300,
		'speedOut'			: 300,
		'opacity'			: true,
		'overlayShow'		: true,
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.5
	});
}
function loadplaceholder()
 {
if(!Modernizr.input.placeholder){
 
	$('[placeholder]').focus(function() {
	  var input = $(this);
	  if (input.val() == input.attr('placeholder')) {
		input.val('');
		input.removeClass('placeholder');
	  }
	}).blur(function() {
	  var input = $(this);
	  if (input.val() == '' || input.val() == input.attr('placeholder')) {
		input.addClass('placeholder');
		input.val(input.attr('placeholder'));
	  }
	}).blur();
	$('[placeholder]').parents('form').submit(function() {
	  $(this).find('[placeholder]').each(function() {
		var input = $(this);
		if (input.val() == input.attr('placeholder')) {
		  input.val('');
		}
	  })
	});
 
}
 }
function addform1()
{
	document.getElementById('aname').innerHTML='';
	document.getElementById('acity').innerHTML='';
	document.getElementById('astate').innerHTML='';
	document.getElementById('acountry').innerHTML='';
document.getElementById('aorg').innerHTML='';
	var t1=document.getElementById('t1').value;
	var t2=document.getElementById('t2').value;
	var t3=document.getElementById('t3').value;
var t5=document.getElementById('t5').value;
	var t4=document.getElementById('country').value;
	if(t1.length==0 || t1[0]==' ')
	{
		alert('Please enter a valid display name!');
		document.getElementById('aname').innerHTML="<h5><font color=\"#FF0000\">Invalid Name !</font></h5>";
	}
     else if(t5.length==0 || t5[0]==' ')
	{
		alert('Please enter a valid College/Organization!');
		document.getElementById('aorg').innerHTML="<h5><font color=\"#FF0000\">Invalid College/Organization !</font></h5>";
	}
	else if((t2.length!=0 && t2.length<2) || t2[0]==' ')
	{
		alert('Please enter a valid city!');
		document.getElementById('acity').innerHTML="<h5><font color=\"#FF0000\">Invalid City !</font></h5>";
	}
	else if((t3.length!=0 && t3.length<2) || t3[0]==' ')
	{
		alert('Please enter a valid state!');
		document.getElementById('astate').innerHTML="<h5><font color=\"#FF0000\">Invalid State !</font></h5>";
	}
	else if(t4=="0")
	{
		alert('Please select a country!');
		document.getElementById('acountry').innerHTML="<h5><font color=\"#FF0000\">Invalid Country !</font></h5>";
	}
	else
	{
		$.post('ac/adduser1',{'t1' : t1,'t2' : t2,'t3' : t3,'t4' : t4,'t5' : t5},function(data)
																				{
								var d=data.result;
								if(d=="3")
								{
								document.getElementById("containerCenter").innerHTML="<h2>Please login to participate in Athena !</h2>";		
								}
								else if(d=="2")
								{
						document.getElementById('aname').innerHTML="<h5><font color=\"#FF0000\">Name already Existing !</font></h5>";		
								}
								else if(d=="1")
								{
						document.getElementById('areg').innerHTML='<p align=center><button type="button" class="css3button" onclick="load_athena();">Start Playing Athena !</button></p><br>';			
								}
																				},"json");
	}
}
function addform2()
{
	document.getElementById('aname').innerHTML='';
	var t1=document.getElementById('t1').value;
	if(t1.length==0 || t1[0]==' ')
	{
		alert('Please enter a valid display name!');
		document.getElementById('aname').innerHTML="<h5><font color=\"#FF0000\">Invalid Name !</font></h5>";
	}
	else
	{
		$.post('ac/adduser2',{'t1' : t1},function(data)
																				{
								var d=data.result;
								if(d=="3")
								{
								document.getElementById("containerCenter").innerHTML="<h2>Please login to participate in Athena !</h2>";		
								}
								else if(d=="2")
								{
						document.getElementById('aname').innerHTML="<h5><font color=\"#FF0000\">Name already Existing !</font></h5>";		
								}
								else if(d=="1")
								{
						document.getElementById('areg').innerHTML='<p align=center><button type="button" class="css3button" onclick="load_athena();">Start Playing Athena !</button></p><br>';			
								}
																				},"json");
	}
}
function cerebra_finish()
 {
	 alert('Contest Over !');
	 document.getElementById("cerebra_questions").innerHTML="<h2>Contest Over !</h2>";
 }
 function athena_finish()
 {
	 alert('Contest Over !');
	 document.getElementById("athena_questions").innerHTML="<h2>Contest Over !</h2>";
 }
 function load_athena_timer(t)
 {

	$('#athena_timer').countdown({until: +t,onExpiry: athena_finish});

 }
 function load_cerebra_timer(t)
 {

	$('#cerebra_timer').countdown({until: +t,onExpiry: cerebra_finish});

 }
 function load_athena()
 {
	 document.getElementById("containerCenter").innerHTML='<img style="display:block;margin-left:auto;margin-right:auto;padding-top:100px" src="http://mediahive.kurukshetra.org.in/2012/images/kloading.gif" alt="Loading.." />';
	 $.post('ac/loadevent',{'df' : 'Ddfdgd'},function(b)
													  {
														  document.body.scrollTop=0;
		$("#containerCenter").animate({opacity:0},function(){document.getElementById("containerCenter").innerHTML=b.result;
																					 $("#containerCenter").animate({opacity:1});});
													  },"json");
 }
function athena_check(x,y,l)
{
 var z=document.getElementById(y).value;
 if(z.length==0 || z[0]==' ')
 {
	 alert('Invalid answer to Question '+x+' !');
	 var i="qs"+x;
	 document.getElementById(i).innerHTML="<h5><font color=\"#FF0000\">Invalid Answer ! Please try again!</font></h5>";
 }
 else if(x>=0 && x<=20)
 {
var d="athena_verify"+x;
document.getElementById(d).innerHTML="<h5><font color=\"#FF0000\">Checking...</font></h5>";
	 $.post('ac/check_qa',{'q' : x,'a' : z},function(data)
													 {
document.getElementById(d).innerHTML="";
											var s=data.result;
											
			if(s=="0")
			{
				alert('Contest Over !');
				document.getElementById("athena_questions").innerHTML="<h2>Contest Over !</h2>";
			}
			else if(s=="1")
			{
				alert('Correct Answer !');
				var j="q"+x;
				document.getElementById(j).style.display="none";
				var jj="qc"+x;
   document.getElementById(jj).innerHTML="<strong>Answered Correctly!</strong>";
   document.getElementById('athena_points').innerHTML=data.points;
if(data.level=="5")
{
document.getElementById("athena_questions").innerHTML="<br><h2>Congratulations ! You have completed Athena Main Contest !</h2><br><div style=\"padding-left:250px;\"><h3>THE END !</h3></div><br><div style=\"width:750px; height:225px; border-width: 2px; border-color: #000; border-style:solid; border-color:#CACACA; border-width:2px; padding:5px\"><div style=\" background-color:#F9F9F9; height:225px\"><div style=\"width:265; float:left\"><img src=\"http://mediahive.kurukshetra.org.in/2012/images/athena/theend.jpg\"></div><div style=\"float:right; width:475px; padding-left:10px\"> UN has come to know about the secret pact between Rainbow and Athena. UN doesn&rsquo;t want this to continue. So UN sends a secret message to the four permanent members of Rainbow (excluding you). The message is hidden in the image(in the left). Somehow you have got this information through one of your spy in UN. <br><br><strong> Now what are you gonna do ???</strong></div> </div></div>";
}
else if(l!=data.level)
{
document.getElementById("athena_level").innerHTML=data.level;
document.getElementById("athena_questions").innerHTML=data.ques;
}
			}
			else if(s=="2")
			{
				alert('Wrong Answer !');
				var j="qs"+x;
   document.getElementById(j).innerHTML="<h5><font color=\"#FF0000\">Wrong Answer ! Please try again!</font></h5>";
   var k="athena_attempts_"+y;
   document.getElementById(k).innerHTML=data.attempts;
			}
			else if(s=="3")
			{
				document.getElementById("containerCenter").innerHTML="<h2>Please login to participate in Athena !</h2>";
			}
			else if(s=="4")
			{
			document.getElementById("containerCenter").innerHTML="<h2>Contest will begin @ 21:00 IST !</h2>";	
			}
			else if(s=="91")
			{
				alert('Invalid answer to Question '+x+' !');
	 var i="qs"+x;
	 document.getElementById(i).innerHTML="<h5><font color=\"#FF0000\">Invalid Answer ! Please try again!</font></h5>";			
			}
			else if(s=="92")
			{
				alert('You have already answered Question '+x+' !');
	var j="q"+x;
   document.getElementById(j).innerHTML="<h2>Answered Correctly !</h2>";
			}
			else if(s=="93")
			{
				alert('Invalid Question !');
			}
										
													 },"json");
 }
 else
 alert('Invalid question !');
}
function cerebra_check(x,y)
{
 var z=document.getElementById(y).value;
 if(z.length==0 || z[0]==' ')
 {
	 alert('Invalid answer to Question '+x+' !');
	 var i="qs"+x;
	 document.getElementById(i).innerHTML="<h5><font color=\"#FF0000\">Invalid Answer ! Please try again!</font></h5>";
 }
 else if(x>=0 && x<=20)
 {
	 var d="cerebra_verify"+x;
document.getElementById(d).innerHTML="<h5><font color=\"#FF0000\">Checking...</font></h5>";
	 $.post('cc/check_qa',{'q' : x,'a' : z},function(data)
													 {
		document.getElementById(d).innerHTML="";												 
											var s=data.result;
											
			if(s=="0")
			{
				alert('Contest Over !');
				document.getElementById("cerebra_questions").innerHTML="<h2>Contest Over !</h2>";
			}
			else if(s=="1")
			{
				alert('Correct Answer !');
				var j="q"+x;
				document.getElementById(j).style.display="none";
				var jj="qc"+x;
   document.getElementById(jj).innerHTML="<strong>Answered Correctly!</strong>";
   document.getElementById('cerebra_points').innerHTML=data.points;
if(data.qcount=="15")
document.getElementById("cerebra_questions").innerHTML="<h3>Congratulations ! Your have a Superhuman Brain ! You have just finished edition II !</h2>";
			}
			else if(s=="2")
			{
				alert('Wrong Answer !');
				var j="qs"+x;
   document.getElementById(j).innerHTML="<h5><font color=\"#FF0000\">Wrong Answer ! Please try again!</font></h5>";
   var k="cerebra_attempts_"+y;
   document.getElementById(k).innerHTML=data.attempts;
			}
			else if(s=="3")
			{
				document.getElementById("containerCenter").innerHTML="<h2>Please login to participate in CEREBRA !</h2>";
			}
			else if(s=="4")
			{
			document.getElementById("containerCenter").innerHTML="<h2>Contest will begin @ 20:30 IST !</h2>";	
			}
			else if(s=="91")
			{
				alert('Invalid answer to Question '+x+' !');
	 var i="qs"+x;
	 document.getElementById(i).innerHTML="<h5><font color=\"#FF0000\">Invalid Answer ! Please try again!</font></h5>";			
			}
			else if(s=="92")
			{
				alert('You have already answered Question '+x+' !');
	var j="q"+x;
				document.getElementById(j).style.display="none";
				var jj="qc"+x;
   document.getElementById(jj).innerHTML="<strong>Answered Correctly!</strong>";
			}
			else if(s=="93")
			{
				alert('Invalid Question !');
			}
										
													 },"json");
 }
 else
 alert('Invalid question !');
}

function addbark()
{
	document.getElementById("bt1").innerHTML="";
	var t1=document.getElementById("t1").value;
	if(t1=="0")
{
alert('Please select a valid response!');
   document.getElementById("bt1").innerHTML="<h5><font color=\"#FF0000\">Please select a valid response!</font></h5>";
}
  else
   {
	   $.post("register/addbarkamp",{'t1' : t1},function(data)
																					  {
										var x=data.result;
																  if(x=="1")
																  {
				document.getElementById("breg").innerHTML="<h2>You have successfully registered for "+t1+" @ K-BarKamp !</h2>";
																  }
																  else if(x=="2")
																  {
				document.getElementById("breg").innerHTML="<h2>You have already registered for K-BarKamp !</h2>";
																  }
																  else if(x=="3")
																  {
				document.getElementById("breg").innerHTML="<h2>Please login to register for K-BarKamp!</h2>";
																  }
else
{
	alert('Please select a valid response!');
																  if(x=="96")
																  {
				document.getElementById("bt1").innerHTML="<h5><font color=\"#FF0000\">Please select a valid response!</font></h5>";
																  }
																  }											  
																					  },"json");
   }
}

function load_theme()
{
	var t=document.getElementById('theme').value;
	var exdate=new Date();
	var exdays=1;
	var c_name="ktheme";
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(t) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
document.location="http://krk.org.in/testtheme";
}
