﻿/* Socang.com JavaScript Framework */
/* Powered By Sammy Zhong of Socang.com */
/* Common Script */

window.onload = allStart;

function allStart(){
	
	var rollpicHrefId = 1;
	doRollpicnews();
	doRollwordnews();
	setTimeout(closeFlash,15000);
	doLinkFill();
}

function closeFlash(){
	document.getElementById("a-dLabel_0").style.display="none";
}

/* Preload Image of Style Sheet Start */
Image1= new Image(260,120);
Image1.src = "image/sample_subsiterecom_slideleft.jpg"; 

Image2 = new Image(260,120);
Image2.src = "image/sample_subsiterecom_slideright.jpg";

Image3 = new Image(120,5);
Image3.src = "image/sample_toslide_cite_on.jpg";
/* Preload Image of Style Sheet End */



/* Roll Pictrue News Start */
function setRollpicnews(){
	if (!$('rollpicLabel')){
		var rollpicLabel = document.createElement('div');
		rollpicLabel.id = 'rollpicLabel';
		var rollpicGuide = document.createElement('div');
		rollpicGuide.id = 'rollpicGuide';
		var rollpicTitle = document.createElement('span');
		rollpicTitle.id = 'rollpicTitle';
		rollpicGuide.style.position = 'absolute';
		rollpicGuide.style.zIndex = 10;
		$('rollpicNews').appendChild(rollpicLabel);
		$('rollpicLabel').appendChild(rollpicGuide);
		$('rollpicGuide').appendChild(rollpicTitle);

		for ( nroll=(arrayImage.length-1) ; nroll>=0 ; nroll-- ){
			rollpicCont = document.createElement('div');
			rollpicCont.id = 'rollpicCont_'+(nroll+1);
			rollpicCont.style.position = 'absolute';
			rollpicCont.style.zIndex = nroll+1;
			rollpicHref = document.createElement('input');
			rollpicHref.id = 'rollpicHref_'+(nroll+1);
			rollpicHref.type = 'button';
			rollpicHref.value = nroll+1;
			if (nroll==0){
				rollpicCont.className = 'rollpicCont_on';
				rollpicHref.className = 'rollpicHref_on';
				$('rollpicTitle').innerHTML = arrayImage[nroll][2];
			}else{
				rollpicCont.className = 'rollpicCont';
				rollpicHref.className = 'rollpicHref';
			}
			rollpicCont.innerHTML= '<a target=\"_blank\" href=\"'+arrayImage[nroll][1]+'"\"><img src=\"'+arrayImage[nroll][0]+'\"></a>';
			$('rollpicLabel').appendChild(rollpicCont);
			$('rollpicGuide').appendChild(rollpicHref);
			$('rollpicHref_'+(nroll+1)).onclick = function(){
				goRollpicnews(this.id, false);
			}
		}
		doAutoroll = setInterval( autoRoll, 5000 );
	}
}

function goRollpicnews(hrefId,ifAuto){
	clearInterval(doAutoroll);
	rollpicHrefId = Socang.getSubnum(hrefId,'rollpicHref');
	var theHrefs = $('rollpicGuide').getElementsByTagName('input');
	var theConts = $('rollpicLabel').getElementsByTagName('div');
	var theHrefsLen = theHrefs.length;

	doAlpha = setInterval ( alphaRollpicnews, 50 );

	for ( nhref=(theHrefsLen-1) ; nhref >= 0  ; nhref-- ){
		theHrefs[nhref].className = 'rollpicHref';
	} 
	
	if (!ifAuto){
		$(hrefId).blur();
	}
	$(hrefId).className = 'rollpicHref_on';
	$('rollpicTitle').innerHTML = arrayImage[rollpicHrefId-1][2];
}

