﻿var queryString 	= window.top.location.search.substring(1);		//參數
var xaction				= getParameter(queryString,'action');					//動作
var web_domain		= location.protocol + '//' + location.host + '/';			//網址
var web_imgpath		= location.protocol + '//image.mogan.com.tw/';
var web_img				= web_imgpath + 'images/';
var web_imgcommon	= web_img + 'common/';

var web						= new Object();
web.domain				= location.protocol + '//' + location.host + '/';			//網址
web.imgpath				= location.protocol + '//image.mogan.com.tw/';
web.img						= web.imgpath + 'images/';
web.imgcommon			= web.img + 'common/';

//取得網址參數
function getParameter(queryString,parameterName){
	var parameterName = parameterName + "=";
  if ( queryString.length > 0 ) {
  	begin = queryString.indexOf ( parameterName );
    if ( begin != -1 ) {
    	begin += parameterName.length;
      end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
      	end = queryString.length
      }
      return unescape ( queryString.substring ( begin, end ) );
    }
    return "null";
  }
}

//Cookie設定與讀取
function setCookie(key, value, expire, domain, path){
	var ck					= key + '=' + encodeURIComponent(value);
	if(expire){
		var epr				=new Date();
		epr.setTime(epr.getTime()+ expire*1000 );
		ck						+= ';expires='+ epr.toUTCString();
	}
	if(domain){	ck	+= ';domain='+ domain;}
	if(path){	ck		+= ';path='+ path;}
	document.cookie	=	ck;
}
function getCookie(key){
	if(document.cookie.length==0)	return false;
	var i						= document.cookie.search(key+'=');
	if(i==-1)	return false;
	i								+= key.length+1;
	var j			= document.cookie.indexOf(';', i);
	if(j==-1){	j		= document.cookie.length;}
	return document.cookie.slice(i,j);
}
//隱藏內容處理
function hidden_access(tmp_name,tmp_val){
	var tmp_msg	= new Object();
	tmp_msg			= '';
	tmp_msg			= '<input type="hidden" name="' + tmp_name + '" value="' + tmp_val + '" />';
	return tmp_msg;
}
//黑幕
function ShowMsgBlackBlock(){
	/*
	if($("div[class='window_msg']").css('display')!='none'){
		$("#ShowMsgBlackBlock").css({'display':'none'});
	}else{
		$("#ShowMsgBlackBlock").css({'width':'99%','height':'99%','display':'block'});
	}
	*/
	$("#ShowMsgBlackBlock").css({'width':'100%','height':'100%'});
	$("#ShowMsgBlackBlock").toggle();
}
//語言轉換
function ChangeLanguage(){
	var tmp_sec					= 60*60*24*365;		//Cookie存活時間
	setCookie('TopLanguage',$("#TopLanguage option:selected").val(),tmp_sec);
	window.location.reload();
}
