//****************************************************/
/*
/*		上海同济留学事务所
/*			Shanghai3h
/*
//****************************************************/

///////////////////////////////////////////////////////
//
//  File			:	countryList.js
//	Author			:	Cleaner1912@Gmail.com
//  Description		:	for countryList.html
//	Last Updated	:	2005-09-28
//
///////////////////////////////////////////////////////

var d	= document;
cNames	= new Array(
			"australia",	"canada",	"denmark",		"france",
			"germany",		"holland",	"ireland",		"italy",
			"japan",		"malaysia",	"newzealand",	"singapore",
			"southkorea",	"thailand",	"uk",			"usa",
			"sweden",		"finland");

//write 2*16 Divs:
function writeDiv()
{
	var divName, divPic;

	d.write('<div id="divAll" style="display: none;width: 100; height: 100;">');
	for(var i = 0; i < cNames.length; i++) {
		divName = '<div style="display:none;"'
			+ 'id="' + cNames[i] + 'Name" '
			+ 'onClick="cnClick(\'' + cNames[i] + '\')" '
			+ 'onMouseOver="cnOver(\'' + cNames[i] + '\')" '
			+ 'onMouseOut="cnOut(\'' + cNames[i] + '\')" ' 
			+ 'style="cursor: hand; position: absolute; filter:' + f
			+ 'AlphaImageLoader(src=\'images/country/' + cNames[i] + 'NameN.png\');">'
			+ '</div>';

		divPic = '<div id="' + cNames[i] + 'Pic">'
			+ '<img src="images/country/' + cNames[i] + 'Pic.jpg" class="countryPic">'
			+ '</div>';

		d.write( divName + divPic );
	}
	d.write('</div>');
	d.write("<input type=hidden name='country'><input type=hidden name='mode'>");
}


//for shorthand use, we set f = "progid:DXImageTransform.Microsoft."
var f = "progid:DXImageTransform.Microsoft.";

