$(document).ready(function(){

	/* HOMEPAGE SECTOR STARTS */
	
	$('li.sector .sector_url').mouseenter(function(){
		$(this).parent().find('.sector_overlay').show();
		$(this).parent().addClass('indexing');
	});
	$('li.sector .sector_overlay').mouseleave(function(){
		$(this).hide();
		$(this).parent().removeClass('indexing');
	});

	/* HOMEPAGE SECTOR ENDS */
	
	
	/* LEFT PRODUCTS STARTS */
	
	$('.left_bg .product-type .top').mouseenter(function(){
		$('.left_bg .product-type .content').hide();
		$('.left_bg .product-type .icon').removeClass('expanded');
		$('.left_bg .product-type .icon').removeClass('collapsed');
		$('.left_bg .product-type .icon').addClass('collapsed');
		
		$(this).parent().find('.content').show();
		$(this).find('.icon').removeClass('collapsed');
		$(this).find('.icon').addClass('expanded');
	});
	$('.left_bg .product-type').mouseleave(function(){
		$(this).find('.content').hide();
		$(this).find('.icon').removeClass('expanded');
		$(this).find('.icon').addClass('collapsed');
	});
	
	/* LEFT PRODUCTS ENDS */
	
	
	/* PRODUCT DETAILS STARTS */
	$('.read_more').click(function(){
		$('.read_more').hide();
		$('.content_overlay').hide();
		$('.content_area').css("height","auto");
	});
	/* PRODUCT DETAILS STOP */
	
	$('a.new-window').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	$('.fandstan_logo a').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	$('img').bind("contextmenu", function(e){
		e.preventDefault();
	});
	
	
	$('.files .file').mouseenter(function(){
		var previewBox = $(this).find('.file-preview');
		if (previewBox.length > 0) {
			previewBox.css('left', $(this).position().left + 150);
			previewBox.css('top', $(this).position().top - previewBox.height() - $(this).height());
			previewBox.show();
		}
	});
	$('.files .file').mouseleave(function(){
		$(this).find('.file-preview').hide();
	});
	
	
	$('.webpoint-captcha-container .captcha-image').click(function(){
		var oImage = $(this);
		var szResetCaptchaImageUrl = oImage.attr('src') + '&type=reset&dt=' + new Date();
		jQuery.get(szResetCaptchaImageUrl, function(szData){
			oImage.attr('src', szData);
			var szEncryptedValue = szData;
			if (szEncryptedValue.indexOf('&c=') >= 0)
				szEncryptedValue = szEncryptedValue.substr(szEncryptedValue.indexOf('&c=') + 3);
			oImage.parent().parent().find('input.captcha-encrypted-value').val(szEncryptedValue);
		});
	});
});
