// Smooth Scroll

var signupopened=false,
signinopened=false;

var webrt='http://www.vidcano.com/';


$(document).ready(function(){


  });

  
jQuery.fn.centerit = function () {
    this.css("position","absolute");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}

  




$(function(){
if ($.cookie("VCc")){
//$("#logout").makeFloat({x:"current",y:"current", speed:"fast"});

$('#logout_top').click(function() {
 // alert('Handler for .click() called.');
 
  $.cookie("VCc", null);
  document.location=mainpage;
});
}

	$('#Search_Button3').live("click", function(){
	var thissval1 = $('#SearchInput2').val();
	//alert(thissval1);
	location.href="http://www.vidcano.com/?req=search&id="+thissval1; 
	this.preventDefault();
	});
	
	$('#Search_Button').live("click", function(){
	var thissval2 = $('#SearchInput').val();
	//alert(thissval2);
	location.href="http://www.vidcano.com/?req=search&id="+thissval2; 
	this.preventDefault();
	});

});



$(function(){
 
    $('a[href*=#]').click(function() {
 
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
 
            var $target = $(this.hash);
 
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
 
            if ($target.length) {
 
                var targetOffset = $target.offset().top;
 
                $('html,body').animate({scrollTop: targetOffset}, 600);
 
                return false;
 
            }
 
        }
 
    });
 
});



// Images fade animation
$(function(){
	$(".fadeload").hover(function(){
		$(this).stop().animate({opacity: "0.2"}, 350);
	},
	function(){
		$(this).stop().animate({opacity: "1"}, 125);
	});
});

// Go Top button animation
$(function(){
	$("#gotop a").hover(function(){
		$(this).stop().animate({top: "-20px" , height: "30px"}, {duration:125 , easing : "easeInCubic"});
	},
	function(){
		$(this).stop().animate({top: "-10px" , height: "20px"}, {duration:600 , easing : "easeOutBounce"});
	});
});



// VIDEOLINE JS

// Remove line on First and Last li
$(function() {	
		$("#sidebar ul").find("li:first").css("border-top", "none");
		$("#sidebar ul").find("li:last").css("border-bottom", "none");
		
		$(".footer_cols ul").find("li:first").css("border-top", "none");
		$(".footer_cols ul").find("li:last").css("border-bottom", "none");
		
});

// DROPDOWN MENU
$(function(){						   
	$("#top-menu ul ul").css({display: "none"});
	$('#top-menu ul li').hover(function(){
		$('ul', this).slideDown(80);
		$(".subline", this).addClass("current");
	},
	function(){
		$('ul', this).fadeOut(105).show();
		$(".subline", this).removeClass("current");
	});	
	
	$("#top-menu ul ul a").wrapInner("<span></span>");
	$("#top-menu ul ul li").hover(function(){
		$(this).find("span").stop().animate({marginLeft:'10px'},{queue:false, duration:250, easing: 'easeOutSine'});
	},
	function(){
		$(this).find("span").stop().animate({marginLeft:'0px'},{queue:false, duration:250, easing: 'easeOutSine'});
	});
	
	$("#top-menu ul ul").hover(function(){
		$(this).parent('li').find(".subline").addClass("current");
	},
	function(){
		$(this).parent('li').find(".subline").removeClass("current");
	});
});

$(function(){						   
	$("#filter-menu ul ul").css({display: "none"});
	$('#filter-menu ul li').hover(function(){
		$('ul', this).slideDown(80);
		$(".subline", this).addClass("current");
	},
	function(){
		$('ul', this).fadeOut(105).show();
		$(".subline", this).removeClass("current");
	});	
	
	$("#filter-menu ul ul a").wrapInner("<span></span>");
	$("#filter-menu ul ul li").hover(function(){
		$(this).find("span").stop().animate({marginLeft:'10px'},{queue:false, duration:250, easing: 'easeOutSine'});
	},
	function(){
		$(this).find("span").stop().animate({marginLeft:'0px'},{queue:false, duration:250, easing: 'easeOutSine'});
	});
	
	$("#filter-menu ul ul").hover(function(){
		$(this).parent('li').find(".subline").addClass("current");
	},
	function(){
		$(this).parent('li').find(".subline").removeClass("current");
	});
});