/* use this to get a filter */
function gf()
{
	/*
	n = Math.random();
	if(n == 1) { n = 0;	}
	
	//Property
	Porperty = new Array(
		"irisStyle", 
		"motion1",		"motion2",		"motion3", 
		"wipeStyle1",	"wipeStyle2", 
		"orientation", 
		"direction", 
		"slideStyle", 
		"stretchStyle");
		
	irisStyle		= "circle, plus, cross";
	motion1			= "in, out";
	motion2			= "leftdown, leftup, rightdown, rightup";
	motion3			= "forward, reverse";
	wipeStyle1		= "CLOCK, WEDGE, RADIAL";
	wipeStyle2		= "0, 1";
	orientation 	= "horizontal, vertical";
	direction		= "up, down, right, left";
	slideStyle		= "HIDE, PUSH, SWAP";
	stretchStyle	= "HIDE, PUSH, SPIN";
		
	for(var i = 0; i < Porperty.length; ++i) {
		var pa = eval(Porperty[i]).split(", ");
		Porperty[i] = pa[Math.floor(n * pa.length)];
		//alert(Porperty[i]);
	}
	*/
	
	//a;
	
	//irisStyle
	irisStyle = "circle, plus, cross";
	irisStyle = irisStyle.split(", ");
	irisStyle = irisStyle[Math.floor(Math.random() * irisStyle.length)];

	//motion1
	motion1 = "in, out";
	motion1 = motion1.split(", ");
	motion1 = motion1[Math.floor(Math.random() * motion1.length)];

	//motion2
	motion2 = "leftdown, leftup, rightdown, rightup";
	motion2 = motion2.split(", ");
	motion2 = motion2[Math.floor(Math.random() * motion2.length)];

	//motion3
	motion3 = "forward, reverse";
	motion3 = motion3.split(", ");
	motion3 = motion3[Math.floor(Math.random() * motion3.length)];

	//wipeStyle1
	wipeStyle1 = "CLOCK, WEDGE, RADIAL";
	wipeStyle1 = wipeStyle1.split(", ");
	wipeStyle1 = wipeStyle1[Math.floor(Math.random() * wipeStyle1.length)];

	//wipeStyle2
	wipeStyle2 = "0, 1";
	wipeStyle2 = wipeStyle2.split(", ");
	wipeStyle2 = wipeStyle2[Math.floor(Math.random() * wipeStyle2.length)];

	//orientation
	orientation = "horizontal, vertical";
	orientation = orientation.split(", ");
	orientation = orientation[Math.floor(Math.random() * orientation.length)];

	//direction
	direction = "up, down, right, left";
	direction = direction.split(", ");
	direction = direction[Math.floor(Math.random() * direction.length)];

	//slideStyle
	slideStyle = "HIDE, PUSH, SWAP";
	slideStyle = slideStyle.split(", ");
	slideStyle = slideStyle[Math.floor(Math.random() * slideStyle.length)];

	//stretchStyle
	stretchStyle = "HIDE, PUSH, SPIN";
	stretchStyle = stretchStyle.split(", ");
	stretchStyle = stretchStyle[Math.floor(Math.random() * stretchStyle.length)];

	//duration
	duration = Math.random();
	if(duration < 0.3) duration = 0.3;
	if(duration > 0.9) duration = 0.9;
	
	//overlap
	overlap		= Math.random();
	percent		= Math.random() * 100;

	//squares, GridSize, spokes, bands
	squares		= Math.floor(Math.random() * 10 + 10);
	GridSize	= Math.floor(Math.random() * 10 + 10);
	spokes		= Math.floor(Math.random() * 10 + 10);
	bands		= Math.floor(Math.random() * 5 + 5);

	//all filters
	F	= "Inset(percent=" + percent + ", duration=" + duration + "); "
		+ "RandomDissolve(overlap=" + overlap + ", percent=" + percent + ", duration=" + duration + "); "
		+ "Wheel(spokes=" + spokes + ", duration=" + duration + "); "
		+ "Stretch(stretchStyle=" + stretchStyle + ", duration=" + duration + "); "
		+ "Fade(overlap=" + overlap + ", duration=" + duration + "); "
		+ "Blinds(bands=" + bands + ", direction=" + direction + ", duration=" + duration + "); "
		+ "Slide(slideStyle=" + slideStyle + ", bands=" + bands + ", duration=" + duration +"); "
		+ "Spiral(GridSizeX=" + GridSize + ", GridSizeY=" + GridSize + ", duration=" + duration + "); "
		+ "zigzag(GridSizeX=" + GridSize + ", GridSizeY=" + GridSize + ", duration=" + duration + "); "
		+ "Barn(orientation=" + orientation + ", motion=" + motion1 + ", duration=" + duration + "); "
		+ "Wipe(GradientSize=1.0, wipeStyle=" + wipeStyle2 + ", motion=" + motion3 + ", duration=" + duration + "); "
		+ "Pixelate(MaxSquare=" + squares + ", Duration=" + duration + "); "
		+ "Checkerboard(squaresX=" + squares + ", squaresY=" + squares + ", direction=" + direction + ", duration=" + duration + "); "
		+ "Strips(Motion=" + motion2 + ", duration=" + duration + "); "
		+ "RandomBars(orientation=" + orientation + ", duration=" + duration + "); "
		+ "RadialWipe(wipeStyle=" + wipeStyle1 + ", duration=" + duration + "); "
		+ "Iris(irisStyle=" + irisStyle + ", motion=" + motion1 + ", duration=" + duration + ")";
	//alert(F);
	
	F = F.split("; ");
	
	//random filter
	var ff = f + F[Math.floor(Math.random() * F.length)];
	return ff;
}


//change country Name
//use argument s(string, "N", "O") to indicate that onMouseOver or onMouseOut' src.png
function changeName(country, s)
{
	var cName		= country + "Name";
	var o			= d.getElementById(cName);
	var filterPre	= f + "AlphaImageLoader(src='images/country/";

	var filterEnd;
	if(s == "N") {
		filterEnd = "N.png')";
	}
	else if(s == "O") {
		filterEnd = "O.png')";
	}

	o.style.filter	= filterPre + cName + filterEnd;
}

