﻿jQuery.fn.infoPopup = function(oParams) {
	var text 	= $(this).attr("title");

	if(oParams.pos == "L"){
		var div		= $("div.popup_infoL[@rel="+oParams.type+"]");
	} else {
		var div		= $("div.popup_info[@rel="+oParams.type+"]");
	}

	var cDiv	= div.find("div");
	var item	= $(this);
	var typeID	= oParams.typeID;

	item.removeAttr("title");

	item.hover(function() {
		cDiv.html(text);
		div.appendTo(item.parent());
		div.show();
	}, function() {
		div.hide();
		div.insertBefore($("#"+typeID));
	});
};

jQuery.fn.extend({

	initInfoPopups: function(pos) {
		if(!pos){
			pos="";
		}

		var thumbs 	= $(this).find("label.error img");
		var type	= $(this).attr("id")+"Display";
		var typeID	= $(this).attr("id");
		thumbs.each( function(i) {
			if($(this).attr("title")){
				$(this).infoPopup({"type":type,"typeID":typeID,"pos":pos});
			}
		});
	}

});

$(document).ready(function() {
	$('img[src$=".png"]').ifixpng();

	if (typeof jQuery.fn.jdMenu == 'function') {
		$('ul.sitemenu').jdMenu({
			disableLinks: false
		});
	}

	//toggleval
	$("input.toggleInput").toggleVal({
		populateFrom:	"label",
		removeLabels:	true,
		focusClass:		"hasFocus",
		changedClass:	"isChanged"
	});

	//quick search
	$("form#searchContent, form#loginForm").submit(function(){
		$(this).find(".toggleInput").each(function() {
			if($(this).val() == $(this).data("defText")) {
				$(this).val("");
			}
		});
	});

});