// ZOOMS
$(function() {	
	$("#bottom_slideshow a span").css("opacity","0");
	$("#bottom_slideshow a").hover(function(){
		$(this).find('span').stop().animate({opacity: 1},{queue:false, duration:180, easing: 'easeOutSine'});
		},
		function(){
		$(this).find("span").stop().animate({opacity: 0},{queue:false, duration:180, easing: 'easeOutSine'});
	});
});

$(function() {	
	$("#nivo_slider a span").css("opacity","0");
	$("#nivo_slider a").hover(function(){
		$(this).find('span').stop().animate({opacity: 1},{queue:false, duration:180, easing: 'easeOutSine'});
		},
		function(){
		$(this).find("span").stop().animate({opacity: 0},{queue:false, duration:180, easing: 'easeOutSine'});
	});
});

$(function() {	
	$(".folio_item span").css("opacity","0");
	$(".folio_item a").hover(function(){
		$(this).find('span').stop().animate({opacity: 1},{queue:false, duration:180, easing: 'easeOutSine'});
		},
		function(){
		$(this).find("span").stop().animate({opacity: 0},{queue:false, duration:180, easing: 'easeOutSine'});
	});
});

// Hover state depending the target format.
$(function() {
	// Image
	$("a[href$='.png'], a[href$='.jpg'], a[href$='.jpeg'], a[href$='.pdf']").addClass("zoom_image");
	// Video
	$("a[href$='.swf'], a[href$='.mov'], a[href$='.rft']").addClass("zoom_video");
	//All other links are like videos...
	$('a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass("external");
	
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").click( function() {
		window.open(this.href);
		return false;
	});
});




// GALLERY FILTER

$(function(){

	$("#the_gallery a").css("opacity","0");
	
	
	$(".filter .all").click(function(){
		
		// Reinitialization of all elements
		$("#the_gallery li").stop().animate({opacity: '1'});
		$("#the_gallery li").find("a").css("top","0px");
		
		
	});
	
	if((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)){
		
		$(".filter a").click(function(){
		
		$(".filter a").removeClass("current");
		$(this).addClass("current");

		// Get the title attribut
		thisItem = $(this).attr('rel');
		
			if(thisItem == "all") {
					
					// Reset settings on all elements
					$("#the_gallery li").stop().animate({width: '160px'});
					$("#the_gallery li").find("a").css("top","0px");
					
					// Reset settings on all elements with li parent has attribut of the filter in class
					$('#the_gallery li.'+thisItem).stop().animate({width: '160px'});
					$('#the_gallery li.'+thisItem).find("a").css("top","0px");
					
					} else {
		
					// Reset settings on all elements
					$("#the_gallery li").stop().animate({width: '0px'});
					$("#the_gallery li").find("a").css("top","160px");
					
					// Settings on all elements with li parent has attribut of the filter in class
					$('#the_gallery li.'+thisItem).stop().animate({width: '160px'});
					$('#the_gallery li.'+thisItem).find("a").css("top","0px");
			}
		
		
	});
		
	} else {
	
	$(".filter a").click(function(){
		
		$(".filter a").removeClass("current");
		$(this).addClass("current");

		// Get the title attribut
		thisItem = $(this).attr('rel');
		
			if(thisItem == "all") {
					
					// 
					$("#the_gallery li").stop().animate({opacity: '1'});
					$("#the_gallery li").find("a").css("top","0px" , "visibility","visible");
					
					// 
					$('#the_gallery li.'+thisItem).stop().animate({opacity: '1'});
					$('#the_gallery li.'+thisItem).find("a").css("top","0px" , "visibility","visible");
					
					} else {
		
					//
					$("#the_gallery li").stop().animate({opacity: '0.3'});
					$("#the_gallery li").find("a").css("top","160px");
					
					// 
					$('#the_gallery li.'+thisItem).stop().animate({opacity: '1'});
					$('#the_gallery li.'+thisItem).find("a").css("top","0px");
			}
		
		
	});
	}
	
	
	
		$("#the_gallery li").hover(function(){
				$(this).find("a").stop().animate({opacity: '0.8'});
		},function(){
				$(this).find("a").stop().animate({opacity: '0'});
		});

});


// GALLERY SLIDESHOW
$(function()
{
	var slideshow = function()
	{
		setTimeout(function(){
			$('#bottom_slideshow li:first').animate({marginLeft: '-238px'},{ duration:800, easing: 'easeOutCubic', complete: function()
				{
					$(this).detach().appendTo('#bottom_slideshow ul').removeAttr('style');	
				}
			});
			slideshow();
		}, 4000);
	};
	slideshow();
});

