


function my_getbyid(id)
{
   itm = null;
   if (document.getElementById)
   {
      itm = document.getElementById(id);
   }
   else if (document.all)
   {
      itm = document.all[id];
   }
   else if (document.layers)
   {
      itm = document.layers[id];
   }
   
   return itm;
}

function generate_location(type,default_lid,default_slid)
{
	generate_sublocation(type,default_lid,default_slid);
	var location;
	var msg = '工作地区';
	if (type == 'home')
	{
		msg = '户口所在地';
	}

	if(type == 'love')
	{
		location = '<select name="' + type + '_location" id="'+ type + '_location" onChange="generate_sublocation(\'' + type + '\',this.options[this.selectedIndex].value,'  +  default_slid + ')"><option value="0">--不限--</option>';
	}
	else if (my_getbyid('doregister'))
	{
		location = '<select name="' + type + '_location" id="'+ type + '_location" onChange="generate_sublocation(\'' + type + '\',this.options[this.selectedIndex].value,'  +  default_slid + '); Validator.Validate_this(document.getElementById(\'step_one\'), this); " dataType="Number" msg="请选择您的' + msg + '" divId="msg_' + type + '"><option value="">--请选择--</option>';
	}
	else if (my_getbyid('usercp_modify'))
	{
		location = '<select name="' + type + '_location" id="'+ type + '_location" onChange="generate_sublocation(\'' + type + '\',this.options[this.selectedIndex].value,'  +  default_slid + ')">';
	}
	else
	{
		location = '<select name="' + type + '_location" id="'+ type + '_location" onChange="generate_sublocation(\'' + type + '\',this.options[this.selectedIndex].value,'  +  default_slid + ')"><option value="0">--不限--</option>';
	}
	var lid_selected = '';
	for (lid in location_array)
	{
		if (lid == default_lid)
		{
			lid_selected = ' selected';
		}
		else
		{
			lid_selected = '';
		}
		location += '<option value="' + lid + '"' + lid_selected + '>' + location_array[lid] + '</option>';
	}
	location += '</select>';
	my_getbyid(type + '_location_span').innerHTML = location;
}

function generate_sublocation(type,lid,default_slid)
{
	var sublocation = '<select name="' + type + '_sublocation" id="'+ type + '_sublocation">';
	if (type == 'work' && my_getbyid('doregister'))
	{
		sublocation = '<select name="' + type + '_sublocation" id="'+ type + '_sublocation" dataType="Number" msg="请将您的工作地区精确到县市" divId="msg_' + type + '" onchange="Validator.Validate_this(document.getElementById(\'step_one\'), this);">';
	}
	else if (type == 'home' && my_getbyid('doregister'))
	{
		sublocation = '<select name="' + type + '_sublocation" id="'+ type + '_sublocation" dataType="Number" msg="请将您的户口所在地精确到县市" divId="msg_' + type + '" onchange="Validator.Validate_this(document.getElementById(\'step_one\'), this);">';
	}
	var slid_selected = '';
	var none_selected = '';
	if (lid == 0 || default_slid == 0)
	{
		none_selected = ' selected';
	}
	if (type == 'love' || (!my_getbyid('usercp_modify') && !my_getbyid('doregister')))
	{
		sublocation += '<option value="0"' + none_selected + '>--不限-- </option>';
	}
	else if (my_getbyid('doregister'))
	{
		sublocation += '<option value=""' + none_selected + '>--请选择-- </option>';
	}

	if (lid > 0)
	{
		for (slid in sublocation_array[lid])
		{
			if (slid == default_slid)
			{
				slid_selected = ' selected';
			}
			else
			{
				slid_selected = '';
			}
			sublocation += '<option value="' + slid + '"' + slid_selected + '>' + sublocation_array[lid][slid] + '</option>';
		}
	}
	sublocation += '</select>';
	my_getbyid(type + '_sublocation_span').innerHTML = sublocation;
}

function new_window(w,h,url)
{
	var l=(window.screen.width/2)-w/2;
	var t=(window.screen.height/2)-h/2;
	window.open(url,'','width='+w+',height='+h+',top='+t+',left='+l+',menubar=no,toobar=no,scrollbar=no,resizable=no,status=no,loation=no');
}

function generate_loc_uni(default_lid,default_slid)
{
	generate_university(default_lid,default_slid);
	var location = '<select name="uni_location" id="uni_location" onChange="generate_university(this.options[this.selectedIndex].value,'  +  default_slid + ')"><option value="0">--请选择--</option>';
	var lid_selected = '';
	for (lid in location_array)
	{
		if (lid == default_lid)
		{
			lid_selected = ' selected';
		}
		else
		{
			lid_selected = '';
		}
		location += '<option value="' + lid + '"' + lid_selected + '>' + location_array[lid] + '</option>';
	}
	location += '</select>';
	my_getbyid('uni_location_span').innerHTML = location;
}

