/* Copyright (c) 2008 Affno (Pvt) Ltd, . All rights reserved.

Module Name		: BRNWEB1
Description		: Brandix various goodies
Created By		: Bjorn de Lima
Created Date	: Mid-2008

*/
t = null;
t2 = null;
anim = false;
current = null;
$(document).ready(function(){
// Hover for top menu
	$(".menu_top a").mouseover(function(){
		$(this).animate({ opacity: "0.6" }, 300);		
		});
	$(".menu_top a").mouseout(function(){
		$(this).animate({ opacity: "1" }, 300);		
		});
	
	$(".gal img").mouseover(function(){
		$(this).css({
		borderBottomColor : "#ffcc00"
		});
	});
	

	$(".gal img.zoom").click(function(e){
		
		if (t!=null) { clearTimeout(t);}
		if ($("#zoomer").length == 0){
		showZoom(e,this);
		}
			$("#zoomer").css({ 
			display : 'block',
			left : $(this).offset().left+($(this).width()/2),
			top : $(this).offset().top+($(this).height()/2)
			});
		
		$("#zoomimg").attr({
			src : $(this).attr('src').replace('sm','large')			  
		  });
		$("#zoomer h2").html($(this).attr('title'));
		
		}); // end mouseover event
	
	$(".gal img.zoom2").click(function(e){
		
		if (t2!=null) { clearTimeout(t2);}
		if ($("#zoomer2").length == 0){
		showZoom2(e,this);
		}
			$("#zoomer2").css({ 
			display : 'block',
			left : $(this).offset().left+($(this).width()/2),
			top : $(this).offset().top+($(this).height()/2)
			});
		
		$("#zoomimg").attr({
			src : $(this).attr('src').replace('sm','large')			  
		  });
		$("#zoomer2 h2").html($(this).attr('title'));
		
		}); // end mouseover event
	
	
	$(".gal img.zoom").mouseout(function(e){
		t = setTimeout(hide,300);
		$(this).css({
		borderBottomColor : "#333"
		});
		});
	
	$(".gal img.zoom2").mouseout(function(e){
		t2 = setTimeout(hide2,300);
		$(this).css({
		borderBottomColor : "#333"
		});
		});
	
	$("img.sizer").click(function(){
		if ($(this).hasClass('f1')){
			$(".text p").css({
					fontSize : "11px"		 
					});
			}
		if ($(this).hasClass('f2')){
			$(".text p").css({
					fontSize : "12px"		 
					});
			}
		if ($(this).hasClass('f3')){
			$(".text p").css({
					fontSize : "13px"		 
					});
			}
		});
	
	$("a.video").click(function(){
								
		showVideo(this,$(this).attr('title'));
		return false;
	});
	
	$("a.video2").click(function(){
								
		showVideo2(this,$(this).attr('title'));
		return false;
	});

	

	
	// show values lightbox image
	$(".values").click(function(e){
								
				
		cover = "<div id='bl' style='width:100%;position:absolute; background-color:#000; top:0px;left:0px; '></div>";
		image = "<div id='zoom' style='width:'><a href='#' class='vidclose'>Close</a><img id='zoomimg' /><img id='zoomimg2' style='position:absolute;top:25px;' /><a href='#' class='vidnext'>More Information</a></div>";
		$(this).after(cover);
		$(this).after(image);

		
		$("#bl").css({
		height : $(document).height(),
		width : $(document).width(),
		zIndex : '500',
		opacity : 0.8
		});
			
		current = $(this).attr("id");	
			
		$("#zoomimg").attr({
			src : "../images/values/"+$(this).attr("id")+".jpg"		  
		  });
		
		$("#zoomimg2").css({
			display:'none',
			position : 'absolute',
			left : '0px'
			 });

		$(".vidnext").click(function(e){
			var width = 600;
			var height = 600;
			var left = parseInt((screen.availWidth/2) - (width/2));
			var top = parseInt((screen.availHeight/2) - (height/2));
			var windowFeatures = "width=" + width + ",height=" + height + ",scrollbars=yes,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
			window.open("../brandix/values/"+current+"_pop.html", "win", windowFeatures);
		});
		/*
		$(".vidnext").click(function(e){
			window.open("../brandix/values/"+current+"_pop.html",'win','width=600,height=600,scrollbars=yes');
			 });
		*/
		$("#zoomimg2").attr({
			src : "../images/values/"+$(this).attr("id")+"_text.jpg"		  
		  });
		
		setInterval(animateValues,5000);
	
	$("#zoom").css({
		zIndex : '700',
		position : 'absolute',
		left: ($(window).width()-300)/2,
		top: $(document).scrollTop()+(($(window).height()-420)/2)
		});
	
	$("#zoomimg").css({
	border : "5px solid #fff"
	});	
		
			
		$("#bl, .vidclose").bind("click", function(){
				$("#bl").remove();
				$("#zoom").remove();
				});
		}); // end mouseover event
	



	// highlight cuurent link
	// called automatically
	objs = $("#sectionmenu a");
	found = false;	
	for (i=0;i<objs.length;i++){
		
		obj = objs[i];

		sPath = window.location.pathname;
		sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		
		if (sPage==$(obj).attr('href')){
		found = true;
		$(obj).css({
		backgroundImage : "url('../images/current_point.gif')",
		backgroundPosition : "center top",
		backgroundRepeat : "no-repeat"
		});
		
		}			
	}
	if (!found){
	if (sPath.indexOf('people') == -1 ){
		$("#sectionmenu a:first").css({
			backgroundImage : "url('../images/current_point.gif')",
			backgroundPosition : "center top",
			backgroundRepeat : "no-repeat"
			});
			}
		else{
		$("#sectionmenu a.def").css({
			backgroundImage : "url('../images/current_point.gif')",
			backgroundPosition : "center top",
			backgroundRepeat : "no-repeat"
			});
		
		}	
			
	}
	
}); // dome ready eveny ends

