// window fix for ventus js style
function windowFix( frst, scnd, flag ){
	var d_Array = new Array( document.getElementById( frst ), document.getElementById( scnd ) );
	var dArray = new Array( d_Array[0].offsetHeight, d_Array[1].offsetHeight );
	// find highest
	var highest = 0;
	for( var x = 0; x < 2; x++ ){
		var y = dArray[x];
		if( y > highest ){
			highest = y;
			if( agent ){
				if( x = 0 ){
					d_Array[1].style.height = highest + 'px';
				} else{
					d_Array[0].style.height = highest + 'px';
				}
			}
		}
	}

	if( dArray[0] < dArray[1] ){
		d_Array[0].style.height = dArray[1] + 'px';
	}

	if( flag ){
		var top = Math.floor( ( highest - 380 ) / 2 );
		document.getElementById( 'ventus-content-divider' ).style.top = top + 'px';
	}
}

var agent = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1;

function changeTestiBG( id, flag ){
	var d = document.getElementById( id );
	var content = document.getElementById( 'ventus-testimonials-part' ).innerHTML;
	var _d = document.getElementById( 'ventus-testimonials-content' );
	if( flag ){
		d.className = 'left ventus-testimonials-clicked';
		_d.innerHTML = content;
		_d.className = 'ventus-testimonials-content';
	} else if( !flag ){
		if( theId == 'ventus-testimonials-content' && agent ){
			d.className = 'left ventus-testimonials-notclicked';
			_d.innerHTML = '';
			_d.className = '';
		} else if( theId != 'ventus-maincontent' && theId != 'ventus-content-right' && !agent ){
			d.className = 'left ventus-testimonials-notclicked';
			_d.innerHTML = '';
			_d.className = '';
		}
	}
}

var TestiAnimation = function(){
	var int, min_h, max_h, max_t, min_t;

	return {
		animate: function( d, mh, f ){
			if( !d.min_h ){
				d.min_h = d.offsetHeight;
			}

			if( !d.max_h ){
				d.max_h = mh;
			}

			d.max_t = 20;
			d.min_t = 250;

			clearInterval( int );

			int = setInterval( function(){ TestiAnimation.slide( d, f ); }, 30 );
		},
		slide: function( d, flag ){
			var mh = d.offsetHeight;
			var mt = d.offsetTop;
			var _n = document.getElementById( 'ventus-new-testimonials-main-content' );
			var _t = document.getElementById( 'ventus-new-testimonials-main-arrow' );

			if( ( d.offsetHeight - 20 ) == ( d.max_h - 20 ) ){
				_n.innerHTML = '<strong>Testimonial</strong>';
			}

			if( flag ){
				// animate
				_mh = mh + 30;
				_mt = mt - 30;
				_mt = ( _mt <= d.max_t ) ? d.max_t : _mt;
				_mh = ( _mh >= d.max_h ) ? d.max_h : _mh;
				d.style.top = _mt + 'px';
				d.style.height = _mh + 'px';
				_n.style.height = _mh + 'px';
				
			} else if( !flag ){
				_mh = mh - 30;
				_mt = mt + 30;
				_mh = ( _mh <= d.min_h ) ? d.min_h : _mh;
				_mt = ( _mt >= d.min_t ) ? d.min_t : _mt;
				d.style.height = _mh + 'px';
				_n.style.height
				d.style.top = _mt + 'px';
			} else{
				clearInterval( int );
			}

			if( flag && d.offsetHeight == d.max_h ){
				clearInterval( int );
				_n.innerHTML = document.getElementById( 'ventus-testimonials-part' ).innerHTML;
				_t.className = 'ventus-new-testimonials-main-arrow-v';
			} else if( !flag && d.offsetHeight == d.min_h ){
				clearInterval( int );
				_n.innerHTML = '<strong>Testimonial</strong>';
				_t.className = 'ventus-new-testimonials-main-arrow-h';
			}
		}
	}
}();

/* fix to ie mouseover bug */
var theId
function grabID( e ){
	var targ;
	if ( !e ){
		var e = window.event;
	}
	if ( e.target ){ 
		targ = e.target;
	} else if ( e.srcElement ){
		targ = e.srcElement;
	}
	if ( targ.nodeType == 3 ){
		targ = targ.parentNode;
	}
	theId = targ.id
}

document.onmouseover = grabID;
