// JavaScript Document
var $j = jQuery.noConflict(), c_Global_timeout = new Array(), c_Stat = true, c_Fullpat = '', c_currPath = '', c_num_loops = 0;
$j(document).ready(function(){c_global_Loader();});
function c_global_Loader(){
	(document.getElementById('tea_dialog'))?'':$j('body').prepend('<div id="tea_dialog"></div>');
	$j('link').each(function(){
		if($j(this).attr('rel') == 'index')c_Fullpat = $j(this).attr('href');	
		if($j(this).attr('rel') == 'canonical')c_currPath = $j(this).attr('href');
	});	
}


function c_focustext(o){
	var tsf_v = $j(o);
	tsf_v.focus(function(){
		if($j(this).val() == $j(this).attr('title')){
			$j(this).val('');		
		}
	});
	tsf_v.blur(function(){
		if($j(this).val() == ''){
			$j(this).val($j(this).attr('title'));
		}else if($j(this).val() == $j(this).attr('title')){
			$j(this).val($j(this).attr('title'));
		}
	});
}


function c_EmailStat(o){	
	var email = o.val();
	var passed;
	var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen;
	intAtSign=email.indexOf("@");
	intDot=email.indexOf(".",intAtSign);
	intComma=email.indexOf(",");
	intSpace=email.indexOf(" ");
	intLastDot=email.lastIndexOf(".");
	intDomain=intDot-intAtSign;
	intStrLen=email.length;
	// *** CHECK FOR BLANK EMAIL VALUE
	
	if (intAtSign == -1){
		c_default_error_box(o);
	}else if (intComma != -1){
		c_default_error_box(o);
	}else if (intSpace != -1){
		c_default_error_box(o);
	}else if ((intDot <= 2) || (intDomain <= 1)  || (intStrLen-(intLastDot+1) < 2)){
		c_default_error_box(o);
	}
};



function c_EmptyStat(o){
	if(o.val() == '' || o.val() == o.attr('title')){
		c_default_error_box(o);
	}
}

function c_default_error_box(obj){
	$j(obj).css({
		'border':'#bf9b9b 1px solid',
		'color':'#c90000'	
	});	
	c_Stat = false;
}




function c_NumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))return false;
	return true;
}


function c_scroll_anywhere(setheight){

	$j.fn.extend({
		autoscroll: function(options) {
			return this.each(function() {
				var $this = $j(this);
				$this.css({overflow:'hidden'});
				if(options.direction == 'horizontal') $this.mousemove(function(e) {
					var width = $this.width();
					$this.attr({ scrollLeft: ($this.attr('scrollWidth')-width)*(0.5-Math.cos(Math.PI*(e.pageX-$this.offset().left)/width)/2) });
				});
				else if(options.direction == 'vertical') $this.mousemove(function(e) {
					var height = $this.height();
					$this.attr({ scrollTop: ($this.attr('scrollHeight')-height)*(0.5-Math.cos(Math.PI*(e.pageY-$this.offset().top)/height)/2) });
				});
				else $this.mousemove(function(e) {
					var width = $this.width(), height = $this.height();
					$this.attr({ scrollLeft: ($this.attr('scrollWidth')-width)*(0.5-Math.cos(Math.PI*(e.pageX-$this.offset().left)/width)/2), scrollTop: ($this.attr('scrollHeight')-height)*(0.5-Math.cos(Math.PI*(e.pageY-$this.offset().top)/height)/2) });
				});
			});
		}
	});
	$j('html, body').animate({scrollTop: setheight}, "fast", 'linear');
}