function hide(){
	$("#zoomer").fadeOut('medium');
	}
	
function hide2(){
	$("#zoomer2").fadeOut('medium');
	}
function showZoom(e,obj){
	html = "<div id='zoomer'><b class='rtop'><b class='r1'></b> <b class='r2'></b> <b class='r3'></b> <b class='r4'></b></b><div class='content'><h2></h2><img id='zoomimg'></div><b class='rbottom'><b class='r4'></b> <b class='r3'></b> <b class='r2'></b> <b class='r1'></b></b></div>";

	$(obj).after(html);
	$("#zoomer").css({ display : 'none'});	

	
}

function showZoom2(e,obj){
	html = "<div id='zoomer2'><b class='rtop'><b class='r1'></b> <b class='r2'></b> <b class='r3'></b> <b class='r4'></b></b><div class='content'><h2></h2><img id='zoomimg'></div><b class='rbottom'><b class='r4'></b> <b class='r3'></b> <b class='r2'></b> <b class='r1'></b></b></div>";

	$(obj).after(html);
	$("#zoomer2").css({ display : 'none'});	

	
}

function showVideo(obj,name){
	file = "../flash/vidplayer.swf";
	width = 640;
	height = 350;
	
	cover = "<div id='bl' style='width:100%;position:absolute; background-color:#000; top:0px;left:0px; '></div>";
	html = "<div id='vid' style='position:absolute;'><div class='content' style='background-color:#333;padding:0px;'><a href='#' class='vidclose'>Close</a><object type='application/x-shockwave-flash' width='"+width+"' height='"+height+"' data='"+file+"' FlashVars='videoname="+name+"'><param name='movie' value='"+file+"' /><param name='quality' value='high' /><param name='FlashVars' value='videoname="+name+"' /><param name='wmode' value='opaque' /><embed src='"+file+"' quality='high'   wmode='opaque'></embed></object></div></div>";
	$(obj).after(cover);
	$(obj).after(html);
	
	$("#bl").css({
		height : $(document).height(),
		width : $(document).width(),
		zIndex : '500',
		opacity : 0.7
		});

	$("#vid").css({
		zIndex : '700',
		left: ($(window).width()-$("#vid").width())/2,
		top: $(document).scrollTop()+(($(window).height()-height)/2)
		});
	
	
	$("a.vidclose").click(function(){
		$("#vid").remove();
		$("#bl").remove();
		anim = false;
		return false;
		});
	}
	
function showVideo2(obj,name){
	file = "../flash/vidplayer2.swf";
	width = 540;
	height = 445;
	
	cover = "<div id='bl' style='width:100%;position:absolute; background-color:#000; top:0px;left:0px; '></div>";
	html = "<div id='vid' style='position:absolute;'><div class='content' style='background-color:#333;padding:0px;'><a href='#' class='vidclose'>Close</a><object type='application/x-shockwave-flash' width='"+width+"' height='"+height+"' data='"+file+"' FlashVars='videoname="+name+"'><param name='movie' value='"+file+"' /><param name='quality' value='high' /><param name='FlashVars' value='videoname="+name+"' /><param name='wmode' value='opaque' /><embed src='"+file+"' quality='high'   wmode='opaque'></embed></object></div></div>";
	$(obj).after(cover);
	$(obj).after(html);
	
	$("#bl").css({
		height : $(document).height(),
		width : $(document).width(),
		zIndex : '500',
		opacity : 0.7
		});
	$("#vid").css({
		zIndex : '700',
		left: ($(window).width()-$("#vid").width())/2,
		top: $(document).scrollTop()+(($(window).height()-height)/2)
		});
	
	
	$("a.vidclose").click(function(){
		$("#vid").remove();
		$("#bl").remove();
		return false;
		});
	}	


function animateValues(){
	if (!anim){
	$("#zoomimg2").fadeIn('slow');		
	$("#zoomimg1").fadeOut('slow');
	anim = true;
	}
	else{
	$("#zoomimg2").fadeOut('slow');		
	$("#zoomimg1").fadeIn('slow');
		anim = false;
		}
	}