function d2d_11D1_TrimLeft(sURL) {
	var i = 0;
	for(; i < sURL.length; ++i) {
		var aC = sURL.charAt(i);
		if(aC == " " || aC == "\t" || aC == "\r" || aC == "\n")	{
			continue;
		}
		break;
	}
	return sURL.substring(i, sURL.length);
}

function d2d_11D1_TrimRight(sURL) {
	var i = sURL.length - 1;
	for(; i >= 0; --i) {
		var aC = sURL.charAt(i);
		if(aC == " " || aC == "\t" || aC == "\r" || aC == "\n")	{
			continue;
		}
		break;
	}
	return sURL.substring(0, i + 1);
}

function d2d_11D1_Trim(sURL) {
	return d2d_11D1_TrimRight(d2d_11D1_TrimLeft(sURL));
}

function d2d_11D1_getVer() {
	var sV = navigator.appVersion;
	var idx1 = sV.indexOf("MSIE");
	if(idx1 < 0)
		return "";
	
	idx1 += "MSIE".length;
	var idx2 = sV.indexOf(";", idx1);
	if(idx2 < 0)
		return "";
		
	return d2d_11D1_Trim(sV.substring(idx1, idx2));
}

var d2d_IE_ver = d2d_11D1_getVer().split('.');
if(d2d_IE_ver.length < 2)
	d2d_IE_ver = null;

function d2d_11D1_CheckFilter(shost) {
	if(d2d_sHostFilter.length == 0) return true;
	return shost.indexOf(d2d_sHostFilter) >= 0;
}

function isScript(sURL) {
	var s;
	s = "location=";
	if(sURL.substring(0, s.length) == s)
		return true;
	
	s = "window.location=";
	if(sURL.substring(0, s.length) == s)
		return true;
	
	s = "location.href=";
	if(sURL.substring(0, s.length) == s)
		return true;

	s = "window.location.href=";
	if(sURL.substring(0, s.length) == s)
		return true;
	return false;
}