function alphaRollpicnews(){
	var preCont = $('rollpicLabel').getElementsByClassName('rollpicCont_on')[0];
	var nextCont = $('rollpicCont_'+rollpicHrefId);
	
	nextCont.style.display = 'inline';
	var preOpacity = preCont.getStyle('opacity');
	var nextOpacity = nextCont.getStyle('opacity');

	if ( preOpacity<0.25 ){
		clearInterval(doAlpha);
		nextCont.className = 'rollpicCont_on';
		nextCont.setOpacity('1');
		nextCont.style.display = 'inline';
		preCont.className = 'rollpicCont';
		preCont.setOpacity('0.06');
		preCont.style.display = 'none';
		doAutoroll = setInterval ( autoRoll, 5000 );
	}else{
		preOpacity = preOpacity/2;
		nextOpacity = nextOpacity*2;
		preCont.setOpacity(preOpacity);
		nextCont.setOpacity(nextOpacity);
	}
}

function autoRoll(){
	var theCurRoll = $('rollpicLabel').getElementsByClassName('rollpicCont_on')[0];
	var theCurRollNum = Socang.getSubnum(theCurRoll.id,'rollpicCont');
	rollpicHrefId = ( theCurRollNum == arrayImage.length ? 1 : parseInt(theCurRollNum)+1 );
	goRollpicnews('rollpicHref_'+rollpicHrefId,true);
}

function doRollpicnews( setTime, setDirection )	{
	var theTime = ( setTime >0 ? setTime : 3 );
	/* About Direction: up/down/left/right */
	var theDirection = ( setDirection != '' ? setDirection : 'down' );

	setRollpicnews();
}
/* Roll Pictrue News End */



/* Slide Special Blocks Start */
/* Define Gobal Refers */
var theSlideDirection = new String();
var theSlidePosition = new String();
var theSlideName = new String();
var preSlideDirection = new String();
var preSlidePosition = new String();
var preSlideName = new String();
var isSlide = new String();
var conSlide = new String();

function toSlide(slideDirection, slidePosition, slideName){
	if ( conSlide == 'on' ){
		controlSlide('off');
	}

	if ( isSlide== 'on' ){
		if ( theSlideName == slideName ){
			return;
		}else{
			if ( theSlideDirection != slideDirection ){
				clearInterval (processSlide);
				processBackSlide = setInterval ( 'doBackSlide(\''+theSlideDirection+'\',\''+theSlidePosition+'\',\''+theSlideName+'\')', 10 );
			}
		}
	}

	if ( slideName == preSlideName && theSlideName != '' ){
		return;
	}else{
		theSlideDirection = slideDirection;
		theSlidePosition = slidePosition;
		theSlideName = slideName;
	}

	if ( preSlideName != '' && preSlideName != theSlideName ){
		preSlideSource = $('toSlide_'+preSlideName);
		preSlideCite = preSlideSource.getElementsByTagName('cite')[0];
		preSlideCite.className = '';
	}

	if ( preSlideDirection != '' && preSlideDirection != theSlideDirection ){
		processBackSlide = setInterval ( 'doBackSlide(\''+preSlideDirection+'\',\''+preSlidePosition+'\',\''+preSlideName+'\')', 10 );
	}

	theSlideSource = $('toSlide_'+slideName);
	theSlideCite = theSlideSource.getElementsByTagName('cite')[0];
	theSlideCite.className = 'cite_on';
	theSlideDiv = $('subsiteRecom'+slideDirection+'_Slide');
	theSlideDiv.className = 'subsiteRecom'+slideDirection+'_Slide_'+slidePosition;

	processSlide = setInterval ( 'doSlide(\''+slideDirection+'\',\''+slidePosition+'\',\''+slideName+'\')', 10 );
}