// CONTACT FORM
$(function() {
		$("#contact_part .content div").animate({opacity:0}).show();
		
		
		$("#forgotpass_su").live('click', function () {

		$("#contact_part").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part3").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part3 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);

		});
		
		
		$("#lcancel").live('click', function () {
		
		$("#contact_part .content div").animate({opacity:0},400,
					function(){
						$("#contact_part").slideUp(700,"easeOutExpo");
					});

		});
		
		$("#contact_opener_head").click(function () {
			if ($("#contact_part").is(":hidden")){
			
			if ($("#contact_part2").is(":hidden")&&$("#contact_part3").is(":hidden")&&$("#contact_part4").is(":hidden")){
				$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
				}else if ($("#contact_part2").is(":hidden")&&$("#contact_part4").is(":hidden")){
				$("#contact_part3").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
					}
					});
				
				}else if ($("#contact_part3").is(":hidden")&&$("#contact_part4").is(":hidden")){
				$("#contact_part2").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
					}
					});
					
				}else{
				$("#contact_part4").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
					}
					});
				
				}
				
				
			} else {
				$("#contact_part .content div").animate({opacity:0},400,
					function(){
						$("#contact_part").slideUp(700,"easeOutExpo");
					});
			}
			return false;
		});
		
		
		
		$("#contact_opener").click(function () {
			if ($("#contact_part").is(":hidden")){
			
			if ($("#contact_part2").is(":hidden")&&$("#contact_part3").is(":hidden")&&$("#contact_part4").is(":hidden")){
				$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
				}else if ($("#contact_part2").is(":hidden")&&$("#contact_part4").is(":hidden")){
				$("#contact_part3").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
					}
					});
				
				}else if ($("#contact_part3").is(":hidden")&&$("#contact_part4").is(":hidden")){
				$("#contact_part2").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
					}
					});
					
				}else{
				$("#contact_part4").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part .content div").animate({opacity:1},400);
					}
					});
					}
					});
				
				}
				
				
			} else {
				$("#contact_part .content div").animate({opacity:0},400,
					function(){
						$("#contact_part").slideUp(700,"easeOutExpo");
					});
			}
			return false;
		});
});

$(function() {
		$("#contact_part2 .content div").animate({opacity:0}).show();
		
			$("#scancel").live('click', function () {
		$("#loginresult").html('');
		
		$("#contact_part2 .content div").animate({opacity:0},400,
					function(){
						$("#contact_part2").slideUp(700,"easeOutExpo");
					});

		});
		
		
		
		$("#signinrent2").click(function () {
			if ($("#contact_part2").is(":hidden")) {
			
			if ($("#contact_part").is(":hidden")&&$("#contact_part3").is(":hidden")){
				$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					}
				);
				}else{
				//$("#contact_part2").slideUp(700,"easeOutExpo");
				
				if ($("#contact_part").is(":hidden")){
				$("#contact_part3").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);
				}else{
				$("#contact_part").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);
				
				}
				}
				$('html, body').animate({ scrollTop: 0 }, 'slow');
			}
		});
		
		
		$("#contact_opener2, #signinrent, #signinbuy").click(function () {
			if ($("#contact_part2").is(":hidden")) {
			
			if ($("#contact_part").is(":hidden")&&$("#contact_part3").is(":hidden")){
				$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					}
				);
				}else{
				//$("#contact_part2").slideUp(700,"easeOutExpo");
				
				if ($("#contact_part").is(":hidden")){
				$("#contact_part3").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);
				}else{
				$("#contact_part").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);
				
				}
				}
				$('html, body').animate({ scrollTop: 0 }, 'slow');
			} else {
				$("#contact_part2 .content div").animate({opacity:0},400,
					function(){
						$("#contact_part2").slideUp(700,"easeOutExpo");
					});
			}
		});
});