function d2d_11D1_82DB_00C04FB1625D_ReDir(sURL, bJS) {
	if(!d2d_bMultiHost)	return sURL;

	if(sURL == null) return sURL;

	sURL = new String(sURL);
	if(isScript(sURL)) return sURL;

	var cTest = sURL.substring(0, 1);
	
	if(cTest == "'" || 
	   cTest == "\"" || 
	   cTest == ">") {
		return sURL;
	}
	
	if(sURL.substring(0,2) == "//")
	{
		if(d2d_isSSL)
		{
			sURL = "https:" + sURL;
		}
		else
		{
			sURL = "http:" + sURL;
		}
	}

	if(sURL.substring(0, 1) == "#")
	{
		if(location.hash == "")
			return location.href + sURL;
		else
			return location.href.substring(0, location.href.length - location.hash.length) + sURL;
	}

	var bJS1 = false;
	if(arguments.length >= 2) bJS1 = bJS;	

	if(d2d_newHost != "")
	{
		var sTest = "../" + d2d_newHost; 
		if(sURL.substring(0, sTest.length) == sTest)
			return sURL;
	}

	if(d2d_newHost1 != "")
	{
		var sTest = "../" + d2d_newHost1; 
		if(sURL.substring(0, sTest.length) == sTest)
			return sURL;
	}

	var snewHost = d2d_newHost;

	//var butf8 = document.charset.toLowerCase() == "utf-8";
	var butf8 = false;
	if(document.charset)
	{
 	butf8 = document.charset.toLowerCase() == "utf-8";
	}
	var preFix;
	if(bJS1) { 
		if(butf8) {
			if(d2d_isSSL)
				preFix = "/utf8jshttps%3A%2F%2F";
			else
				preFix = "/utf8jshttp%3A%2F%2F";
		}
		else {
			if(d2d_isSSL) {
				if (d2d_fixJS)
					preFix = "/fixjshttps%3A%2F%2F";
				else
					preFix = "/jshttps%3A%2F%2F";
			}
			else {
				if (d2d_fixJS)
					preFix = "/fixjshttp%3A%2F%2F";
				else
					preFix = "/jshttp%3A%2F%2F";
			}
		}
	}
	else {
		if(d2d_isSSL)
			preFix = "/https%3A%2F%2F";
		else
			preFix = "/http%3A%2F%2F";
	}
	 
	sURL = d2d_11D1_TrimLeft(sURL.toString());
	if(sURL.length == 0) return sURL;

	if("/http%3A%2F%2F" == sURL.substring(0, "/http%3A%2F%2F".length)) return sURL;
	if("/jshttp%3A%2F%2F" == sURL.substring(0, "/jshttp%3A%2F%2F".length)) return sURL;
	if("/fixjshttp%3A%2F%2F" == sURL.substring(0, "/fixjshttp%3A%2F%2F".length)) return sURL;

	if("/https%3A%2F%2F" == sURL.substring(0, "/https%3A%2F%2F".length)) return sURL;
	if("/jshttps%3A%2F%2F" == sURL.substring(0, "/jshttps%3A%2F%2F".length)) return sURL;
	if("/fixjshttps%3A%2F%2F" == sURL.substring(0, "/fixjshttps%3A%2F%2F".length)) return sURL;

	if("/utf8jshttp%3A%2F%2F" == sURL.substring(0, "/utf8jshttp%3A%2F%2F".length)) return sURL;
	if("/utf8jshttps%3A%2F%2F" == sURL.substring(0, "/utf8jshttps%3A%2F%2F".length)) return sURL;


	var sURL1 = sURL.toLowerCase();
	var shttp = "http://", shost, indx1, indx2; 
	var sOldH = d2d_oldHost;
	
	if(sURL1.charAt(0) == "/") 	{
		if(!d2d_11D1_CheckFilter(sOldH)) 
			return sURL;

		if(d2d_isSSL) {
			if (d2d_baseHost != "") {
				return d2d_newHost1 + preFix + d2d_baseHost + sURL;
			}
			else
			{
				return d2d_newHost1 + preFix + sOldH + sURL;
			}
		}
		else {
			if (d2d_baseHost != "") {
				return d2d_newHost + preFix + d2d_baseHost + sURL;
			}
			else
			{
				return d2d_newHost + preFix + sOldH + sURL;
			}
		}
	}
	else if(sURL1.substring(0, "http:".length) == "http:") {
		if(d2d_newHost == "") return sURL;
		shttp = "http://";
		indx1 = shttp.length;
		shost = sURL1.substring(shttp.length, sURL1.length);
		indx2 = shost.indexOf("/");
		if(indx2 > 0)
			shost = shost.substring(0, indx2);

		if((shttp + shost).toLowerCase() == d2d_newHost.toLowerCase())
			return sURL;
		else if(!d2d_11D1_CheckFilter(shost)) 
			return sURL;
		else
			return d2d_newHost + preFix + sURL.substring(shttp.length, sURL.length);

	}
	else if(sURL1.substring(0, "https:".length) == "https:") {
		if(d2d_newHost1 == "") return sURL;
		shttp = "https://";
		indx1 = shttp.length;
		shost = sURL1.substring(shttp.length, sURL1.length);
		indx2 = shost.indexOf("/");
		if(indx2 > 0)
			shost = shost.substring(0, indx2);

		if((shttp + shost).toLowerCase() == d2d_newHost1.toLowerCase())
			return sURL;
		else if(!d2d_11D1_CheckFilter(shost)) 
			return sURL;
		else
			return d2d_newHost1 + preFix + sURL.substring(shttp.length, sURL.length);
	}
	else if(sURL1.substring(0, "javascript:".length) == "javascript:")
		return sURL;
	else if(sURL1.substring(0, "mailto:".length) == "mailto:")
		return sURL;
	else if(sURL1.substring(0, "mms:".length) == "mms:")
		return sURL;
	else if(sURL1.substring(0, "telnet:".length) == "telnet:")
		return sURL;
	else if(sURL1.substring(0, "ftp:".length) == "ftp:")
		return sURL;
	else if(sURL1.substring(0, "wais:".length) == "wais:")
		return sURL;
	else if(sURL1.substring(0, "gopher:".length) == "gopher:")
		return sURL;
	else if(!d2d_11D1_CheckFilter(sOldH))
		return sURL;
	else if (sURL1.substring(0, "location=".length) == "location=") {
		var newURL;
		if(d2d_isSSL)
			newURL = d2d_newHost1;
		else
			newURL = d2d_newHost;
			
		var currentPath = window.location.pathname;
		var intIndex = currentPath.lastIndexOf("/");
		currentPath = currentPath.substring(0, indxf);
			
		var strLocation = sURL.substring(0, "location=".length);
		var strQuote = sURL.substring(sURL.length - 1, sURL.length);
		var str = sURL.substring("location=".length + strQuote.length, sURL.length - 1);
		if (str.substring(0, 1) == '/')
			return strLocation + strQuote + newURL + preFix + sOldH + str + strQuote;
		else {
			while(str.substring(0, '../'.length) == '../')	{
				str = str.substring('../'.length, sURL.length);
				intIndex = currentPath.lastIndexOf("/");
				currentPath = currentPath.substring(0, indxf);
			}
			return strLocation + strQuote + newURL + currentPath + '/' + str + strQuote;
		}
	}
	else
	{
		//relative path
		var newURL;
		if(d2d_isSSL)
		{
			newURL = d2d_newHost1;
		}
		else
		{
			newURL = d2d_newHost;
		}

		
		var spath = window.location.pathname;
		var indxf = spath.lastIndexOf("/");
		if(indxf < 0) 
			return newURL + preFix + sOldH + '/' + sURL;
		else {			
			spath = spath.substring(0, indxf);
			while(sURL.substring(0, '../'.length) == '../')	{
				sURL = sURL.substring('../'.length, sURL.length);
				if(spath == '/') {
					continue;
				}
				indxf = spath.lastIndexOf("/");
				spath = spath.substring(0, indxf);
			}
				
			spath = spath + '/' + sURL;
			
			indxf = spath.indexOf(sOldH + "/");
			if(indxf >= 0) {
				spath = preFix + sOldH + "/" + spath.substring(indxf + (sOldH + "/").length)
			}

			if(spath.substring(0, preFix.length) != preFix)
			{
				return newURL + preFix + sOldH + spath;
			}
			else
				return newURL + spath;
		}			
	}

	return d2d_newHost + preFix + sURL.substring(shttp.length, sURL.length);
}

