
$(document).ready(function() {
						   
	var objectID = '';
						   
	$('body').append('<div id="overlay"></div>');
	
	$('ul.prodType').css({display:'block'});
	//$('.wrap_view:not(:first)').hide();
	$('.wrap_view').appendTo('body').css({display:'none',float:'none',position:'absolute',zIndex:'10000'}).children('.inn_prod');//.prepend('<a class="closebtn"></a>');
	//$('.prodType a:first').addClass('act');
	
	$('.wrap_view.imagebox').each(function(){
	
		theImage = $(this).find('img');
		newImage = new Image();
		newImage.src = $(theImage).attr('src');
		w = newImage.width;
		h = newImage.height;
		w2 = w;
		h2 = h;
		
		if (w>880) {
			w2 = 880;
			h2 = Math.round((h*w2)/w);
		}
		
		if (h2>$(window).height()*0.7) {
			h2 = Math.round($(window).height()*0.7);
			w2 = Math.round((w*h2)/h);
		}
		
		$(theImage).attr({ width: w2, height: h2 });
		
		if (w2<200) w2 = 200;
		
		$(this).find('.top_prod,.btm_prod').css({ width:w2+'px' });
		
		w2 += 20;
		
		$(this).css({ width:w2+'px' }).find('.inn_prod').css({ width:w2+'px' });//.find('.rightBorder').css({ height:mh+'px' });
	
	});
	
	$('ul.prodType a, .needhelp').click(function () {
		//$('ul.prodType a').removeClass('act');
		//$(this).addClass('act');
		
		h = $(document).height();
		$('#overlay').css({height:h+'px',display:'block'});
		
		var bodyId = $(this).attr('href');
		var body = $(bodyId);
		if (body.height()>=$(window).height()) body.height($(window).height()*0.8).find('.scroll').css({height:(body.height()-100)+'px',overflowY:'scroll'});
		l = ($('body').width()/2)-(body.width()/2);
		t = $(window).scrollTop() + ( ( $(window).height()-body.height() ) / 2 );
		//$('.wrap_view:visible').filter(':not(' + bodyId + ')').fadeOut('fast', function () {
		body.css({left:l+'px',top:t+'px'}).fadeIn('fast');
		//});
		
		if($.browser.msie) {
			if (Number($.browser.version)<7.0) $('#wrapper select').css({visibility:'hidden'});
			objectID = body.find('object').attr('id');
			if (objectID) document.getElementById(objectID).SetVariable('playVar', 'true');
		}
		
		return false;
	});
	
	$('#overlay').click(function(){
		
		if($.browser.msie) {
			if (Number($.browser.version)<7.0) $('#wrapper select').css({visibility:'visible'});
			//objectID = $(this).parent().parent().find('object').attr('id');
			if (objectID) document.getElementById(objectID).SetVariable("rewindVar", 'true');
		}
		
		$(this).css({display:'none'});
		$('.wrap_view').fadeOut('fast');
		//if($.browser.msie && Number($.browser.version)<7.0) $('#wrapper select').css({visibility:'visible'});
	});
	
	$('.closebtn').css({cursor:'pointer'}).click(function(){
														  
		if($.browser.msie) {
			if (Number($.browser.version)<7.0) $('#wrapper select').css({visibility:'visible'});
			//objectID = $(this).parent().parent().find('object').attr('id');
			if (objectID) document.getElementById(objectID).SetVariable("rewindVar", 'true');
		}
		
		$('#overlay').css({display:'none'});
		$(this).parent().parent().fadeOut('fast');
	});
	
	$(document).keydown(function(event) {
		if (event.keyCode == 27) {
			
			if($.browser.msie) {
				if (Number($.browser.version)<7.0) $('#wrapper select').css({visibility:'visible'});
				//objectID = $(this).parent().parent().find('object').attr('id');
				if (objectID) document.getElementById(objectID).SetVariable("rewindVar", 'true');
			}
			
			$('#overlay').css({display:'none'});
			$('.wrap_view').fadeOut('fast');
			//if($.browser.msie && Number($.browser.version)<7.0) $('#wrapper select').css({visibility:'visible'});
		}
	});
	
	//$('.prod_more').hide();
	/*
	$('a.readMore').click(function () {
		$(this).parents('.prod_body').next('.prod_more').toggle();		
		return false;
	});
	*/
});