function doSlide(doSlideDirection,doSlidePosition,doSlideName){
	isSlide = 'on';
	$('subsiteRecom'+doSlideDirection+'_Slide').style.display = '';
	slideHeight = $('subsiteRecom'+doSlideDirection+'_Slide').style.height;
	if ( slideHeight=='' || !slideHeight ){
		slideHeight = '10px';
	}else{
		slideHeightNum = Socang.getPx(slideHeight);
		if ( slideHeightNum <= 100 ){
			slideHeightNum = slideHeightNum+10;
			slideHeight = slideHeightNum+'px';
		}else{
			$('subsiteRecom'+doSlideDirection+'_Slide').className = 'subsiteRecom'+doSlideDirection+'_Slide_'+doSlidePosition;
			$('subsiteRecom'+doSlideDirection+'_Slide').innerHTML = $('toFill_'+doSlideName).innerHTML;
			
			isSlide = 'off';

			preSlideDirection = doSlideDirection;
			preSlidePosition = doSlidePosition;
			preSlideName = doSlideName;

			clearInterval(processSlide);
			appendExtnews();
		}
	}
	$('subsiteRecom'+doSlideDirection+'_Slide').style.height = slideHeight;
}

function setBackSlide(){
	if (preSlideName != '' ){
		preSlideSource = $('toSlide_'+preSlideName);
		preSlideCite = preSlideSource.getElementsByTagName('cite')[0];
		preSlideCite.className = '';

		removeExtnews();

		$('subsiteRecom'+preSlideDirection+'_Slide').innerHTML = '';
		processBackSlide = setInterval ( 'doBackSlide(\''+preSlideDirection+'\',\''+preSlidePosition+'\',\''+preSlideName+'\')', 10 );
	}
}

function doBackSlide(backSlideDirection,backSlidePosition,backSlideName){
	backSlideDiv = $('subsiteRecom'+backSlideDirection+'_Slide');
	backSlideDiv.innerHTML = '';
	backSlideDiv.className = 'subsiteRecomOnSlide';
	backSlideHeight = backSlideDiv.style.height;
	backSlideHeightNum = Socang.getPx(backSlideHeight);
	if ( backSlideHeightNum >0 ){
		backSlideHeightNum = backSlideHeightNum-10;
		backSlideHeight = backSlideHeightNum+'px';
	}else{
		backSlideSource = $('toSlide_'+backSlideName);
		backSlideCite = backSlideSource.getElementsByTagName('cite')[0];
		backSlideCite.className = '';
		backSlideDiv.className = '';
		backSlideDiv.style.display = 'none';
		
		clearInterval(processBackSlide);
		
		theSlideName = '';
		theSlideDirection = '';
		theSlidePosition = '';
	}
	backSlideDiv.style.height = backSlideHeight;
}

function controlSlide(conTurn){
	if ( conTurn == 'on' ){
		conSlide = 'on';
		theConTurn = setTimeout ( setBackSlide, 5000 );
	}else{
		conSlide = 'off';
		if ( preSlideName!='' ){
			clearTimeout ( theConTurn );
		}
	}
}

function appendExtnews(){
	if (!$('extendNews')){
		theExtnews = document.createElement('div');
		theExtnews.id = 'extendNews';
		theExtnews.onmouseover= function(){
			controlSlide('off');
		}
		theExtnews.onmouseout = function(){
			controlSlide('on');
		}
		theExtnews.innerHTML = $('toExt_'+preSlideName).innerHTML;
		$('topicFrame').appendChild(theExtnews);
	}else{
		$('topicFrame').removeChild($('extendNews'));
		theExtnews = document.createElement('div');
		theExtnews.id = 'extendNews';
		theExtnews.onmouseover= function(){
			controlSlide('off');
		}
		theExtnews.onmouseout = function(){
			controlSlide('on');
		}
		theExtnews.innerHTML = $('toExt_'+preSlideName).innerHTML;
		$('topicFrame').appendChild(theExtnews);
	}
}

function removeExtnews(){
	if($('extendNews')){
		$('topicFrame').removeChild($('extendNews'));
	}
}
/* Slide Special Blocks End */



/* Roll News Start */
var theMarqueeNum = 0;

function doRollwordnews(){
	processRollWordNews = setInterval ( rollWordnews, 3000 )
}

function rollWordnews(){
	var theMarquee = $('theMarqueeFrame').getElementsByTagName('span')[0];
	var theRollnews = $('thePreMarqueeFrame').getElementsByTagName('span')[theMarqueeNum];
	theMarquee.innerHTML = theRollnews.innerHTML;
	theMarqueeNum++;
	if ( theMarqueeNum >= $('thePreMarqueeFrame').getElementsByTagName('span').length ){
		theMarqueeNum = 0;
	}
}

