$(document).ready(function() {
	//$('#showscroll').show('slow');
	//$("#scroller").simplyScroll({autoMode: 'loop'});
	
	var rheight = $("div.right_content").height();
	if(rheight > 200){
		//alert(rheight);
		//$("div.left_inner").height(rheight);
	}
	
	$("#copybutton").trigger('click');
	$("#copybutton").trigger('click');
	$("#searchkey").click(function(){
		var searchterm = $("#q").val();
		window.location.href = 'search.php?q='+searchterm+'&refine=1';
	});
	
	/*
	LOGIN AND REGISTRATION TOGGLE IN HEADER :)
	*/
	var logregtop 	= '-3px';
	var regboxh 	= '305px';
	var regboxhm 	= '312px';
	var loginboxh	= '126px';
	var openspeed	= 1000;
	
	$("#viewlogin").toggle(function(){
		var rb = $('div.registerbox').css("top");
		
		if(rb == logregtop){
			$('div.registerbox').animate({top:"-"+regboxhm},openspeed);
			$('div.login_register').animate({top:logregtop},openspeed,'swing',function(){
				$('div.loginbox').animate({top:logregtop},openspeed);
				$('div.login_register').animate({top:loginboxh},openspeed);
			});
		}
		else{
			$('div.loginbox').animate({top:logregtop},openspeed);
			$('div.login_register').animate({top:loginboxh},openspeed);
		}
	},function(){
		
		var rb = $('div.registerbox').css("top");
		if(rb == logregtop){
			$('div.registerbox').animate({top:"-"+regboxhm},openspeed);
			$('div.login_register').animate({top:logregtop},openspeed,"swing",function(){
				$('div.loginbox').animate({top:logregtop},openspeed);
				$('div.login_register').animate({top:loginboxh},openspeed);
			});
		}
		else{
			$('div.loginbox').animate({top:"-"+loginboxh},openspeed);
			$('div.login_register').animate({top:logregtop},openspeed);
		}
	});
	
	
	$("#viewregistration").toggle(function(){
		
		var lb = $('div.loginbox').css("top");
		if(lb == logregtop){
			$('div.loginbox').animate({top:"-"+loginboxh},openspeed);
			$('div.login_register').animate({top:logregtop},openspeed,'swing',function(){
				$('div.registerbox').animate({top:logregtop},openspeed);
				$('div.login_register').animate({top:regboxh},openspeed);
			});
		}
		else{
			$('div.registerbox').animate({top:logregtop},openspeed);
			$('div.login_register').animate({top:regboxh},openspeed);
		}
	},function(){
		var lb = $('div.loginbox').css("top");
		if(lb == logregtop){
			
			$('div.loginbox').animate({top:"-"+loginboxh},openspeed);
			$('div.login_register').animate({top:logregtop},openspeed,'swing',function(){
				$('div.registerbox').animate({top:logregtop},openspeed);
				$('div.login_register').animate({top:regboxh},openspeed);
			});
		}else{
			$('div.registerbox').animate({top:"-"+regboxhm},openspeed);
			$('div.login_register').animate({top:logregtop},openspeed);
		}
	});
	
	/*LEFT ADDONS SLIDE */
	$('#slideaction').toggle(
		
		function(){
			$('div#slidepanel').animate({left:"0px"},openspeed);
		},
		function(){
			$('div#slidepanel').animate({left:"-210px"},openspeed);
		}
	);
	
	
	/*MEGA MENU*/
				
   // $(".MegaMenuLink").megamenu(".MegaMenuContent",{width: "695px"});
    
	/* INDEX PAGE 6 PHOTO LINKS*/
	$("#vinfo1").colorbox({width:"50%", inline:true, href:"#viewinfo1",current:"",opacity:"0.3",fixed:"true"});
	$("#vinfo2").colorbox({width:"50%", inline:true, href:"#viewinfo2",current:"",opacity:"0.3",fixed:"true"});
	$("#vinfo3").colorbox({width:"50%", inline:true, href:"#viewinfo3",current:"",opacity:"0.3",fixed:"true"});
	$("#vinfo4").colorbox({width:"50%", inline:true, href:"#viewinfo4",current:"",opacity:"0.3",fixed:"true"});
	$("#vinfo5").colorbox({width:"50%", inline:true, href:"#viewinfo5",current:"",opacity:"0.3",fixed:"true"});
	$("#vinfo6").colorbox({width:"50%", inline:true, href:"#viewinfo6",current:"",opacity:"0.3",fixed:"true"});
	$("a[rel='photopreview']").colorbox({opacity:"0.3"});
	
	$('a.sendsol').live('click',function(event) {
		event.preventDefault();
		var vid = this.id.replace('mm_', "");
		var ck = $.colorbox({href:vid,opacity:"0.4",iframe:true, innerWidth:'600px', innerHeight:'550px;'});
	});

if ($.browser.msie && $.browser.version.substr(0,1)<=7) {
 $("div#slidepanel").show();
 $("div#slidepanel").css("position","absolute");
 $("#forgotpass").css("display","none");
}
else{
$("div#slidepanel").show();
}

	$('#tcountryreg').change(function(){
		if(($("#tcountryreg").val() != "1") && ($("#tcountryreg").val() != "0")){
			$('#txtMobile').css('width','100px');
			$('#tcountrycode').fadeIn('slow');
			$('#tshowmobile').html('Country Code + Mobile');
			
		}
		else{
			$('#tcountrycode').fadeOut('100',function(){
			$('#txtMobile').css('width','155px');
			$('#tshowmobile').html('Mobile<em>*</em>');
			});
			
		}
	});

	
});
function validateslideForm()
{
	$("#slideerror").html("<div class='cerror'>Note: Fields marked with an asterisk (*) are mandatory. </div>");
	if ($("#txtName").val() == "") 
	{
	  $("#slideerror").html("<div class='cerror'>Enter your Name.</div>");
	  $("#txtName").focus();
	  return false;
	}
	else if ($("#class").val() == "0") 
	{
	  $("#slideerror").html(" <div class='cerror'> Select your Class </div>");
	  $("#class").focus();
	  return false;
	}
	else if ($("#txtEmail").val() == "") 
	{
	  $("#slideerror").html(" <div class='cerror'>Enter Email Id (LoginId). </div>");
	  $("#txtEmail").focus();
	  return false;
	}
		
	
	else if ($("#txtEmail").val() != "")
	{
		 
		 n=$("#txtEmail").val();
		 m=n.indexOf("@");
		 k=n.length;
		 str1=n.substr(0,m);
		 str2=n.substr(m+1,k-m);
		if(n=="")
		{
			
		}
		else if(str1.indexOf(".")==0 || n.indexOf("@")<=0 || n.indexOf("Index.php")>0 || str2.indexOf(".")<=0)
		{
			flag=false;
		    		$("#slideerror").html(" <div class='cerror'>  Enter Valid Email Id (LoginId). </div>");
			$("#txtEmail").focus();
			return false;
		}
		else if ($("#txtPwd").val() == "") 
		{
		  	  $("#slideerror").html(" <div class='cerror'>  Enter Password. </div>");
		  $("#txtPwd").focus();
		  return false;
		}
		else if ($("#txtConfirm").val() == "") 
		{
		  	  $("#slideerror").html(" <div class='cerror'>  Confirm Password. </div>");
		  $("#txtConfirm").focus();
		  return false;
		}
		
		else if($("#txtPwd").val()!=$("#txtConfirm").val())
		{
			$("#slideerror").html(" <div class='cerror'>Confirm Password does not match.</div>");
		    $("#txtConfirm").focus();
			return false;
		}
		else if ($("#txtCity").val() == "") 
			{
			  $("#slideerror").html("<div class='cerror'>Enter your City.</div>");
			  $("#txtCity").focus();
			  return false;
			}
		else if ($("#tcountryreg").val() == "0") 
		{
		 	$("#slideerror").html(" <div class='cerror'>Select Country.</div>");
		    $("#tcountryreg").focus();
			return false;
		}
		else if (($("#tcountryreg").val() == 1) && ($('#txtMobile').val() == '')) 
		{
		 	$("#slideerror").html(" <div class='cerror'>Enter Mobile No.</div>");
		    $("#txtMobile").focus();
			return false;
		}
		

		else{
			$('#showbanner').html('Processing, Please Wait <img src="images/wait.gif" alt=".." style="vertical-align:middle;padding-left:5px;" />');
			$('#showbanner').css("height","15px");
			$('#showbanner').css("padding","10px");
			centerPopup('showbanner');
			loadPopup('showbanner');
			$.post("pregistration.php", $("#slideform").serialize(),function(data){
				 disablePopup();
				 var step = data.step; 							
				 if(step == "1"){
					$('div.registerbox').animate({top:"-271px"},300);
					$('div.login_register').animate({top:"0px"},300);
					$.colorbox({iframe:true, innerWidth:500, innerHeight:250,href:"confirmation-code.php",
					onClosed:function(){ 
						window.location.href = "user_account.php"; 
					}
					});
				 }
				 else if(step == "2"){
					$("#slideerror").html(" <div class='cerror'>Email Id (LoginId) already Exist, Enter another Email Id</div>");
					$("#txtEmail").focus();
				 }
			}, "json");
		}
	}
	
	
	
}
function getDocumentHeight()
{
	if($.browser.msie)
	{
	var $temp = $("<div>")
	.css("position","absolute")
	.css("left","-10000px")
	.append($("body").html());
	 
	$("body").append($temp);
	var h = $temp.height();
	$temp.remove();
	return h;
	}
	return $("body").height();
}
function OpenWindow(url,name,w,h){
	var ht=h+30;
	window.open(url,name,'width='+w+',height='+h);
}