function d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(sin, spara) {
	var sin1 = sin.toString().toLowerCase();
	var scase = "";
	var spara1 = spara + "\"";
	var spara2 = spara + "\'";

	var indx1 = sin1.indexOf(spara1);
	if(indx1 < 0) {
		indx1 = sin1.indexOf(spara2);
		if(indx1 < 0) {
			indx1 = sin1.indexOf(spara);
			if(indx1 < 0)
				scase = "";
			else {
				if(sin1.charAt(indx1 - 1) == ' ' || 
				   sin1.charAt(indx1 - 1) == '\n' ||
				   sin1.charAt(indx1 - 1) == '\t')
					scase = spara;
				else
					return sin;	
			}
		}
		else {
			if(sin1.charAt(indx1 - 1) == ' ' || 
			   sin1.charAt(indx1 - 1) == '\n' ||
			   sin1.charAt(indx1 - 1) == '\t')
				scase = spara2;
			else
				return sin;			
		}
	}
	else {
		if(sin1.charAt(indx1 - 1) == ' ' || 
		   sin1.charAt(indx1 - 1) == '\n' ||
		   sin1.charAt(indx1 - 1) == '\t')
			scase = spara1;
		else
			return sin;
	}

	if(scase == "")
		return sin;

	var s1 = sin.substring(0, indx1 + scase.length);
	var spreF = "/http%3A%2F%2F";
	var bJS = false;

	if(spara == "src=") {
		var idx = s1.length-1; 
		for(;idx >= 0; --idx) {
			if(s1.charAt(idx) == '<') {
				if(s1.substring(idx, idx + "<script".length).toLowerCase() == "<script") {
					bJS = true;
					break;
				}
			}
		}
	}

	var s2 = sin.substring(indx1 + scase.length, sin1.length);
	s2 = d2d_11D1_82DB_00C04FB1625D_ReDir(s2, bJS);
	return s1 + s2;
}

function d2d_11D1_82DB_00C04FB1625D_document_write(sin) {		
	if(!d2d_bMultiHost)	
		return sin;	
	else if(sin == null) 
		return sin;	

	var vTags = sin.split('<');	
	var idx = 1, sinout = "";

	var sin1; 
	
	if(d2d_11D1_TrimRight(vTags[0]) != '') 
	{
		sin1 = d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(vTags[0], "href=");		
		sin1 = d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(sin1, "action=");
		sinout += d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(sin1, "src=");		
	}

	for(;idx < vTags.length; ++idx) {
		if(d2d_11D1_TrimRight(vTags[idx]) == '') 
			continue;
		vTags[idx] = '<' + vTags[idx];
		sin1 = d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(vTags[idx], "href=");		
		sin1 = d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(sin1, "action=");
		sinout += d2d_11D1_82DB_00C04FB1625D_document_write_doRedir(sin1, "src=");		
	}
	return sinout;
}