$(function() {
		$("#contact_part3 .content div").animate({opacity:0}).show();
		
		$("#upload_opener").click(function () {
			if ($("#contact_part3").is(":hidden")) {
			
			if ($("#contact_part").is(":hidden")&&$("#contact_part2").is(":hidden")){
				$("#contact_part3").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part3 .content div").animate({opacity:1},400);
					}
					}
				);
				}else{
				//$("#contact_part2").slideUp(700,"easeOutExpo");
				
				if ($("#contact_part").is(":hidden")){
				$("#contact_part2").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part3").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part3 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);
				}else{
				$("#contact_part").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part3").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part3 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);
				
				}
				}
				$('html, body').animate({ scrollTop: 0 }, 'slow');
			} else {
				$("#contact_part3 .content div").animate({opacity:0},400,
					function(){
						$("#contact_part3").slideUp(700,"easeOutExpo");
					});
			}
		});
		
		
		$("#forgotpass_su").live('click', function () {
		$("#loginresult").html('');
		
		$("#contact_part").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part3").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part3 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);

		});
		
				$("#forgotpasssubmit").live('click', function () {
		$("#loginresult").html('');
		
		$("#contact_part2").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part3").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part3 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);

		});
		
		$("#fcancel").live('click', function () {
		$("#loginresult").html('');
		
		$("#contact_part3").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);

		});
		
		$("#forgotpasssent").live('click', function () {
		$("#loginresult").html('');
		
		$("#contact_part3").slideUp({
					duration: 700,
					easing: 'easeOutExpo',
					complete:function(){
						$("#contact_part2").slideDown({
					duration: 400,
					easing: 'easeOutBack',
					complete:function(){
						$("#contact_part2 .content div").animate({opacity:1},400);
					}
					});
					}
					}
				
				
				);

		});
		
		
});


// Flickr fade animation
$(function(){
	$(".flickr_stream img").hover(function(){
		$(this).stop().animate({opacity: "0.5"});
	},function(){
		$(this).stop().animate({opacity: "1"});
	});
});
/*

$("#contact-form2").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajax_login.php",{ user_name:$('#username').val(),password:$('#password3').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  	 //redirect to secure page
				 document.location='secure.php';
			  });
			  
			});
		  }
		  else 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Your login detail sucks...').addClass('messageboxerror').fadeTo(900,1);
			});		
          }
				
        });
 		return false; //not to post the  form physically
	});
	*/
/*	
$("#password3").blur(function()
{
        $("#contact-form2").trigger('login');
});
*/
// Captcha system
/*
$(function(){
$("#errorcaptcha").css({opacity: "0"});
$("#check").keyup(function () {
		var rep = $(this).val();
		var n1 = document.getElementById('num1').innerHTML;
		var n2 = document.getElementById('num2').innerHTML;
		var n3 = parseInt(n1) + parseInt(n2);
      		if( n3 == rep ){
			$("#submitter").prepend('<input type="submit" name="contact_submit" id="contact_submit" value="Send Now" />').animate({opacity: "1"},{duration:350});
			$("#errorcaptcha").text(" ").animate({opacity: "0"},{duration:150});
		}
		else {
			$("#errorcaptcha").text("Not good!").animate({opacity: "1"},{duration:350});
			$("#submitter").prepend('').animate({opacity: "0"},{duration:150}).empty();
		}
    });
});

$(function(){
$("#reply-form #reply-errorcaptcha").css({opacity: "0"});
$("#reply-form #reply-check").keyup(function () {
		var rep = $(this).val();
		var n1 = document.getElementById('reply-num1').innerHTML;
		var n2 = document.getElementById('reply-num2').innerHTML;
		var n3 = parseInt(n1) + parseInt(n2);
      		if( n3 == rep ){
			$("#reply-form #reply-submitter").prepend('<input type="submit" name="reply_submit" id="reply_submit" value="Reply Now" />').animate({opacity: "1"},{duration:350});
			$("#reply-form #reply-errorcaptcha").text(" ").animate({opacity: "0"},{duration:150});
		}
		else {
			$("#reply-form #reply-errorcaptcha").text("Not good!").animate({opacity: "1"},{duration:350});
			$("#reply-form #reply-submitter").prepend('').animate({opacity: "0"},{duration:150}).empty();
		}
    });
});
*/




// PrettyPhoto Setting


$(function() {	
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'dark_rounded'}); 
});

// Forms Validator
/*
$(function() {
	$("#contact-form").validate({
  rules: {
  
	password1: {
      minlength: 6
    },
    password2: {
      equalTo: "#password1"
    }
  }
});
	$("#contact-form2").validate();
	$("#reply-form").validate();
});
*/