function generate_university(lid,default_slid)
{
	var university = '<select name="university" id="university" style="width:160px;">';
	var slid_selected = '';
	var none_selected = '';
	if (lid == 0 || default_slid == 0)
	{
		none_selected = ' selected';
	}
	university += '<option value="0"' + none_selected + '>--请选择-- </option>';

	if (lid > 0)
	{
		for (slid in university_array[lid])
		{
			if (slid == default_slid)
			{
				slid_selected = ' selected';
			}
			else
			{
				slid_selected = '';
			}
			university += '<option value="' + slid + '"' + slid_selected + '>' + university_array[lid][slid] + '</option>';
		}
	}
	university += '</select>';
	my_getbyid('university_span').innerHTML = university;
}

function check_all(form_object)
{
	for (var i=0;i<form_object.elements.length;i++)
	{
		var e = form_object.elements[i];
		if ((e.name != 'check_all_box') && (e.type=='checkbox') && (!e.disabled))
		{
			e.checked = form_object.check_all_box.checked;
		}
	}
}

function uncheck_all(form_object)
{	
	var total_checkboxes = 0;
	var total_checkedboxes = 0;
	for (var i=0;i<form_object.elements.length;i++)
	{
		var e = form_object.elements[i];
		if ((e.name != 'check_all_box') && (e.type=='checkbox'))
		{
			total_checkboxes++;
			if (e.checked)
			{
				total_checkedboxes++;
			}
		}
	}
	
	if (total_checkboxes==total_checkedboxes)
	{
		form_object.check_all_box.checked=true;
	}
	else
	{
		form_object.check_all_box.checked=false;
	}
}

/**** story ****/
var bannerAD=new Array();
var bannerADlink=new Array();
var bannerImg_pre = new Array();
var bannerImg = new Array();
var adNum=0;
var sumTime = 5000;

bannerAD[0]="images/20063211858929.gif";
bannerADlink[0]="/index_shmmw.asp?mod=maple&act=qyq";
bannerImg[0]="images/story_homeup_011.gif";
bannerImg_pre[0]="images/story_homeup_01.gif";

bannerAD[1]="images/20063211843765.gif";
bannerADlink[1]="/index_shmmw.asp?mod=maple&act=qyq";
bannerImg[1]="images/story_homeup_022.gif";
bannerImg_pre[1]="images/story_homeup_02.gif";

bannerAD[2]="images/20064714430277.gif";
bannerADlink[2]="/index_shmmw.asp?mod=maple&act=lbs";
bannerImg[2]="images/story_homeup_033.gif";
bannerImg_pre[2]="images/story_homeup_03.gif";

bannerAD[3]="images/200606041108.jpg";
bannerADlink[3]="/index_shmmw.asp?mod=maple&act=bfzh";
bannerImg[3]="images/story_homeup_044.gif";
bannerImg_pre[3]="images/story_homeup_04.gif";

bannerAD[4]="images/200606041101.jpg";
bannerADlink[4]="/index_shmmw.asp?mod=maple&act=xyh";
bannerImg[4]="images/story_homeup_055.gif";
bannerImg_pre[4]="images/story_homeup_05.gif";


var preloadedimages=new Array();
var len = bannerAD.length;
for (i=1;i<len;i++){
	preloadedimages[i]=new Image();
	preloadedimages[i].src=bannerAD[i];
}

function setTransition(){
	if (document.all){
		bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
		bannerADrotator.filters.revealTrans.apply();
	}

}

function playTransition(){
	if (document.all)
		bannerADrotator.filters.revealTrans.play()
}

function nextAd(){
	if(adNum<bannerAD.length-1)
	{
		adNum++;
	}
	else
	{
		adNum=0;
	}

	nextImg(adNum);
}

function nextImg(n){
	adNum = n;
	setTransition();
	document.images.bannerADrotator.src=bannerAD[adNum];
	for(i=0; i<len; i++){
		my_getbyid('bg_' + (i)).src = bannerImg_pre[i];
	}
	my_getbyid('bg_' + (adNum)).src = bannerImg[adNum];

	playTransition();
}

function autoAd(){
	if(sumTime <= 0)
	{
		nextAd();
		sumTime = 5000;
	}
	sumTime = sumTime - 1000;
	theTimer=setTimeout("autoAd()", 1000);
}

function jump2url(){
	jumpUrl=bannerADlink[adNum];
	jumpTarget='_blank';
	if (jumpUrl != ''){
		if (jumpTarget != '')
			window.open(jumpUrl,jumpTarget);
		else
			location.href=jumpUrl;
   }
}

function displayStatusMsg() { 
   status=bannerADlink[adNum];
   document.returnValue = true;
}

function show_nav(index)
{
	for (i=1;i<7;i++)
	{
		if (i == index)
		{
			if (my_getbyid("nav_"+i).style.display == "")
				my_getbyid("nav_"+i).style.display = "none";
			else
				my_getbyid("nav_"+i).style.display = "";
		}
		else
			my_getbyid("nav_"+i).style.display = "none";
	}
}