//show or hide country picture
//use arugment b(bool, 1, 0) to indicate show or hide Pic
function showPic(country, b)
{
	var cPic = country + "Pic";
	var o = d.getElementById(cPic);

	if(b == 1) {
		var myFilter = gf();
		o.style.filter	= myFilter;

		o.filters[0].Apply();
		o.style.display = "block";
		o.filters[0].Play();

		//window.status	= myFilter;
	}
	else if(b == 0) {
		o.style.display = "none";
	}
}

//change country flag:
function changeFlag(country)
{
	var o			= d.getElementById("countryFlag");
	var filter		= f + "Wipe(GradientSize=1.0, wipeStyle=0, motion='reverse') ";

	o.style.filter	= filter;
	o.filters[0].Apply();
	o.style.display = "block";
	o.src			= "images/country/" + country + "Flag.jpg";
	o.filters[0].Play();
}

//restore flag to "TEL"
function restoreFlag()
{
	var o			= d.getElementById("countryFlag");
	var filter		= f + "Wipe(GradientSize=1.0, wipeStyle=0, motion='forward') ";

	o.style.filter	= filter;
	o.filters[0].Apply();
	o.style.display = "block";
	o.src			= "images/subTopTel.jpg";
	o.filters[0].Play();
}

//onMouseOver of countryName:
function cnOver(country)
{	
	changeName(country, "O");
	showPic(country, 1);
	changeFlag(country);
}

//onMouseOut of countryName:
function cnOut(country)
{	
	changeName(country, "N");
	showPic(country, 0);
//	restoreFlag();
}

function cnClick(country)
{	if(country=="italy")
	{
		window.location = "news_20050513001.asp";
	}
	else if(country=="australia")

    {
        window.location = "news_20070403_A.asp";
    }
		/*else if(country=="germany")

	 {
	    window.location = "news_20070403_G.asp";
	 }*/
	 else if(country=="usa")

	 {
	    window.location = "news_20070403_USA.asp";
	 }
	 else if(country=="uk")

	 {
	    window.location = "news_20070403_UK.asp";
	 }
	else
	{
		window.location = "ctemp.asp?country=" + country + "&mode=Country";
	}
}

function cnClick2(country)
{	
	window.location = "ctemp.asp?country=" + country + "&mode=College";
}

function cnClick3(country)
{	
	window.location = "ctemp.asp?country=" + country + "&mode=Living";

}

isAllLoaded = false;

//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];
			}
		}
	}
}

//Preload images
function preloadImages()
{
	for(var i = 0; i < cNames.length; i++) {
		fLoad("images/country/" + 
			cNames[i] + "NameO.png", "images/country/" + 
			cNames[i] + "Flag.jpg");
	}
	isAllLoaded = true;
	setTimeout("showDivAll()", 1000);
}

function showDivAll()
{
	if(isAllLoaded == true) {
		loading.style.display = "none";
		
		divAll.style.filter = f + "fade(overlap=1, duration=1)";
		divAll.filters[0].Apply();
		divAll.style.display = "block";
		divAll.filters[0].Play();
		
		for(var i = 0; i < cNames.length; i++) {
			with(document.getElementById(cNames[i] + "Name")) {
				//filters[1].Apply();
				style.display = "block";
				//filters[1].Play();
			}
		}
			
	}
}

function showMapb(country)
{
	var a = screen.width/2;
	var b = screen.height/2;
	window.open("showMapb.asp?c=" + country, "mapWindow", "left=" + 
		a + ", top= " + b + 
		", width=100, height=100, scrollbars=no, stats=no, toolbar=no");
}

function resizeWindow()
{
	d.body.style.filter = f + "Wipe(GradientSize=1.0, wipeStyle=1, motion='forward')";
	d.body.filters[0].Apply();

	var x = d.body.scrollWidth + 10;
	var y = d.body.scrollHeight + 25;
	var a = (screen.width - x)/2;
	var b = (screen.height - y)/2;
	
	self.moveTo(a, b);
	self.resizeTo(x, y);

	d.body.filters[0].Play();
}


//From Macromedia Dreamweaver

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

