﻿/**
 *  import.js
 *  @version 1.2
 */

if (document.getElementById || document.getElementsByTagName || (document.createElement || document.createElementNS)) {
	var Includer = new Includer();
	Includer.levelCheck("carrozzeria");
	Includer.include("/carrozzeria/js/swfobject_2_1.js","Shift_JIS");
	Includer.include("/carrozzeria/js/replyer.js","UTF-8");
	Includer.include("/carrozzeria/js/display.js","UTF-8");
	Includer.include("/carrozzeria/js/common.js","Shift_JIS");
} else {
	//return;
}

function Includer() {
	
	this.adjLevel = new String();
	
	this.levelCheck = function (pathStr){
		var myRoot = pathStr;
		var myPath = location.pathname;	//get document path
		var myURL = document.URL;
		var pathToRoot ="";
		var myPlace = myURL.match(/(http|https):\/\/.+/);

		if(myPlace == null)
		{
			// offline
			
			if (navigator.userAgent.indexOf("MSIE")>=0 && navigator.userAgent.indexOf('Win'))
			{
				//win ie
				myArray = myPath.split("\\");
			}
			else
			{
				myArray = myPath.split("/");
			}
		
			for( i=0; i<100; i++)
			{
				u = myArray.length - 1 - i;
				myData = myArray[u].match(/carrozzeria/);
				if(myData)
				{
					myLevel = i + 1 ;
					break;
				}
			}
			
			var pathToRoot = "";
			for(i=1;i<myLevel;i++)
			{
				pathToRoot += "../";
			}
			
			this.adjLevel = pathToRoot;
		}
		else
		{
			// online
			var lc = myURL.match(/www3.pioneer.co.jp/);
			if(lc == null)
			{
				this.adjLevel = "";
			}
			else
			{
				// www3.pioneer.co.jp
				this.adjLevel = "http://pioneer.jp/";
			}
		}
	};
	
	this.includeList = [];
	
	this.include = function(file,charsets) {
		var included = false;
		
		for (var i = 0; i < this.includeList.length; i++)
		{
			if (this.includeList[i] == file)
			{
				included = true;
				break;
			}
		}
		
		if (!included)
		{
			document.write('<script type="text/javascript" charset="' + charsets + '" src="'+ this.adjLevel + file + '"></script>');
			this.includeList[this.includeList.length] = file;
		}
	};
}