function d2d_11D1_82DB_00C04FB1625D_eval_statements(sin) {
	var	sin1 = sin.toString();
	var sR = "", indx;
	if(sin1.substring(0, "window.".length) == "window.")
	{
		sR += sin1.substring(0, "window.".length);
		sin1 = sin1.substring("window.".length, sin1.length);
	}
	else if(sin1.substring(0, "parent.".length) == "parent.")
	{
		sR += sin1.substring(0, "parent.".length);
		sin1 = sin1.substring("parent.".length, sin1.length);
	}
	else if(sin1.substring(0, "top.".length) == "top.")
	{
		sR += sin1.substring(0, "top.".length);
		sin1 = sin1.substring("top.".length, sin1.length);
	}

	sin1 = d2d_11D1_TrimLeft(sin1);

	if(sin1.substring(0, "location".length) == "location")
	{
		indx = sin1.indexOf("=", "location".length); 
		if(indx < 0)
			return sin;

		var sT = d2d_11D1_Trim(sin1.substring("location".length, indx));
		if(sT != "" && sT != ".href")
			return sin;

		sR += sin1.substring(0, indx + 1);
		sin1 = sin1.substring(indx + 1, sin1.length);
		sR += "d2d_11D1_82DB_00C04FB1625D_ReDir(" + sin1 + ");"
		return sR;
	}
	else if(sin1.substring(0, "open".length) == "open")
	{
		indx = sin1.indexOf("(", "open".length); 
		if(indx < 0)
			return sin;

		var sT = d2d_11D1_Trim(sin1.substring("open".length, indx));
		if(sT != "")
			return sin;

		sR += sin1.substring(0, indx + 1);
		sin1 = sin1.substring(indx + 1, sin1.length);

		sR += "d2d_11D1_82DB_00C04FB1625D_ReDir(";

		indx = sin1.indexOf(","); 
		if(indx < 0)
			indx = sin1.indexOf(")"); 

		sR += sin1.substring(0, indx);
		sin1 = sin1.substring(indx, sin1.length);
		sR += ")" + sin1;
		return sR; 
	}
	else
	{
		indx = sin1.indexOf(".src=");
		if(indx >= 0)
		{
			sR += sin1.substring(0, indx + ".src=".length);
			sin1 = sin1.substring(indx + ".src=".length, sin1.length);	
			sR += "d2d_11D1_82DB_00C04FB1625D_ReDir(" + sin1 + ");"
			return sR;
		}

		indx = sin1.indexOf(".href=");
		if(indx >= 0)
		{
			sR += sin1.substring(0, indx + ".href=".length);
			sin1 = sin1.substring(indx + ".href=".length, sin1.length);	
			sR += "d2d_11D1_82DB_00C04FB1625D_ReDir(" + sin1 + ");"
			return sR;			
		}

		indx = sin1.indexOf(".action=");
		if(indx >= 0)
		{
			sR += sin1.substring(0, indx + ".action=".length);
			sin1 = sin1.substring(indx + ".action=".length, sin1.length);	
			sR += "d2d_11D1_82DB_00C04FB1625D_ReDir(" + sin1 + ");"
			return sR;			
		}
	}
	return sin;
}

function d2d_11D1_keyword_replace(sin, sf, sr) {
	var sout = "", stmp = "";
	var nIndx = 0, nF = 0;
	nF = sin.indexOf(sf, nIndx);
	while(nF >= 0) {
		stmp = sin.charAt(nF - 1).toLowerCase();
		if((stmp >= 'a' && stmp <= 'z') || stmp == "_")	{
			sout += sin.substring(nIndx, nF + sf.length);
			nIndx = nF + sf.length;
			nF = sin.indexOf(sf, nIndx);			
			continue;
		}

		stmp = sin.charAt(nF + sf.length).toLowerCase();
		if((stmp >= 'a' && stmp <= 'z') || stmp == "_")	{
			sout += sin.substring(nIndx, nF + sf.length);
			nIndx = nF + sf.length;
			nF = sin.indexOf(sf, nIndx);
			continue;
		}

		sout += sin.substring(nIndx, nF) + sr;
		nIndx = nF + sf.length;
		nF = sin.indexOf(sf, nIndx);
	}
	sout += sin.substring(nIndx, sin.length);
	return sout;
}

