$(document).ready(function() {
	$(".carousel").carousel({
		dispItems: 1,
		autoSlide: true,
		animSpeed: "slow",
		autoSlideInterval: 8000,
		pagination: true,
		loop: true,
		effect: "fade"
	});

	$('.popup .popup-close').click(function() {
		var popup = $(this).parent('.popup');
		popup.hide();
		if (popup.is("#popup-new-request"))
			popup.find('.table-2.mb10 tr:visible').remove()
		$('.popup-shading').hide();
	});
	//Add scrolling to Popup if it is too long
	var pp = $('.popup-inner-body')
	$('.popup').bind('show', function(){
    		//$(this).trigger('isVisible');

		var pp = $('.popup-inner-body')
		alert($('.popup').height());
		if (pp.height() > $(window).height() - 300){
			pp.css({'height': $(window).height() - 300 + 'px', 'overflow': 'auto'});
			}
		});
	//alert($(window).height());
	//---
	
	
	var vstring = "<div id='popup-video' class='popup' style='top:150px;margin-left:-350px; width:714px'><div class='popup-shadow-tl'></div><div class='popup-shadow-t'></div><div class='popup-shadow-tr'></div><div class='popup-shadow-r'></div><div class='popup-shadow-br'></div><div class='popup-shadow-b'></div><div class='popup-shadow-bl'></div><div class='popup-shadow-l'></div><div class='popup-close' id='video-popup-close' onClick='document.getElementById(\"popup-shading-video\").parentNode.removeChild(document.getElementById(\"popup-shading-video\"));document.getElementById(\"popup-video\").parentNode.removeChild(document.getElementById(\"popup-video\"));return false;'></div><div class='popup-inner'><div class='popup-inner-header' style='height:20px	'></div><div class='popup-inner-body' style='padding:0'>\
	<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='700' height='394' id='player1' name='player1'>\
		<param name='movie' value='/player.swf'>\
		<param name='allowfullscreen' value='false'>\
		<param name='allowscriptaccess' value='always'>\
		<param name='flashvars' value='file=/FirstShare_Demo.flv&image=&autostart=true&icons=true&repeat=none&stretching=none'>\
		<embed id='player1' name='player1' src='/player.swf' width='700' height='394' allowscriptaccess='always'   allowfullscreen='false' flashvars='file=/FirstShare_Demo.flv&image=&autostart=true&icons=true&repeat=none&stretching=none' /></object></div></div></div><div class='popup-shading' id='popup-shading-video'></div>";

	$('#popup-video').hide()
	$('#watch-video a').click(function(){
		$("body").prepend(vstring);
		$('#popup-video').show();
		$('#popup-shading-video').show();
		return false;
		});


	//	$('.open-popup-edit-stoks-to-buy').click(function() {
	//		$('.popup-shading').show();
	//		$('#popup-edit-stoks-to-buy').show();
	//		return false;
	//	});

	//	$('.open-popup-edit-stoks-to-sell').click(function() {
	//		$('.popup-shading').show();
	//		$('#popup-edit-stoks-to-sell').show();
	//		return false;
	//	});

	//	$('.open-popup-new-request').click(function() {
	//		$('.popup-shading').show();
	//		$('#popup-new-request').show();
	//		return false;
	//	});

	//	$('.open-popup-contact-seller').click(function() {
	//		$('.popup-shading').show();
	//		$('#popup-contact-seller').show();
	//		return false;
	//	});
});

