
/**
We don't organize it in module  because we think that it is used in interfaces html 
**/
sg.enabled = function enabled(elementOrSelector) {
	return $(elementOrSelector).each(function(i, e) {
		var $this = $(this);
		$this.css("cursor", "pointer");
		var options = $this.data("options") || {};
		options.enabled = true;
		$this.data("options", options);
	});
}

sg.disabled = function disabled(elementOrSelector) {
	return $(elementOrSelector).each(function(i, e) {
		var $this = $(this);
		$this.css("cursor", "default");
		var options = $this.data("options") || {};
		options.enabled = false;
		$this.data("options", options);
	});
}

sg.hide = function(elementOrSelector) {
	$(elementOrSelector).hide();
}
sg.show = function(elementOrSelector) {
	$(elementOrSelector).show();
}
sg.fadeIn = function(elementOrSelector) {
	$(elementOrSelector).fadeIn("slow");
}
sg.fadeOut = function(elementOrSelector) {
	$(elementOrSelector).fadeOut("slow");
}

//태그의 sg-call속성에 있는 자바스크립트 실행///////*함수명으로 함수호출*/
function sg_call(element) {
	if (!element) {
		throw "sg_call에서 element값이 " + element;
		return;
	}
	//var fnNames = element.dataset["sgCall"];
	var fnNames = element.getAttribute("data-sg-call");
	if (fnNames) {
		eval(fnNames);
	}
}


sg.swapImg = function swapImg(elementOrSelector) {
	var $img = $(elementOrSelector);
	$img.each(function(i, e) {
		/*
				if(this.dataset["sgSrc"]){
					var tempSrc = this.src;
					this.src = this.dataset["sgSrc"];
					this.dataset["sgSrc"] = tempSrc;
				}
				*/
		var $me = $(this);
		var tempSrc = $me.attr("src");
		$me.attr("src", $me.attr("data-sg-src"));
		$me.attr("data-sg-src", tempSrc);
	});
}


// Events ////////////////////////////////////

// @function toggle to other 
sg.toggleOther=function(){
    var me = $(this);
    console.log(me);
    var other=me.attr('data-sg-toggle-other');
    var selector=me.attr('data-sg-selector');// look in this
    console.log(selector);
    if(selector=="" || selector==undefined){
    	me.parent().find(other).toggle();
    	console.log(me.parent().html());
    }else{
    	$(selector).find(other).toggle();
    }
    sg.sound('success-low',true);
}




