function createHttpRequest(){

		//Win ie用
		if(window.ActiveXObject){
			try {
				//MSXML2以降用
				return new ActiveXObject("Msxml2.XMLHTTP") //[1]'
			} catch (e) {
				try {
					//旧MSXML用
					return new ActiveXObject("Microsoft.XMLHTTP") //[1]'
				} catch (e2) {
					return null
				}
			}
		} else if(window.XMLHttpRequest){
			//Win ie以外のXMLHttpRequestオブジェクト実装ブラウザ用
			return new XMLHttpRequest() //[1]'
		} else {
			return null
		}
	}

	function otherColorOn (ename, posiname, id, did, cid, px, type){
		$("p").fadeOut("slow").remove();

		var xmlHttp;

		//XMLHttpRequestオブジェクト生成
	    xmlHttp = createHttpRequest()
	    xmlHttp.onreadystatechange = checkStatus;
		xmlHttp.open("GET", "./ajax/otherColors.php?did="+did+"&cid="+cid+"&px="+px, true);

		xmlHttp.send(null);

		function checkStatus(){
			if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
				inner = xmlHttp.responseText;

				imgLeft = getPosition(posiname+id, 1);
				imgTop = getPosition(posiname+id, 2);
				if (type==1) {
					var top = imgTop+115;
			        var left = imgLeft+115;

			        $('span.'+ename+id).append( '<p id="vtip" ><img id="vtipArrow" />' + inner + '</p>' );
			        $('p#vtip #vtipArrow').attr("src", '/images/common/vtip_arrow2.png');
			        $('p#vtip').css({"top":top+"px"}).css({"left":left+"px"}).fadeIn("slow");
				} else if (type==2) {
					var top = imgTop+81;
			        var left = imgLeft+75;

			        $('span.'+ename+id).append( '<p id="vtip" ><img id="vtipArrow" />' + inner + '</p>' );
			        $('p#vtip #vtipArrow').attr("src", '/images/common/vtip_arrow2.png');
			        $('p#vtip').css({"top":top+"px"}).css({"left":left+"px"}).fadeIn("slow");
				} else if (type==3) {

					cnt = pictCht();

					var top = imgTop+81;
			        var left = imgLeft+75-cnt*65-110;

			        var allowTop = -17;
			        var allowLeft = cnt*65+13;

			        $('span.'+ename+id).append( '<p id="vtip" ><img id="vtipArrow3" />' + inner + '</p>' );
			        $('p#vtip #vtipArrow3').attr("src", '/images/common/vtip_arrow3.png');
			        $('p#vtip').css({"top":top+"px"}).css({"left":left+"px"}).fadeIn("slow");
			        $('p#vtip #vtipArrow3').css({"top":allowTop+"px"}).css({"left":allowLeft+"px"});
				}
			}
		}
	}

	function otherColorOff (){
		$("p").fadeOut("slow").remove();
	}

	/*IMGタグの数を数える*/
	function pictCht() {
		flg = false;
		cnt = 0;
		editInner = inner;
		while(flg==false) {
			len = editInner.length;
			charPosi = editInner.indexOf("<img");
			if (charPosi == -1) {
				flg = true;
			} else {
				editInner = editInner.slice(charPosi+4, len);
				cnt++;
			}
		}
		return cnt;
	}

	function getPosition(target, type)
	{
		var el = document.getElementById(target);

		if (type==1) {
		    var x = 0;

		    do{
		        x += el.offsetLeft;
		    }
		    while(el = el.offsetParent);
		    return  x;
		} else if (type==2) {
			var y = 0;

		    do{
		        y += el.offsetTop;
		    }
		    while(el = el.offsetParent);
		    return  y;
		} else if (type==3) {
			var z = 0;

		    do{
		        z += el.offsetWidth;
		    }
		    while(el = el.offsetParent);
		    return  z;
		}

	}
