$(function() {
	$("div.rs_grayblock_in[rel]").overlay({effect: 'apple'});
});
$(document).ready(function()
{
	$("body").click(function (){
		$("div.dropblock").hide();
		$("div.dropblock1").hide();
		$("div.dropblock4").hide();
		//$("div.dropblock6").hide(); // education in doctor profile edit
		$("div.dropblock66").hide();
		$("div.dropblock7").hide();
		$("div.dropblock8").hide();
		$("div.dropblock9").hide();
		//return false;
	});	
	
	$("div.rs_icons a").bind("mouseenter",function(){
		$("img", $(this)).attr("src", str_replace("_off", "_on", $("img", $(this)).attr("src")));
	});
	$("div.rs_icons a").bind("mouseleave",function(){
		$("img", $(this)).attr("src", str_replace("_on", "_off", $("img", $(this)).attr("src")));
	});
	$("div.footer_icons a").bind("mouseenter",function(){
		$("img", $(this)).attr("src", str_replace("_off", "_on", $("img", $(this)).attr("src")));
	});
	$("div.footer_icons a").bind("mouseleave",function(){
		$("img", $(this)).attr("src", str_replace("_on", "_off", $("img", $(this)).attr("src")));
	});
	$("div.greenboxes a").bind("mouseenter",function(){
		$("img", $(this)).attr("src", str_replace("_off", "_on", $("img", $(this)).attr("src")));
	});
	$("div.greenboxes a").bind("mouseleave",function(){
		$("img", $(this)).attr("src", str_replace("_on", "_off", $("img", $(this)).attr("src")));
	});
	if(bLightBoxOn == true) {
		$('#gallery a[rel=lightbox-gallery]').lightbox();
		
		$.Lightbox.construct({
			"text": {
				// For translating
				"image":        "Image",
				"of":           "of",
				"close":        "Close X",
				"closeInfo":    "You can also click anywhere outside the image to close.",
				"download":     "Download.",
				"help": {
					"close":    "Click to close",
					"interact": ""
				},
				"about": {
					"text":     "",
					"title":    "",
					"link":     ""
				}
			}
		});
	}
	
	if(bTreatmentsRightDynamicOn == true) {
		$("a.fakeRTMenuLink").click(function(){
			toggleFaqLikeBlocks($("#"+str_replace("RTMenuLink", "", $(this).attr("id"))+" a:first-child"));
		});
	}
	
	$("#dim").css("height", $(document).height());
	$("div.rs_grayblock_in").click(function(){
		$("#dim").fadeIn();
		return false;
	});
	$("a.close").click(function(){
		$("#dim").fadeOut('fast');
		document.getElementById('ply').sendEvent('STOP');
		return false;
	});
	$(window).bind("resize", function(){
		$("#dim").css("height", $(document).height());
	});
	$("div.tmenu").bind("mouseenter",function()
	{
		$(this).children("div").show();
		$(this).children("a.tlink[hassub='Y']").height("42px");
		$(this).children("a.tlink_on[hassub='Y']").height("42px");
		$(this).children("a.tlink").removeClass("tlink").addClass("tlink_on");
	});
	
	$("div.tmenu").bind("mouseleave",function()
	{
		$(this).children("div").hide();
		$(this).children("a.tlink_on[hassub='Y']").height("41px");
		$(this).children("a.tlink[hassub='Y']").height("41px");
		$(this).children("a.tlink_on").not("a[sel=Y]").removeClass("tlink_on").addClass("tlink");
	});	
	
	$("a.rmore").not(".none-dynamic").unbind('click');
	$("a.rmore").not(".none-dynamic").removeAttr('onclick');
	$("a.rmore").not(".none-dynamic").click(function (){
	    var t = $(this);
		$('#'+$(this).attr("id")+'_toggle1').toggle(400, function() {
			if(t.hasClass("opened")) {
				$('#'+t.attr("id")+'_toggle1').css("display", "inline");
			}
			else if (t.hasClass("rmore")){
				$('#'+t.attr("id")+'_toggle1').css("display", "none");
			}
		});
		
		if($(this).hasClass("opened")) {
			//$('#'+$(this).attr("id")+'_toggle1').css('display', 'none');
			$(this).removeClass("opened").addClass("rmore");
		}
		else if ($(this).hasClass("rmore")){
			//$('#'+$(this).attr("id")+'_toggle1').css('display', 'inline');
			$(this).removeClass("rmore").addClass("opened");
		}
		
		
		if($(this).text() == 'Read More') {
			$(this).text('Hide');
		}
		else if ($(this).text() == 'Hide'){
			$(this).text('Read More');
		}
		return false;
	});
	$("a").click(function (){
		if($(this).children(':first-child').attr("src") == '/images/newsletter/close_button.png' || $(this).children(':first-child').attr("src") == '/images/close_button.png') {
			if($.browser.msie){
				$(this).parent().hide();
			}
			else {
				$(this).parent().fadeOut('fast');
			}
			return false;
		}
	});
	$("div.comment_line").children("a").click(function (){
		toggleFaqLikeBlocks($(this), 'Hide Comments', 'Show Comments');
		return false;
	});
	
});	
parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};
