// encode: utf-8, no BOM

(function(){
	var getEicUrl= 'geteic/*.html';
	var curId= curId || 0,
			totalNum,
			targetElId= 'eicContent';
function processData(data){
	try{
	document.getElementById(targetElId).innerHTML= data;
	}catch(ex){log(ex)}
}
function getNextEic(targetId){
	totalNum= totalNum || totalEicNum || 0;
	if(totalNum == 0){return false}
	curId+= 1;
	(curId >= totalNum) && (curId= 0);
	$.get(getEicUrl.replace(/\*/, curId), processData);
	return false;
}
function getPrevEic(targetId){
	totalNum= totalNum || totalEicNum || 0;
	if(totalNum == 0){return false}
	curId-= 1;
	(curId < 0) && (curId= (totalNum- 1));
	$.get(getEicUrl.replace(/\*/, curId), processData);
	return false;
}
window.getNextEic= getNextEic;
window.getPrevEic= getPrevEic;

})();

$(function(){
	var el= document.getElementById('qcDropMenu');
	if(!el){
		return
	}
	var links= el.getElementsByTagName('b'),
			link,
			curMenu;
	var menus= [];
	for(var i=0;i<links.length;i++){
		link= links[i];
		if(link.className != 'ttl'){
			continue
		}
		link.onmouseover= linkOver;
		link.parentNode.onmouseout= function(ev){
			ev= ev || window.event;
			var ref= ev.relatedTarget || ev.toElement || null;
			if(isP(this, ref)){
				return;
			}
			menuOut(this);
		};
	}
	function linkOver(){
		if(curMenu){
			curMenu.style.display= 'none';
		}
		curMenu= this.parentNode.getElementsByTagName('ul')[0];
		if(curMenu){
			curMenu.style.display= '';
		}
	}
	function menuOut(el){
		if(curMenu){
			curMenu.style.display= 'none';
			curMenu= undefined;
		}
		el.getElementsByTagName('ul')[0].style.display= 'none';
	}
	function isP(elmP, elm){
		var p= elm;
		while(p){
			if(p=== elmP){
				return true
			}
			p= p.parentNode
		}
		return false
	}
});

function switchContent(el){
    var elD = el.parentNode;
    
    while(elD = elD.nextSibling){
        if(elD.nodeType == 1){
            break;
        }
    }
    var toClose = elD.style.display != "none";
    jQuery(el).parent().parent().parent().find("div.content").each(function(_i, _e){
            _e.style.display = "none";
        });
    
    if(toClose){
        elD.style.display = "none"
    }else{
        elD.style.display = ""
    }
    return false;
}

(function(){
	var pageCovered = false,
			pageCoverId = 'pageCover',
			alertWinId = 'alertWin',
			lastForm;
	function CT(tag){return document.createElement(tag);}
	function gId(id){return document.getElementById(id);}
	window.coverPage = function(to){
		var pc = gId(pageCoverId);
		if(!pc){
			pc = CT('div');
			pc.id = pageCoverId;
			pc.style.display = 'none';
			document.body.appendChild(pc);
		}
		var h = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
		pc.style.height = h + 'px';
		if(arguments.length > 0){
			to = !!to
		}else{
			to = (pc.style.display == 'none') ? true : false;
		}
		pc.style.display = to ? '' : 'none';
	};
	function winSt(){return document.documentElement.scrollTop || document.body.scrollTop || 0}
	function dataLoad(data){
		gId(alertWinId).innerHTML = data;
		requireName();
	}
	window.requireName = function(f){
		try{
			coverPage(true);
			if(f){
				lastForm = f;
			}
			var alertWin = gId(alertWinId);
			if(!alertWin){
				alertWin = CT('div');
				alertWin.id = alertWinId;
				document.body.appendChild(alertWin);
				alertWin.style.display = 'none';
				$.get('/web/js/alert_win.html', dataLoad);
				return;
			}
			alertWin.style.display = '';
			alertWin.style.left = (Math.max(document.body.clientWidth, document.documentElement.clientWidth) - 400)/2 + 'px';
			alertWin.style.top = (winSt() + 200) + 'px';
		}catch(ex){console.log(ex)}
	};
	requireName.hide = function(){
		coverPage(false);
		try{
			gId(alertWinId).style.display = 'none';
		}catch(ex){}
	};
})();