
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


// place any jQuery/helper plugins in here, instead of separate, slower script files.

/* sliding_effect.js
 * Navigation Effect Using jQuery By Bedrich Rios
 * http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-mootools-homepage-inspired-navigation-effect-using-jquery/
 */
function slide(navigation_id, pad_out, pad_in, time, multiplier)
{
	// creates the target paths
	var list_elements = navigation_id + " li.sliding-element";
	var link_elements = list_elements + " a";
	
	// initiates the timer used for the sliding animation
	var timer = 0;
	
	// creates the slide animation for all list elements 
	$(link_elements).each(function(i)
	{
		// margin left = - ([width of element] + [total vertical padding of element])
		$(this).css("margin-left","-180px"); // super swiping intro
		// updates timer
		timer = (timer*multiplier + time);
		$(this).animate({ 
			marginLeft: "0", 
			opacity: 0
		 }, timer);
		$(this).animate({ 
			marginLeft: "30px",
		 	opacity:.5
		}, timer);
		$(this).animate({ 
			marginLeft: "10px",
			opacity:1
		}, timer);
	});

	// creates the hover-slide effect for all link elements 
	$(list_elements).bind({
				mouseenter:function()
				{
					// $(this).animate({ paddingLeft: pad_out }, 150);
					//if ( $(this).hasClass('c') ) {
						//$(this).parent().prepend("<span id='hlp_spc' style='height:"+$(this).height()+"px'></span>")
						//$("#hlp_spc").width(pad_out);
						$(this).animate({ paddingLeft: pad_out }, 150);
					//}
				},
				mouseleave:function()
				{
					// $(this).animate({ paddingLeft: pad_in }, 150);
				//if ( $(this).hasClass('c') ){	
					$(this).animate({ paddingLeft: pad_in }, 150);
					//}
				}
			}
		);
	
}


//Nested Side Bar Menu (Mar 20th, 09)
//By Dynamic Drive: http://www.dynamicdrive.com/style/csslibrary/item/nested_side_bar_menu/

var menuids=["sliding-navigation"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas

function initsidebarmenu(){

	for (var i=0; i<menuids.length; i++){
	   
	    var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
		
		for (var t=0; t<ultags.length; t++){
			
			ultags[t].parentNode.getElementsByTagName("a")[0].className+=" subfolderstyle"
			 if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
			   ultags[t].style.right=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
			else //else if this is a sub level submenu (ul)
			
			ultags[t].style.right=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
			
			ultags[t].parentNode.onmouseover=function(){
				this.getElementsByTagName("ul")[0].style.display="block";
			}
			
			ultags[t].parentNode.onmouseout=function(){
				this.getElementsByTagName("ul")[0].style.display="none";
			}
		
		}
		for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
		  ultags[t].style.visibility="visible";
		  ultags[t].style.display="none";
		}
	  }
}
function initsidebarmenu_jq(){
	for (var i=0; i<menuids.length; i++){
		$("#"+menuids[i]+" ul").each(function(){
			$(this).parent().children("a").addClass("subfolderstyle");
			$(this).css("right", $(this).parent().attr("offsetWidth")+"px");
				//fix for ie 8 and lower
				if ($.browser.msie)  
				if (parseInt($.browser.version) <= 8)
				$(this).find("li a").css("margin-top", "-1px")	
				
			$(this).parent().bind({
			mouseenter:function(){$(this).children("ul").show();},
			mouseleave:function(){$(this).children("ul").hide();}
			});
			
		})	
	}
}

//setting images size depending on browser window
		function SetImgSize(jqObj, init){
			
			mnWidth = 640;//320;//640;
			mnHeight = 480;//280;//480;
			
			jqObj.each(function(){
			  mxWidth =$(this).attr("naturalWidth");;
			  mxHeight = $(this).attr("naturalHeight");
			  ratio = mxHeight/mxWidth;
			   	  
			  if (prWidth===$(window).width())
			   {
				   if ($(this).parent().parent().hasClass("portfolio"))
				    nwHeight = $(window).height()-370;
				   else
					nwHeight = $(window).height()-245;
					
					if (nwHeight>mxHeight) nwHeight = mxHeight;
					if (nwHeight<mnHeight) nwHeight = mnHeight;
					nwWidth = nwHeight/ratio;
			   }
			   else{	
			   	   prWidth=$(window).width();	 	
				   nwWidth = $(window).width()-200;
				   if (nwWidth>mxWidth) nwWidth = mxWidth;
				   if (nwWidth<mnWidth) nwWidth = mnWidth;
				   nwHeight = nwWidth*ratio;
			   }
			   
			   jqObj.width(nwWidth);
			   jqObj.height(nwHeight);
			   
			   //changing slides container accordingly, but not initally
			    if (init!==true){
				if (jqObj.parent().hasClass("slides"))	
			   		jqObj.parent().height( jqObj.height());
				else if (jqObj.parent().parent().hasClass("portfolio"))	
					jqObj.parent().parent().height( jqObj.height());
				
			   //$("#top-left .slides").height( jqObj.height());
			   //$("#top-left .slides").width( jqObj.width());
			   }
			  
		  })
		}
