/* @charset "UTF-8" */
/*
 * 根据客户端数据，选择相应页面
 */
//var starttime,endtime;
//var stock = '300033',circle = 8192;
//judgeOpen(stock, circle);

/**
 * 判断是个股还是大盘
 * 1 个股
 * 0 大盘
 * @param	股票代码
 * @return	integer
 */
function isStockOrMarket(stock) {
	var quote = {};
	quote = external.createObject('Quote');
	var ret = quote.IsStockOrIndex(stock);
	if (ret == 1) {
		return 1;
	} else {
		return 0;
	}
	
}

/**
 * 判断是分时还是K线 根据周期判断
 * 1 分时
 * 0 K线
 * @param	circle
 * @return	integer
 */
function isDevisionOrKline(circle) {
	var devision = 8192;
	if (circle == devision) {
		return 1;
	} else {
		return 0;
	}
	
}

/**
 * 判断是L2还是统一版
 * 1 L2用户
 * 0 统一版用户
 * @return	integer
 */
function isL2OrUnite() {
	var passport = {};
	passport = external.createObject('Passport');
	if (passport.IsLevel2User()) {
		return 1;
	} else {
		return 0;
	}
}

/**
 * 判断页面类型
 * @param stock		股票代码
 * @param circle	周期
 * [0, 0]		大盘K线区间统计
 * [0, 1]		大盘分时区间统计
 * [1, 1, 0]	个股分时--统一版
 * [1, 1, 1]	个股分时--L2
 * [1, 0, 0]	个股K线区间统计
 * [1, 0, 1]	个股K线区间统计--L2
 */
function judgeOpen(stock, circle) {
	var sm,dk,lu,stockType,code,thsQuote;
	sm = isStockOrMarket(stock);
	dk = isDevisionOrKline(circle);
	lu = isL2OrUnite();
	thsQuote = external.createObject("Quote");
	code = thsQuote.getStockCode(stock);
	
	stockType	= thsQuote.getStockType(stock);
//	alert(stock+'|'+sm+'|'+dk+'|'+lu+'||||'+stockType);
	
	if (sm == 0 && dk == 0) {
		window.location.href = 'mket.html';
	}
	if (sm == 0 && dk == 1) {
//		var gxs	= ['1A0001', '399001','1A0003','399003'];
//		if ($.inArray(code, gxs) >= 0) {
			window.location.href = 'mdet.html';
//		} else {
//			window.location.href = 'mdet2.html';
//		}
	}
	if (sm == 1 && dk == 1 && lu == 0) {
		window.location.href = 'sdfu.html';
	}
	if (sm == 1 && dk == 1 && lu == 1) {
		if (stockType == 1) {
			window.location.href = 'sdfltwo.html';
		} else {
			window.location.href = 'sdfu.html';
		}
	}
	if (sm == 1 && dk == 0 && lu == 0) {
		window.location.href = 'sket.html' ;
	}
	if (sm == 1 && dk == 0 && lu == 1) {
		if (stockType == 1) {
			window.location.href = 'sketfltwo.html';
		} else {
			window.location.href = 'sket.html';
		}
	}
}