function d2d_11D1_82DB_00C04FB1625D_eval(sin, this_name) {
	if(typeof(sin) != "string")
		return sin;
		
	var iSemicolon = sin.indexOf(";");
	var statements = sin.split(";");
	var sin1 = "";
	var i = 0;
	for(; i < statements.length; ++i) {
		sin1 += d2d_11D1_82DB_00C04FB1625D_eval_statements(d2d_11D1_Trim(statements[i]));
		if ((iSemicolon != -1) && (statements[i].length > 0))
			sin1 += ";";
	}
	return sin1;	
}

function d2d_11D1_82DB_eval(athis, sin) {
	eval("var d2d_athis = athis;");
	sin = d2d_11D1_82DB_00C04FB1625D_eval(sin, athis.name);
	eval(sin);
}

document.oldwrite = document.write;
function document_11D1_82DB_write(sin) {
	if (arguments.length > 1) {
		sin = new String(arguments[0]);
		for (i=1; i<arguments.length; i++) {
			sin += arguments[i];
		}
	}
	else {
		sin = new String(sin);
	}
	if(sin.length > 5) {
		sin = d2d_11D1_82DB_00C04FB1625D_document_write(sin);
	}
	document.oldwrite(sin);
}
document.write = document_11D1_82DB_write;

document.oldwriteln = document.writeln;
function document_11D1_82DB_writeln(sin) {
	sin = new String(sin); 
	if(sin.length > 5)
		sin = d2d_11D1_82DB_00C04FB1625D_document_write(sin);	 
	document.oldwriteln(sin);
}
document.writeln = document_11D1_82DB_writeln;
	  
if(d2d_IE_ver != null)
{
	if(parseInt(d2d_IE_ver[1]) >=5)
	{
		window.location.oldassign = window.location.assign;
		function location_11D1_82DB_assign(sin) {
			sin = d2d_11D1_82DB_00C04FB1625D_ReDir(sin);
			window.location.oldassign(sin);
		}
		window.location.assign = location_11D1_82DB_assign;

		window.location.oldreplace = window.location.replace;
		function location_11D1_82DB_replace(sin) {
			sin = d2d_11D1_82DB_00C04FB1625D_ReDir(sin);
			window.location.oldreplace(sin);
		}
		window.location.replace = location_11D1_82DB_replace;
	}
}

window.oldshowModalDialog = window.showModalDialog;
function window_11D1_82DB_showModalDialog(sURL, vArguments, sFeatures) {
	if(arguments.length >= 1)
		sURL = d2d_11D1_82DB_00C04FB1625D_ReDir(arguments[0]);

	switch(arguments.length) {
	case 0:
		return window.oldshowModalDialog();
	case 1:
		return window.oldshowModalDialog(sURL);
	case 2:
		return window.oldshowModalDialog(sURL, arguments[1]);
	case 3:
		return window.oldshowModalDialog(sURL, arguments[1], arguments[2]);
	}
}
window.showModalDialog = window_11D1_82DB_showModalDialog;

window.oldopen = window.open;
function window_11D1_82DB_open(sURL, sName, sFeatures, bReplace) {
	if(arguments.length >= 1)
		sURL = d2d_11D1_82DB_00C04FB1625D_ReDir(arguments[0]);
	switch(arguments.length) {
	case 0:
		return window.oldopen();
	case 1:
		return window.oldopen(sURL);
	case 2:
		return window.oldopen(sURL, arguments[1]);
	case 3:
		return window.oldopen(sURL, arguments[1], arguments[2]);
	case 4:
		return window.oldopen(sURL, arguments[1], arguments[2], arguments[3]);
	}
}

window.open = window_11D1_82DB_open;
function srcobj_11D1_82DB_onreadystatechange(aObj)
{
	if(aObj.readyState == "uninitialized" && aObj.name != "")
	{
		if(aObj.src.substring(0, d2d_newHost.length) == d2d_newHost)
		{
			var stest = d2d_newHost + "/http%3A%2F%2F";
			if(aObj.src.substring(0, stest.length) == stest)
				return;

			var url_11D1_82DB = aObj.src.substring(d2d_newHost.length, aObj.src.length);
			url_11D1_82DB = d2d_11D1_82DB_00C04FB1625D_ReDir(url_11D1_82DB);
			window.setTimeout("document['"+aObj.name+"'].src = '" + url_11D1_82DB + "'", 10);
			return;
		}
	}
}
