
/*
/*		上海同济留学事务所
/*			Shanghai3h
/*
//****************************************************/

///////////////////////////////////////////////////////
//
//  File			:	common.js
//	Author			:	Cleaner1912@Gmail.com
//  Description		:	for all
//	Last Updated	:	2005-09-28
//
///////////////////////////////////////////////////////


var d = document;


function setWidth()
{	
	// 1003 = 195 + 808, or = 1024 - 17;
	if(d.body.scrollWidth >= 1003 )
	{
		d.getElementById("mostLeft").style.width = d.body.scrollWidth - 1003;	
	}
	else
	{
		//d.getElementById('mostLeft').style.width = d.body.scrollWidth - 1003;	
	}
}

function matchSize()
{
	d.getElementById("matchSize").style.height = d.body.scrollHeight;
}

function fGo(url)
{
	d.location = url;
}

function stopMQ()
{
	var o = d.getElementById("marqueeID");
	o.scrollAmount = 0;
}
function playMQ()
{
	var o = d.getElementById("marqueeID");
	o.scrollAmount = 1;
}

//aRLT = admin Register List Table
function aRLTOver(o)		
{
	o.style.background		= "#807F42";
	o.style.color			= "#FFFFFF";
}

function aRLTOut(o, i)
{
	if(i == 1) {
		o.style.background	= "#E0E0B1";
	}
	else if(i == 2) {
		o.style.background	= "#F2F2E0";
	}

	o.style.color			= "#3F3C3C";
	
}

function init(country, mode)
{
	smFrameID.location			= "country/" + country + mode + ".html";
	srMenu01.src				= "images/country/" + country + "Menu01.gif";
	srMenu02.src				= "images/country/" + country + "Menu02.gif";
	srMenu03.src				= "images/country/" + country + "Menu03.gif";
	scMaps.src					= "images/country/" + country + "Maps.gif";
	countryFlag.src				= "images/country/" + country + "Flag.jpg";
	countryFlag.style.display	= "block";
	if( country == "southkorea" ||
		country == "singapore" ||
		country == "malaysia"
		)
	setPhone();
	if(	country == "japan")
	setPhoneJapan();
}

var x = "none", y = "none", z = "none";			//global, store 3 menus's display property

//function: return display property: x, y and z of "Country", "Collage", "Living", respectively.
function getDisplay(mode) {				
	switch(mode){
	case "Country":
		x = "block";
		y = "none";
		z = "none";
		break;
	case "College":
		x = "none";
		y = "block";
		z = "none";
		break;
	case "Living":
		x = "none";
		y = "none";
		z = "block";
		break;
	}
	//return x, y, z;
}

//function: write menu function
//num = 5, 26, 7 for "Country", "Collage", "Living", respectively.
function writeMenuf(mode, num, display, countryName)	
{
	var Pre	= '<div style="display: ' + display + ';" id="stMenu' + mode + '"><div id="stMenu' + mode + 'Img">';
	var Img	= '<img src="images/stMenu/stMenu'+ mode + '0.png">';
	var End	= '</div><div id="stMenu' + mode + 'Bg"></div></div>';

	for(var i = 1; i <= num; i++) {
		Img += '<a target="smFrameName" href="country/' + countryName + mode + '.html#' + i + '">' + 
			'<img class="stMenuImg" src="images/stMenu/stMenu' + mode + i + '.png"></a>';
	}

	d.write( Pre + Img + End );
}

//main write menu, use function "writeMenuf()"
function writeMenu(mode, countryName)			//mode = "Country", "College", "Living", countryName = country name
{
	getDisplay(mode);							//obtain x, y and z from function "getDisplay(s)"

	writeMenuf("Country", 5, x, countryName);
	writeMenuf("College", 26, y, countryName);
	writeMenuf("Living", 7, z, countryName);
}

//show Menu
function showMenu(mode)
{
	getDisplay(mode);							//obtain x, y and z from function getDisplay()
	da = new Array(x, y, z);

	var ma = d.getElementById("stMenuCountry");
	var mb = d.getElementById("stMenuCollege");
	var mc = d.getElementById("stMenuLiving");

	mm = new Array(ma, mb, mc);

	for(var i = 0; i < mm.length; i++) {
		mm[i].style.display = da[i];
	}
}