function stopRollwordnews(){
	clearInterval (processRollWordNews);
}
/* Roll News End */



/* Drop Search Type Start */
var dropTimer = null;
var dropSortsInner = new String();
var dropSortsText = new String();
function initDrop( toinitDropCtrl, toinitDropList, toinitTime ){
	var initDropCtrl = $(toinitDropCtrl);
	var initDropList = $(toinitDropList);
	
	if ( initDropCtrl && !initDropCtrl.initialized ) {
		initDropCtrl.initialized = true;
		initDropCtrl.unselectable = true;

		initDropCtrl.outfunc = typeof initDropCtrl.onmouseout == 'function' ? initDropCtrl.onmouseout : null;
		initDropCtrl.onmouseout = function() {
			if(this.outfunc) this.outfunc();
			dropTimer = setTimeout ('hideDrop(\''+toinitDropList +'\')', toinitTime );
		}

		initDropCtrl.overfunc = typeof initDropCtrl.onmouseover == 'function' ? initDropCtrl.onmouseover : null;
		initDropCtrl.onmouseover = function() {
			if(this.overfunc) this.overfunc();
			if(dropTimer) clearTimeout ( dropTimer );
		}
	}
	
	if ( initDropList && !initDropList.initialized ) {
		initDropList.initialized = true;
		initDropList.style.position = 'absolute';
		initDropList.onmouseover = function() {
			if(dropTimer) clearTimeout ( dropTimer );
		}
		initDropList.onmouseout = function() {
			dropTimer = setTimeout ('hideDrop(\''+toinitDropList +'\')', toinitTime );
		}
		initDropList.style.zIndex = 50;
	}
}

function hideDrop(hideDropList){
	if($(hideDropList)){
		$(hideDropList).style.display = 'none';
	}
}

function dropSearType(){
	var dropBtn_Name = 'tradeSearch_Btn_SearType';
	var dropBtn = $(dropBtn_Name);
	var dropInp_Name = 'tradeSearch_Inp_SearType';
	var dropInp = $(dropInp_Name);
	var dropList_Name = 'tradeSearch_List_SearType';
	var dropList = $(dropList_Name);
	var timeout = 5000;

	dropBtn.blur();

	if ( !dropList ){
		dropList = document.createElement('div');
		document.body.appendChild(dropList);
		dropList.id = dropList_Name;
	}
	
	hideDrop ( dropList_Name );

	initDrop ( dropBtn_Name, dropList_Name, timeout );
	
	dropList.style.display = '';

	if ( !Socang.isOpera ) {
		dropList.style.clip = 'rect(auto, auto, auto, auto)';
	}

	var dropInp_pos = Socang.fetchOffset(dropInp);
	var dropInp_x = dropInp_pos['left'];
	var dropInp_y = dropInp_pos['top'];
	var dropInp_w = dropInp.offsetWidth;
	var dropInp_h = dropInp.offsetHeight;
	var dropList_w = dropList.offsetWidth;
	var dropList_h = dropList.offsetHeight;

	dropList.style.left = dropInp_x - 1 + 'px';
	dropList.style.top = ( dropInp_y + dropInp_h + 4 ) + 'px';
	if ( Socang.isMoz ){
		dropList.style.left = dropInp_x - 2 + 'px';
		dropList.style.top = ( dropInp_y + dropInp_h + 3 ) + 'px';
	}
	if ( Socang.isOpera ){
		dropList.style.left = dropInp_x - 2 + 'px';
		dropList.style.top = ( dropInp_y + dropInp_h + 3 ) + 'px';
	}

	if ( dropList.style.clip && !Socang.isOpera ) {
		dropList.style.clip = 'rect(auto, auto, auto, auto)';
	}
	
	var theInnerString = new String();
	for ( dropNum=0 ; dropNum<arrayDropSearType.length ; dropNum++ ){
		theInnerString = theInnerString+'<span><a onmouseover=\"this.className=\'on\';\" onmouseout=\"this.className=\'\';\" href=\"javascript:dropFillSearType( \'tradeSearch_Inp_SearType\', \''+dropNum+'\')\">'+arrayDropSearType[dropNum][0]+'</a></span>'
	}
	dropList.innerHTML = theInnerString;
}

