$(document).ready(function() {
   /**
	* _blank work around
	* Usage: <a href="http://www.google.com" rel="external">Google</a>
	*/
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	
	/**
	 * Homepage banner rotation
	 */
	var total = $('.rotate_slide').length;
	var c = 0;
	var time = 5000
	//var move = setInterval(r_slide, time);	

	function r_slide() {
		$("#rslide_" + c).fadeOut("slow");
		$("#rotate_nav li a").removeClass('current');
		c = (c >= total) ? 1 : c + 1;
		$("#rslide_" + c).fadeIn("slow");
		$("#rotate_nav li a[href=#rslide_" + c + "]").addClass('current');
	}

	$("#rotate_nav li a").click(function() {
		clearInterval(move);
		$("#rotate_nav li a").removeClass('current');
		$(this).addClass('current');
		$("#rslide_" + c).fadeOut("slow");

		var which = $(this).attr('href');
		which = which.substr(8);
		c = parseInt(which);

		$("#rslide_" + c).fadeIn("slow");
		//move = setInterval("r_slide()", time);
		return false;
	});
	
	
	/**
	 * scrollpane
	 */
	//$('.scroll-pane').jScrollPane();
	
	/**
	 * Search
	 */
	var tmp = 'Search';
	$('#s').attr('value', tmp);
	
	$('#s').focus(function() {
		tmp = $(this).attr('value');
		$(this).attr('value', '');
	});
	$('#s').blur(function() {
		if($(this).attr('value') == '') {
			$(this).attr('value', tmp);
		}
		
	});

	
	/**
	 * IE6 Drops
	 */
	sfHover = function() {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);
	
	
	/**
	 * confirm box for pros
	 */
	var gotourl = '';
	$('#change_site').click(function() {
		gotourl = $(this).attr('href');
		$( "#change_site_text" ).dialog({
			resizable: false,
			height:300,
			width: 300,
			modal: true,
			buttons: {
				"OK": function() {
					$( this ).dialog( "close" );
					window.location = gotourl;
				},
				Cancel: function() {
					$( this ).dialog( "close" );
					
				}
			}
		});
		return false;
	});
	
	/**
	 * Confirm box for likeme.com link
	 */
	$('#like_me').click(function() {
		gotourl = $(this).attr('href');
		$( "#like_me_text" ).dialog({
			resizable: false,
			height:350,
			width: 500,
			modal: true,
			buttons: {
				"OK": function() {
					$( this ).dialog( "close" );
					window.location = gotourl;
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			}
		});
		return false;
	});
	
	
	/**
	 * Confirm box for sermo.com link
	 */
	$('#sermo').click(function() {
		gotourl = $(this).attr('href');
		$( "#sermo_text" ).dialog({
			resizable: false,
			height:350,
			width: 500,
			modal: true,
			buttons: {
				"OK": function() {
					$( this ).dialog( "close" );
					window.location = gotourl;
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			}
		});
		return false;
	});
	
	/**
	 * Confirm box for docsboard.com link
	 */
	$('#docsboard').click(function() {
		gotourl = $(this).attr('href');
		$( "#docsboard_text" ).dialog({
			resizable: false,
			height:350,
			width: 500,
			modal: true,
			buttons: {
				"OK": function() {
					$( this ).dialog( "close" );
					window.location = gotourl;
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			}
		});
		return false;
	});
	
	

	
	
	
});
