/*****************************************************************
File : 			common.js
Author : 		Martin Halla , martin@halladesign.com , www.halladesign.com
Created : 		November 2008 NYC , NY 
Description : 	This file holds jquery functions and the other js functions
				needed throughout the site
*****************************************************************/


/* Jquery Document ready */
$(document).ready(
	function(){ 
		$("ul.").slideDown("slow");
		
		// hide the content so it can be animated
		if(jQuery("#mycarousel").length==0) {
			jQuery(".content").css({"display":"none"});
		}	
		
		// show content home
		$(".content.home").css({"display":"block"});
		
		// hide these so it can be animated
		$(".content.home img.home , .homepage-center").css({"display":"none"});
		$(".content.home img.home, .homepage-center").show("slow");
		
		// hide the forms to be able to animate them
		$("form").css({"display":"none"});
		$("form").slideDown("slow");
		
		// position the submenu for the animation
		// animate only when no carousel
		
		$(".submenu").css({"left":"1000px"});
		// animate the submenu 
		$(".submenu").animate({"left":"-=1000px"},1000,function()
				{
					show_content();
					
				});
				

		$("#vjustifyExample").click(function(){adjust_columns();})
		
		
		/*
		var files = [
					'company.flv',
					'dovas1a.flv',
					'dovas1b.flv',
					'dovas2.flv',
					'Fall2007.flv',
					'intro.flv',
					'Philosophy.flv',
					'video.flv'
					];
		*/			
		var files = [
					'dovas1b.flv',
					'dovas2.flv',
					'Fall2007.flv'
					];			


			/*
			files[1] = 'company.flv';
			files[1] = 'dovas1a.flv';
			files[1] = 'dovas1b.flv';
			files[1] = 'dovas2.flv';
			files[1] = 'Fall2007.flv';
			files[1] = 'intro.flv';
			files[1] = 'Philosophy.flv';
			files[1] = 'video.flv';
			*/
		
		for(var i = 0;i<8;i++) {
			var object_name  = "#vidPlayer" +i;
			if($(object_name).length != 0) {
				var dom_object = "videoPlayer";
				var vidPlayer = new SWFObject("/video/player_v416.swf", dom_object, "400", "300", "8", "#6699CC");
				vidPlayer.addParam('allowscriptaccess','always');
			  	vidPlayer.addParam('allowfullscreen','true');
			  	vidPlayer.addParam('autostart','false');
			  	/* Default moview and picture */
			  	//vidPlayer.addParam('flashvars','&file=/video/dovas2.flv&image=/video/fox-news-logo.jpg');
			  	vidPlayer.addParam('flashvars','&file='+ files[i]);
			  	vidPlayer.addVariable('javascriptid','videoPlayer');
			  	vidPlayer.addVariable('enablejs','true');
			  	//vidPlayer.addVariable("linktarget", "_self");
				vidPlayer.write("vidPlayer"+ i);
			}
		}	
	
		$("p.answer").css({display:"none"});
		
	
		  
		
	}); // end document ready
	
	
	
function show_content() {
	$(".content").slideDown("slow",function(){adjust_columns();});
	
					
	
}	
/* toggles the questions visibility */	
function show_faq_answer(id) {
	
		
			$("p.answer").css({display:"none"});
			$("#"+id).css({display:""});
		
}	
	
	
/* adjusts the CSS submenu columns heights*/	
	


function adjust_columns() {
					
					if($(".content_holder").length != 0 ) {
						
						var submenuHeight = $(".submenu").height();
						var contentHeight = $(".content_holder").height();
						//alert("Hey ,content shown, now the numbers : submenuHeight " + submenuHeight + "\nContent Height " + contentHeight);
						
						if(submenuHeight >contentHeight) {
							$(".content_holder").css({"height":submenuHeight})
						}else {
							$(".submenu").css({"height":contentHeight})
						}
						/*******************************8
						D E B U G G I N G
						
						var submenuHeight2 = $(".submenu").height();
						var contentHeight2 = $(".content_holder").height();
						
						alert("After the Update "+ submenuHeight2 +  "  submenuHeight,\n Content Height " + contentHeight2);
						********************************/
					
					}
					
					else if ($(".content").length != 0 ) {
						var submenuHeight = $(".submenu").height();
						var contentHeight = $(".content").height();
						//alert("Hey ,content shown, now the numbers : submenuHeight " + submenuHeight + "\nContent Height " + contentHeight);
						
						if(submenuHeight >contentHeight) {
							$(".content").css({"height":submenuHeight})
						}else {
							$(".submenu").css({"height":contentHeight})
						}
					}else {
						alert("alert : "  + $(".content_holder").length);
					}
					
					


}

	
	
/* this has been taken from the affiliates ..., I don' really use it '*/	
function sendEvent(swf,typ,prm) { 
	thisMovie(swf).sendEvent(typ,prm); 
};


function getUpdate(typ,pr1,pr2,swf) {};




function thisMovie(swf) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[swf];
	} else {
		return document[swf];
	}
};





function loadFile(swf,obj) { 
	thisMovie(swf).loadFile(obj);
};



/* this is for the ice-beauty collection ,
it displays the three pictures at the same time , ajaxable :-)*/
function show_three_pics(img_path,pic_number) {
	var order = 1;
	//alert(pic_number); // debugging
	order = (pic_number % 3);
	
	// get the element name 
	var el_name = "#pic-1";
	switch (order) {
		case 0 :
			el_name = "#pic-3";
			break;
		case 1 :
			el_name = "#pic-1";
			break;
		case 2 :
			el_name = "#pic-2";
			break;		
	}
	//	alert(el_name);		// debugging
	//var el_name = "#pic-2";
	
	
	// html text to injet into the element
	var text = "<img src = \"" + img_path + "\" alt = \"\" border = \"0\" />";
	
	// jquery call 
	$(el_name).html(text);
	$(el_name).css({"display":"none"});
	$(el_name).fadeIn("slow");
	
	//alert(text); // debugging 
	return false;
}

