var ajx,fsubt=false,cun,rit;
function $(i){return typeof i=='object'?i:document.getElementById(i)}
function att(){
	var ret=null;
	try{ret=new XMLHttpRequest();}catch(e){
		try{ret=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){ret=new ActiveXObject("Microsoft.XMLHTTP");}
	}
	return ret;
}
function ajl(req,el,rif){
	rit=rif||false;
	el=dgi(el);
	el.innerHTML='<img src="load.gif" /><br />Loading...';
	ajx=att();
	ajx.onreadystatechange=function(){
		if(ajx.readyState==4){
			el.innerHTML=ajx.responseText;
			if(rit)ajl('menu','menu');
			rit=false;
			if(el!='menu')NFInit();
		}
	}
	req='go='+req;
	ajx.open("POST",'?s='+Math.random(),true);
	ajx.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajx.setRequestHeader("Content-length",req.length);
	ajx.setRequestHeader("Connection","close");
	ajx.send(req);
	return false;
}
var lastHash = '';
function pollHash(){
    if(lastHash!==location.hash){
        lastHash=location.hash;
		var val=(window.location.hash||'#').substr(1);
		if(val){$('dii').value=val;sufo('ashform');}
		else{$('results').innerHTML=$('none').innerHTML;}
    }
}
setInterval(pollHash, 100);
function ss(){document.location='#'+$('dii').value;return false}
function sufo(ff){
	fsubt=true;
	$('fsub').onload=(function(){
		if(!fsubt)return;
		var ii=$('fsub'),v;
		if(ii.contentDocument)
			v=ii.contentDocument;
		else if(ii.contentWindow)
			v=ii.contentWindow.document;
		else
			v=window.frames['fsub'].document;
		$('results').innerHTML=v.body.innerHTML;
		fsubt=false;
		ii.src='about:blank';
	});
	$('results').innerHTML='<div align="center"><img src="load.gif" alt="loading" style="vertical-align:middle" /><b> Loading...</b></div>';
	$(ff).submit();
}
var imagesPath="img/",
NF=new Array(),
isIE=false,
resizeTest=1;
function NFInit() {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
	if(!document.getElementById) {return false;}
	NFDo('start');
}
function NFDo(what) {
	var niceforms = document.getElementsByTagName('form');
	var identifier = new RegExp('(^| )ashiyane( |$)');
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
		var ieversion=new Number(RegExp.$1);
		if(ieversion < 7) {return false;}
		isIE = true;
	}
	for(var q=0;q<niceforms.length;q++){if(identifier.test(niceforms[q].className)){
		if(what=="start"){
			NF[q]=new niceform(niceforms[q]);
			niceforms[q].start();
		}else{
			niceforms[q].unload();
			NF[q]="";
		}
	}}
}
function NFFix(){
	NFDo('stop');
	NFDo('start');
}
function niceform(nf){
	nf._inputText=new Array();nf._inputSubmit=new Array();
	nf.add_inputText=function(obj){this._inputText[this._inputText.length]=obj;inputText(obj);}
	nf.add_inputSubmit=function(obj){this._inputSubmit[this._inputSubmit.length]=obj;inputSubmit(obj);}
	nf.start = function() {
		var allInputs = this.getElementsByTagName('input');
		for(var w = 0; w < allInputs.length; w++) {
			switch(allInputs[w].type) {
				case "text": case "password": {this.add_inputText(allInputs[w]); break;}
				case "submit": case "reset": case "button": {this.add_inputSubmit(allInputs[w]); break;}
			}
		}
		var allButtons = this.getElementsByTagName('button');
		for(var w = 0; w < allButtons.length; w++) {
			this.add_inputSubmit(allButtons[w]);
		}
		for(w = 0; w < this._inputText.length; w++) {this._inputText[w].init();}
		for(w = 0; w < this._inputSubmit.length; w++) {this._inputSubmit[w].init();}
	}
	nf.unload = function() {
		for(w = 0; w < this._inputText.length; w++) {this._inputText[w].unload();}
		for(w = 0; w < this._inputSubmit.length; w++) {this._inputSubmit[w].unload();}
	}
}
function inputText(el) {
	el.oldClassName = el.className;
	el.left = document.createElement('img');
	el.left.src = imagesPath + "0.png";
	el.left.className = "NFTextLeft";
	el.right = document.createElement('img');
	el.right.src = imagesPath + "0.png";
	el.right.className = "NFTextRight";
	el.dummy = document.createElement('div');
	el.dummy.className = "NFTextCenter";
	el.onfocus = function() {
		this.dummy.className = "NFTextCenter NFh";
		this.left.className = "NFTextLeft NFh";
		this.right.className = "NFTextRight NFh";
	}
	el.onblur = function() {
		this.dummy.className = "NFTextCenter";
		this.left.className = "NFTextLeft";
		this.right.className = "NFTextRight";
	}
	el.init = function() {
		this.parentNode.insertBefore(this.left, this);
		this.parentNode.insertBefore(this.right, this.nextSibling);
		this.dummy.appendChild(this);
		this.right.parentNode.insertBefore(this.dummy, this.right);
		this.className = "NFText";
	}
	el.unload = function() {
		this.parentNode.parentNode.appendChild(this);
		this.parentNode.removeChild(this.left);
		this.parentNode.removeChild(this.right);
		this.parentNode.removeChild(this.dummy);
		this.className = this.oldClassName;
	}
}
function inputSubmit(el) { //extend Buttons
	el.oldClassName = el.className;
	el.left = document.createElement('img');
	el.left.className = "NFButtonLeft";
	el.left.src = imagesPath + "0.png";
	el.right = document.createElement('img');
	el.right.src = imagesPath + "0.png";
	el.right.className = "NFButtonRight";
	el.onmouseover = function() {
		this.className = "NFButton NFh";
		this.left.className = "NFButtonLeft NFh";
		this.right.className = "NFButtonRight NFh";
	}
	el.onmouseout = function() {
		this.className = "NFButton";
		this.left.className = "NFButtonLeft";
		this.right.className = "NFButtonRight";
	}
	el.init = function() {
		this.parentNode.insertBefore(this.left, this);
		this.parentNode.insertBefore(this.right, this.nextSibling);
		this.className = "NFButton";
	}
	el.unload = function() {
		this.parentNode.removeChild(this.left);
		this.parentNode.removeChild(this.right);
		this.className = this.oldClassName;
	}
}
function option(el, no) {
	el.li = document.createElement('li');
	el.lnk = document.createElement('a');
	el.lnk.href = "javascript:;";
	el.lnk.ref = el.parentNode;
	el.lnk.pos = no;
	el.lnk._onclick = el.onclick || function () {};
	el.txt = document.createTextNode(el.text);
	el.lnk.appendChild(el.txt);
	el.li.appendChild(el.lnk);
}
function findPosY(obj) {
	var posTop = 0;
	do {posTop += obj.offsetTop;} while (obj = obj.offsetParent);
	return posTop;
}
function findPosX(obj) {
	var posLeft = 0;
	do {posLeft += obj.offsetLeft;} while (obj = obj.offsetParent);
	return posLeft;
}
function getInputsByName(name) {
	var inputs = document.getElementsByTagName("input");
	var w = 0; var results = new Array();
	for(var q = 0; q < inputs.length; q++) {if(inputs[q].name == name) {results[w] = inputs[q]; ++w;}}
	return results;
}
var existingResizeEvent = window.onresize || function() {};
window.onresize = function() {
	if(resizeTest!=document.documentElement.clientHeight) {
		existingResizeEvent();
		NFFix();
	}
	resizeTest = document.documentElement.clientHeight;
}