function dropSearSort(){
	var dropBtn_Name = 'tradeSearch_Btn_SearSort';
	var dropBtn = $(dropBtn_Name);
	var dropInp_Name = 'tradeSearch_Inp_SearSort';
	var dropInp = $(dropInp_Name);
	var dropList_Name = 'tradeSearch_List_SearSort';
	var dropList = $(dropList_Name);
	var timeout = 5000;

	dropBtn.blur();

	if ( !dropList ){
		dropList = document.createElement('div');
		document.body.appendChild(dropList);
		dropList.id = dropList_Name;
		
		hideDrop ( dropList_Name );

		initDrop ( dropBtn_Name, dropList_Name, timeout );
		
		dropList.style.display = '';

		if ( !Socang.isOpera ) {
			dropList.style.clip = 'rect(auto, auto, auto, auto)';
		}

		var dropInp_pos = Socang.fetchOffset(dropInp);
		var dropInp_x = dropInp_pos['left'];
		var dropInp_y = dropInp_pos['top'];
		var dropInp_w = dropInp.offsetWidth;
		var dropInp_h = dropInp.offsetHeight;
		var dropList_w = dropList.offsetWidth;
		var dropList_h = dropList.offsetHeight;

		dropList.style.left = dropInp_x  + 'px';
		dropList.style.top = ( dropInp_y + dropInp_h + 4 ) + 'px';
		if ( Socang.isMoz ){
			dropList.style.left = dropInp_x - 1 + 'px';
			dropList.style.top = ( dropInp_y + dropInp_h + 3 ) + 'px';
		}
		if ( Socang.isOpera ){
			dropList.style.left = dropInp_x - 1 + 'px';
			dropList.style.top = ( dropInp_y + dropInp_h + 3 ) + 'px';
		}

		if ( dropList.style.clip && !Socang.isOpera ) {
			dropList.style.clip = 'rect(auto, auto, auto, auto)';
		}
		
		var theInnerString = new String();
		for ( dropNum=0 ; dropNum<arrayDropSearSort.length ; dropNum++ ){
			theInnerString = theInnerString+'<span><input type=\"checkbox\" name="theSearSort" class=\"sortCheck\" value=\"'+arrayDropSearSort[dropNum][1]+'\"><cite>'+arrayDropSearSort[dropNum][0]+'</cite></span>';
		}
		theInnerString = theInnerString + '<span><input type=\"button\" class=\"sortSubmit\" onclick=\"dropFillSearSort();\"></span>';
		dropList.innerHTML = theInnerString;

	}else{

		$(dropList).style.display = 'inline';

	}
}

function dropFillSearType ( dropFillTarget, dropFillNum ){
	var theDropFillTarget = $(dropFillTarget);
	var theDropFillTargetSubmit = $(dropFillTarget+'_Submit');
	theDropFillTarget.value = arrayDropSearType[dropFillNum][0];
	theDropFillTargetSubmit.value = arrayDropSearType[dropFillNum][1];
	hideDrop(dropFillTarget.replace('Inp','List'));
}

function dropFillSearSort (){
	dropSearSorts = document.getElementsByName('theSearSort');
	dropSortsInner = '';
	dropSortsText = '';
	for ( dropFillNum2=0 ; dropFillNum2<dropSearSorts.length ; dropFillNum2++ ){
		if ( dropSearSorts[dropFillNum2].checked == true ){
			dropSortsInner = dropSortsInner+'|('+dropSearSorts[dropFillNum2].value+')';
			if ( dropSortsText != '' ) dropSortsText = dropSortsText+'，';
			dropSortsText = dropSortsText+arrayDropSearSort[dropFillNum2][0];
		}
	}
	if ( dropSortsText != '' ){
		$('tradeSearch_Inp_SearSort').value = dropSortsText;
	}else{
		$('tradeSearch_Inp_SearSort').value = '所有分类';
	}
	$('tradeSearch_Inp_SearSort_Submit').value = dropSortsInner;
	hideDrop('tradeSearch_List_SearSort');
}

