// 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.



/*
* Title: BlueMouse Custom Scripts
* Author: Yves Torres
* Standard Scripts
*/


/*
* prepare external links
*/

(function externalLinks() {	
	if (!document.getElementsByTagName) return; 
 	var anchors = document.getElementsByTagName("a"); 
 	for (var i=0; i<anchors.length; i++) { 
   		var anchor = anchors[i]; 
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "blank")anchor.target = "_blank"; 
	} 
})(document); 

/*
* set & get Cookies 
*/

function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var name_eq = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(name_eq) == 0) return c.substring(name_eq.length,c.length);
	}
	return null;
}

	
/*
* cycle_slideshow 
*/

function cycle_slideshow() {
	$('.slideshow').each(function(){
		if($(this).find('.element').length>1)
			$(this).cycle({slideExpr:'.element', timeout:6000, cleartype: true, cleartypeNoBg: true})
	});
}


/*
* ghostVal
*/

function ghostVal(el,txt) {
	$(el).attr('value',txt);
	$(el).data('txt',txt);
	if($(el).attr('type')=='password') {
		repField = "<input onfocus=\"replaceField(this,'"+$(el).attr('id')+"')\" type=\"text\" value=\""+txt+"\" id=\""+$(el).attr('id')+"\" style=\""+$(el).attr('style')+"\" maxlength=\""+$(el).attr('maxlength')+"\" name=\""+$(el).attr('name')+"\" />";
		orgField = "<input onblur=\"replaceField(this,'"+$(el).attr('id')+"')\" type=\"password\" value=\"\" id=\""+$(el).attr('id')+"\" style=\""+$(el).attr('style')+"\" maxlength=\""+$(el).attr('maxlength')+"\" name=\""+$(el).attr('name')+"\" />";
		$(el).replaceWith(repField);
	}
	else {
		$(el).bind('focus',function() { 
			if($(this).attr('value')==$(el).data('txt')) {
				$(this).attr('value',''); 
			}
		});
		$(el).bind('blur',function() { 
			if($(this).attr('value')=='') {
			$(this).attr('value',$(el).data('txt')); 
			}
		});
	}
}

/*
* Shadowbox
*/

var sbTimer,sbBodyHeight,setHeight;

function reloadPage() {
	location.reload(true);
}
	
function sbAutoHeight() {
	var body = $('body:first');
	var sbWrapper = $('#sb-wrapper');
	var sbWrapperInner = $('#sb-wrapper-inner');
	var _setHeight = function() {
		var bodyHeight = $(window).height();	
		var sbOuterHeight = sbWrapper.height();
		var _sbBodyHeight = sbBodyHeight+4;
		if(sbBodyHeight>bodyHeight-100)
			_sbBodyHeight=bodyHeight-100;
		var newYpos = parseInt((bodyHeight/2)-(sbOuterHeight/2));	
		sbWrapperInner.height(_sbBodyHeight);
		sbWrapper.css({'top':newYpos+'px'});
	}
	sbTimer = setInterval(_setHeight,50);
}

function initShadowboxes() {
	Shadowbox.init({overlayColor:'#2c2c2e',overlayOpacity: 0.8, modal: true, skipSetup: true, onClose:function(){ reloadPage(); clearInterval(sbTimer); } });
	// Standard
	var stdOverlays = $('.shadowbox');
	if(stdOverlays.length) {
		stdOverlays.click(function(event){
			event.preventDefault();
			Shadowbox.open({
				player: 'iframe',
				content: url=$(this).attr('href'),
				width: 800,
				height: 600				
			});
		});
	}
}

/*
* Auto closing of Shadowbox
*/

function autoClosebox() {
	var messageSuccessDiv = $('.success');
	if(messageSuccessDiv.length>0) {
		messageSuccessDiv.animate({'opacity':1},2000).fadeOut(500,function(){ window.parent.Shadowbox.close(); });	
	}
}

/*
* Get height of overlay, uncomment if required

	parent.sbBodyHeight = $('#overlay').height();
	parent.sbAutoHeight(); */

/*
* schriftersetzung mit cufon
*/

(function cufonFontReplace() {
	Cufon.replace('.cufon', { fontFamily: 'futura' });
})(document); 

/*
* Animations
*/

function animations(){
}

