/* JS FUNCTIONS
------------------------------------------------------------------------------*/

/* HOMESLIDE
------------------------------------------------------------------------------*/

  function homeSlide(){
    alert('sdsd');
    var $marginLefty = $('#homeslide').next();
    $marginLefty.animate({ marginLeft: parseInt($marginLefty.css('marginLeft'),10) == 0 ? $marginLefty.outerWidth() : 0 });



  }


/* TOPLINK
------------------------------------------------------------------------------*/

  function gotoTop(){
    $('.jspPane').css("top","0px");
    $('.jspDrag').css("top","0px");
  }


/* TCR
------------------------------------------------------------------------------*/

  var max = 24;
  function incCounter() {
    if(parseInt($('.tc').html()) < 9){
      $('.dp').html(':0');
    }else{
      $('.dp').html(':');
    }
    var currCount = parseInt($('.tc').html());
    $('.tc').text(currCount+1);
    if (currCount+1 != max) {
      setTimeout('incCounter()',50);
    }else{
      currCount = 0;
      $('.tc').html(0);
      setTimeout('incCounter()',50);
    }
  }



/* MAILTO
------------------------------------------------------------------------------*/

jQuery.fn.mailto = function() {
	return this.each(function(){
		var email = $(this).html().replace(/\s*\(.+\)\s*/, "@");
		$(this).before('<a href="mailto:' + email + '" rel="nofollow" title="' + email + '">' + email + '</a>').remove();
	});
};


/* BLANKWIN
/* written by Alen Grakalic, provided by Css Globe (cssglobe.com)
/* http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/
------------------------------------------------------------------------------*/

this.blankwin = function(){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false;
	};
	this.set = function(obj){
		obj.target = "_blank";
	};
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};
};

// script initiates on page load.

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,"load",blankwin);