function submitTradeSearch(theid){
	if ($(theid).value==''){ 
		alert("请输入关键字！");
		return false;
	}
	else
	{
		return true;
	}
}
/* Drop Search Type End */


/* Gobal Operation Start */
var thePnlBlock = new String();
var thePnlId = new String();
var thePnlNum = new String();
var thePnlon = 0;

function setPnl(pnlBlock,pnlId,pnlNum) {
	thePnlBlock = pnlBlock;
	thePnlId = pnlId;
	thePnlNum = pnlNum;

	var n = parseInt(pnlNum);
	var pnlSel = $(pnlBlock+'_'+pnlId);
	if (pnlSel.className=='pnlSelon'){
		pnlSel.getElementsByTagName('a')[0].blur();
		return;
	}
	var pnlSels = pnlSel.parentNode.getElementsByTagName('li');
	for(i=0; i<pnlSels.length; i++) {
		if (pnlSels[i].className != 'pnlSelad' ){
			if ( pnlSels[i].className == 'pnlSelon' ) {
				thePnlon = i;
			}
			pnlSels[i].className = '';
		}
	}
	pnlSels[n].className = 'pnlSelon';
	pnlSels[n].getElementsByTagName('a')[0].blur();
	
	processPnlChange = setInterval ( 'pnlChange(\''+pnlBlock+'\',\''+pnlId+'\',\''+pnlNum+'\')', 50 ); 
}

function pnlChange(pnlBlock,pnlId,pnlNum){

	pnlSel = $(pnlBlock+'_'+pnlId);
	var pnlConts = pnlSel.parentNode.parentNode.getElementsByTagName('ul')[1].getElementsByTagName('li');
	var curPnl = $(pnlBlock+'_'+thePnlon)
	var nextPnl = $(pnlBlock+'_'+pnlNum);
	nextPnl.style.display = 'inline';

	var curPnlOpacity = curPnl.getStyle('opacity');
	var nextPnlOpacity = nextPnl.getStyle('opacity');

	if ( curPnlOpacity<0.25 ){
		clearInterval(processPnlChange);
		nextPnl.className = 'pnlConton';
		nextPnl.setOpacity('1');
		nextPnl.style.display = 'inline';
		curPnl.className = 'pnlContoff';
		curPnl.setOpacity('0.06');
		curPnl.style.display = 'none';
	}else{
		nextPnlOpacity = nextPnlOpacity*2;
		curPnlOpacity = curPnlOpacity/2;
		curPnl.setOpacity(curPnlOpacity);
		nextPnl.setOpacity(nextPnlOpacity);
	}
}


function finishAD(){
	theTrunAD = 0;
	if ( theClockAD == 0 ){
		removeAD();
	}
}

var theIntervalKill = null;

function removeAD(){
	$('loadSlide').style.width = '298px';
	clearInterval(theIntervalAD);
	clearInterval(theIntervalLoad);
	theDocu = $('frameAll');
	theIntervalKill = setInterval( killAD, 50);
}

function removeAD2(){
	removeAD();
	window.onload = null;
	var rollpicHrefId = 1;
	doRollpicnews();
	doRollwordnews();
}

function killAD(){
	var theAD = $('initalad');
	var adOpacity = theAD.getStyle('opacity');

	if ( adOpacity<0.06 ){
		clearInterval(theIntervalKill);
		document.body.removeChild(theAD);
		theDocu.style.display='block';
	}else{
		adOpacity = adOpacity/2;
		theAD.setOpacity(adOpacity);
	}
}

var startLoad = 1;

/* Gobal Operation End */
