var isSwf = false;

/*

jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);	
}; 
*/


/*



// starting the script on page load
$(document).ready(function(){
	tooltip();
});
// starting the script on page load
$(document).ready(function(){
	tooltip();
	imagePreview();
});

// starting the script on page load
$(document).ready(function(){
});
*/





(function($){

	$(document).ready(function(){


    runAfterLoad();
    
    /////easy-slider///
    $(document).ready(function(){
        $("#slides").slides({
          play: 5000,
	      effect: 'slide, fade',
          slideSpeed: 500,
	      generatePagination: false
    });
  });
  /////
  ///setTheme///
  function setTheme() {
      var theTheme = false;
      var hashes = location.href.slice(location.href.indexOf('?') + 1).split('&');
      for (var i = 0; i < hashes.length; i++) {
        var theHash = hashes[i].split('=');
        if (theHash[0] == 'theme') {
          var theTheme = theHash[1];
        }
      }
      if (theTheme) {
        $('a').each(function(){
          if ($(this).attr('href')) {
            if ($(this).attr('href').indexOf('?') == -1) {
              $(this).attr('href', $(this).attr('href') + '?theme=' + theTheme);
            } else {
              $(this).attr('href', $(this).attr('href') + '&theme=' + theTheme);
            }
          }
        });
      }
    }  
       setTheme();
        
            /////
    

//
//$("div").one('click', function () {
//  if ($(this).is(":first-child")) {
//    $("p").text("It's the first div.");
//  } else if ($(this).is(".blue,.red")) {
//    $("p").text("It's a blue or red div.");
//  } else if ($(this).is(":contains('Peter')")) {
//    $("p").text("It's Peter!");
//  } else {
//    $("p").html("It's nothing <em>special</em>.");
//  }
//  $("p").hide().slideDown("slow");
//  $(this).css({"border-style": "inset", cursor:"default"});
//});


//$('#grid-content ul').css({"position":"relative"});
  
//  $(this).width(30).css({"float":"left", "background-color":"blue", "height":"auto", "display":"block"});
//
//if (i==1) {
//$(this).css({"left":"300px"});
//} else if (i==2) {
//$(this).css({"left":"600px"});
//}



 // alert(i)

 // = "33";
 
//   alert( $(this).height());
 
// $(this).hide();
   // alert(  this  );
//});


//$("#grid-content li").

//	
//$("#grid-content").vgrid({
//  easeing: "",
//  time: 400,
//  delay: 20,
//  fadeIn:{
//    time: 500,
//    delay: 50
//  }
//});
//	

	$('ul#photoList a').click(function() {
		$('img#largeImage').attr("src", $(this).attr("href"));
		return false;
	});

	var current = $('body').attr('class');
	var postfix = '_o';
	$('a.hover img, input.hover').not('[src*="' + postfix + '."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + '.png';
		if (current.indexOf(img.parent().parent().attr('class')) != -1 && img.parent().parent().attr('class') != "") {
			img.attr('src', src_on);
		}
		img.hover( function() {
			img.attr('src', src_on);
		}, function() {
			if (current.indexOf(img.parent().parent().attr('class')) == -1 || img.parent().parent().attr('class') == "") {
				img.attr('src', src);
			}
		} );
	});

	//$("div#content a img").
	
	$("div#gfBanner a img").hover(
		function() { $(this).stop(); $(this).animate({ opacity:0.65 }, 150); },
		function() { $(this).stop(); $(this).animate({ opacity:1 }, 250);}
	);
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<div id='tooltip'>"+ this.t +"</div>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			


		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? this.t : "";
		$("body").append("<div id='preview'><img src='"+ this.href +"' alt='image preview' /><p>"+ c +"</p></div>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			


// フォーカスで消える文字

		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? this.t : "";
		$("body").append("<div id='screenshot'><img src='"+ this.rel +"' alt='url preview' /><p>"+ c +"</p></div>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			


	$("a.screenshot-footer").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? this.t : "";
		$("body").append("<div id='screenshot'><img src='"+ this.rel +"' alt='url preview' /><p>"+ c +"</p></div>");								 
		$("#screenshot")
			.css("top",(e.pageY - 200) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot-footer").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - 200) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			

	
	
	
/*
	tooltip();
	imagePreview();
	screenshotPreview();
*/

		$("#info .customize h3").addClass("test");
		$("#info .customize h3").next().hide();
		$("#info .customize h3").click(function(){
			$(this).next(".editor").slideToggle(200, function() {
				if ($(this).is(':hidden')) {
					$(this).parent().removeClass("over");
				} else { 
					$(this).parent().addClass("over");
				}
			});
		});

		$("#detailMore > ul > li > a").addClass("test");
		$("#detailMore > ul").next().hide();
		$("#detailMore > ul > li > a").click(function(){
			$(this).prev('div').slideToggle(200, function() {
				if ($(this).is(':hidden')) {
					$(this).parent().removeClass("over");
				} else { 
					$(this).parent().addClass("over");
				}
			});
		});



//		$(".faqList span").addClass("test");
		$(".faqList span").each(function(){
			if (location.href.indexOf("#" + $(this).attr("id")) == -1) {
				$(this).next("div").hide();
			}
		});
		$(".faqList span").click(function(){
			$(this).next("div").slideToggle(200, function() {
				if ($(this).is(':hidden')) {
					$(this).parent().removeClass("over");
				} else { 
					$(this).parent().addClass("over");
				}
			});
		});
		
		$(".infoAreaList span").each(function(){
			if (location.href.indexOf("#" + $(this).attr("id")) == -1) {
				$(this).next("div").hide();
			}
		});
		$(".infoAreaList span").click(function(){
			$(this).next("div").slideToggle(200, function() {
				if ($(this).is(':hidden')) {
					$(this).parent().removeClass("over");
				} else { 
					$(this).parent().addClass("over");
				}
			});
		});

		var originalTopMain = $("div#topMain img").attr("src");
		$("div#topCollection li a").each(function(){
			jQuery('<img />').attr('src', $(this).attr("rel"));
		});
		$("div#topCollection li a").hover(
			function(){
				$("div#topMain img").attr("src", $(this).attr("rel"));
			},
			function(){
				$("div#topMain img").attr("src", originalTopMain);
			}
		);

	});

	$(document).resize(function(){
	});
		
})(jQuery.noConflict());





function runAfterLoad() {
	var popupArray = new Array();
	function setPopup(theElement) {
		var theID = popupArray.length;
		for (var i = 0; i < theElement.getElementsByTagName("div").length; i++) {
			if (theElement.getElementsByTagName("div")[i].className == "descriptionBox") {
				popupArray[theID] = {"div": theElement.getElementsByTagName("div")[i], "opend": false};
			}
		}
		for (var i = 0; i < theElement.getElementsByTagName("a").length; i++) {
			if (theElement.getElementsByTagName("a")[i].className == "openButton") {
				theElement.getElementsByTagName("a")[i].onclick = function() {
					if (popupArray[theID]["opend"]) {
						popupArray[theID]["div"].style.visibility = "hidden";
						popupArray[theID]["opend"] = false;
					} else {
						for (var j = 0; j < popupArray.length; j++) {
							if (j == theID) {
								popupArray[j]["div"].style.visibility = "visible";
								popupArray[j]["opend"] = true;
							} else {
								popupArray[j]["div"].style.visibility = "hidden";
								popupArray[j]["opend"] = false;
							}
						}
					}
				}
			} else if (theElement.getElementsByTagName("a")[i].className == "closeButton") {
				theElement.getElementsByTagName("a")[i].onclick = function() {
					popupArray[theID]["div"].style.visibility = "hidden";
					popupArray[theID]["opend"] = false;
				}
			}
		}
	}
	for (var i = 0; i < document.getElementsByTagName("dl").length; i++) {
		if (document.getElementsByTagName("dl")[i].className == "boxContainer") {
			setPopup(document.getElementsByTagName("dl")[i]);
		}
	}
/*
	for (var i = 0; i < document.getElementById("form1").getElementsByTagName("dl").length; i++) {
		if (document.getElementById("form1").getElementsByTagName("dl")[i].className == "boxContainer") {
			setPopup(document.getElementById("form1").getElementsByTagName("dl")[i]);
		}
	}
*/
}