//download function 
function stDown(url)
{
	var a = screen.width/2;
	var b = screen.height/2;
	var w = 280;
	var h = 108;
	window.open(url, "_blank", 
		"left=" + (a - w/2) + ", top= " + (b - h/2) + 
		", width=" + w + ", height=" + h + 
		", scrollbars=no, stats=no, toolbar=no");
}

/* play subTopImg filter */
function playSubTopFilter()
{
	var o = d.getElementById("subTopImg");
	if(o != null) {
		var oi = o.childNodes[0];
		oi.style.display = "none";
		oi.style.filter = "progid:DXImageTransform.Microsoft.wipe()";
		oi.filters[0].Apply();
		oi.style.display = "block";
		oi.filters[0].Play();
	}
}

/* home page, 6 flags onmouseover(out) state */
function switchHomeFlag(country, state)
{
	switch(state.toUpperCase()) {
	case "OVER":
		state = "O";
		break;
	case "OUT":
		state = "N";
		break;
	}
	var o = event.srcElement;
	if(o.tagName.toUpperCase() == "IMG") {
		o.src = "images/homeFlag/" + country + state + ".gif";
		o.style.cursor = "hand";
	}
}
/* preload 6 flag' image */
//an array
var homeFlags = new Array("uk", "australia", "germany", "denmark", "holland", "france");
//Preload images's function
function fLoad()
{
	if( d.images ) { 
		if(!d.r) {
			d.r = new Array();
		}
		var j = d.r.length;
		var a = fLoad.arguments;

		for(var i = 0; i < a.length; i++) {
			if( a[i].indexOf("#") != 0 ) {
				d.r[j] = new Image;
				d.r[j++].src = a[i];
			}
		}
	}
}
//prelaod
function preloadSixFlags()
{
	for(var i = 0; i < homeFlags.length; i++) {
		fLoad("images/homeFlag/" + homeFlags[i] + "O.gif");
	}
	
}

function showNewsDetail(id)
{
	window.location = "newsDetail.asp?newsId=" + id;
}

function showNewsDetail2(id)
{
	window.location = "CountryNewsDetail.asp?newsId=" + id;
}

function mmOver(n)
{
	var o1 = d.getElementById("icon" + n);
	var o2 = d.getElementById("icon" + n + "txt");

	o1.src = "images/admin/icon" + n + "O.gif";
	o2.src = "images/admin/icon" + n + "txtO.gif";
}

function mmOut(n)
{
	var o1 = d.getElementById("icon" + n);
	var o2 = d.getElementById("icon" + n + "txt");

	o1.src = "images/admin/icon" + n + "N.gif";
	o2.src = "images/admin/icon" + n + "txtN.gif";
}


//document.oncontextmenu	= function() { return false; };
//document.oncopy			= function() { return false; };
//document.onselectstart	= function() { return false; };


function setPhone() {
	var newPhone = "上海市北京西路1701号静安中华大厦1306室（200040）<strong> 传&nbsp;&nbsp;&nbsp;&nbsp;真: 021-62885852 </strong><br>" +
			"<strong>TEL: 021-32290099 / 62885850&nbsp;&nbsp;&nbsp;&nbsp;E_mail: shanghai_tongji@hotmail.com  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><br>";
	var o = document.getElementById("topAdd");
	o.innerHTML = newPhone;
}

function setPhoneJapan() {
	var newPhone = "上海市北京西路1701号静安中华大厦1306室（200040）<strong> 传&nbsp;&nbsp;&nbsp;&nbsp;真: 021-62885762 </strong><br>" +
			"<strong>TEL: 021-62885750 &nbsp;&nbsp;&nbsp;&nbsp;E_mail: shanghai_tongji@hotmail.com &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日本部经理：周卫平</strong><br>";
	var o = document.getElementById("topAdd");
	o.innerHTML = newPhone;
}

function linkOver(o){
	//o.src = "images/linkPictureM.gif";
	o.style.filter = "alpha(opacity=100)";
}

function linkOut(o){
	//o.src = "images/linkPicture.gif";
	o.style.filter = "alpha(opacity=60)";
}

