// JavaScript Document

function GetCookie(name)
{
	var result = null;
	var myCookie = document.cookie + ";";
	var searchName = name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1)
	{
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";",startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
} 

var bInitDialog = false

function initDialog()
{
if (bInitDialog) return
bInitDialog = true
document.write("<span id='dialogBox' style='display:none; z-index:10001'></span>")
document.write("<div id='dialogBoxShadow' style='display:none; z-index:10000'></div>")
}

initDialog()

function showDialog(url, width, height, title)
{
s1 = "<table border='0' width='"
s2 = "' height='"
s3 = "' cellspacing='0' cellpadding='0'><tr><td width='6' height='8'><img style='filter: alpha(opacity=40)' border='0' src='/images/corner1.gif' width='6' height='8'></td><td style='filter: alpha(opacity=40); background: #000000'></td><td width='6' height='8'><img style='filter: alpha(opacity=40)' border='0' src='/images/corner2.gif' width='6' height='8'></td></tr><tr><td style='filter: alpha(opacity=40); background: #000000'></td><td><table border='0' width='100%' cellspacing='0' cellpadding='0' height='100%' style='border: 1px solid #565656'><tr><td width='99%' height='30' bgcolor='#355582' style='padding-left: 12px; font-size: 14px; color: #FFFFFF'><b>"
s4 = "</b></td><td width='30' height='30' bgcolor='#355582' style='padding-right: 10px; font-size: 12px'><a href='javascript:closeDialog()' class='close'><img src='/images/close.gif' border='0'></a></td></tr><tr><td bgcolor='#FFFFFF' colspan='2' style='border-top: 1px solid #565656'><iframe frameBorder='0' width='100%' scrolling='yes' height='"+height+"' src='"+url+"'></iframe></td></tr></table></td><td style='filter: alpha(opacity=40); background: #000000'></td></tr><tr><td width='6' height='8'><img style='filter: alpha(opacity=40)' border='0' src='/images/corner3.gif' width='6' height='8'></td><td style='filter: alpha(opacity=40); background: #000000'></td><td width='6' height='8'><img style='filter: alpha(opacity=40)' border='0' src='/images/corner4.gif' width='6' height='8'></td></tr></table>"
s = s1 + width + s2 + height + s3 + title + s4 
dialogBox.innerHTML = s
dialogBox.style.position = "absolute"
//dialogBox.style.top = (this.document.body.clientHeight - height) / 2 + this.document.body.scrollTop

dialogBox.style.top = document.documentElement.scrollTop + 200;
//dialogBox.style.top = document.body.scrollHeight
//dialogBox.style.top = 200;
dialogBox.style.left = (this.document.body.clientWidth - width) / 2 + this.document.body.scrollLeft
dialogBox.style.display = ""
showShadow()
window.attachEvent("onresize", window_onresize)
}

function closeDialog()
{
dialogBox.innerHTML = ""
window.detachEvent("onresize", window_onresize)
closeShadow()
}

function showShadow()
{
var oShadow = dialogBoxShadow
oShadow['style']['position'] = "absolute"
oShadow['style']['display']	= ""
oShadow['style']['opacity']	= "0.2"
oShadow['style']['filter'] = "alpha(opacity=20)"
oShadow['style']['background'] = "#000000"
oShadow['style']['top'] = "0px"
oShadow['style']['left'] = "0px"

oShadow['style']['width'] = (document.body.scrollLeft + document.body.clientWidth) + "px"
oShadow['style']['height'] = (document.body.scrollTop + document.body.clientHeight) + "px"
window.setTimeout("resetShadow()", 1)
}

function closeShadow()
{
dialogBoxShadow.style.display	= "none"
}

function resetShadow()
{
var oShadow = dialogBoxShadow;
oShadow['style']['width'] = document.body.scrollWidth + "px";
oShadow['style']['height'] = document.body.scrollHeight + "px";
}

function window_onresize()
{
showShadow()
}

/* Greybox Redux
 * Required: http://jquery.com/
 * Written by: John Resig
 * Based on code by: 4mir Salihefendic (http://amix.dk)
 * License: LGPL (read more in LGPL.txt)
 */

var GB_DONE = false;
var GB_HEIGHT = 400;
var GB_WIDTH = 400;
var GB_ANIMATION = 1;

function GB_show(caption, url, height, width) {
  GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  if(!GB_DONE) {
    $(document.body)
      .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
        + "<img src='/js/close.gif' alt='Close window'/></div>");
    $("#GB_window img").click(GB_hide);
    $("#GB_overlay").click(GB_hide);
    $(window).resize(GB_position);
    GB_DONE = true;
  }

  $("#GB_frame").remove();
  $("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");

  $("#GB_caption").html(caption);
  $("#GB_overlay").show();
  GB_position();

  if(GB_ANIMATION)
    $("#GB_window").slideDown("slow");
  else
    $("#GB_window").show();
}

function GB_hide() {
  $("#GB_window,#GB_overlay").hide();
}

function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  $("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px",
    left: ((w - GB_WIDTH)/2)+"px" });
  $("#GB_frame").css("height",GB_HEIGHT - 32 +"px");
}


function getRadioValue(radio)
{
	if (!radio.length && radio.type.toLowerCase() == 'radio')  
	{ return (radio.checked)?radio.value:'';  } 
	if (radio[0].tagName.toLowerCase() != 'input' || radio[0].type.toLowerCase() != 'radio') 
	{ return ''; } 
	var len = radio.length; 
	for(i=0; i<len; i++)
	{
		if (radio[i].checked)
		{ 
		return radio[i].value; 
		} 
	}
	return '';
} 

function addBookmark(title,url) 
{ 
	if (window.sidebar) 
	{ 
		window.sidebar.addPanel(title, url,""); 
	} 
	else if( document.all ) 
	{ 
		window.external.AddFavorite( url, title); 
	} 
	else if( window.opera && window.print ) 
	{ 
		return true; 
	} 
} 

function SetHome(obj,vrl)
{        
	try
	{                 
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(vrl);         
	}        
	
	catch(e)
	{                
		if(window.netscape) 
		{                        
			try 
			{                                
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");                         
			}                        
				catch (e) 
				{                                 
					alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");                         
				}                       
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);                         
				prefs.setCharPref('browser.startup.homepage',vrl);                  
		}        
	}
}

function ismobile(inputString)
{
	var partten = /^1[3,5,8]\d{9}$/;
  if(partten.test(inputString))
  {
  	//alert('是手机号码');
  	return true;
  }
  else
  {
    //alert('不是手机号码');
  	return false;
  }
}

function isphone(inpurStr)
{
	var partten = /^0(([1,2]\d)|([3-9]\d{2}))\d{7,8}$/;
  if(partten.test(inpurStr))
  {
  	//alert('是电话号码');
  	return true;
  }
  else
  {
  	//alert('不是电话号码');
  	return false;
  }
}

function setSelectOption(objId, targetValue)
{
	//alert(targetValue);
  var obj = document.getElementById(objId);
  if(obj)
	{
    var options = obj.options;
    if(options)
		{
      var len = options.length;
      for(var i=0;i < len ; i++)
			{
        if(options[i].value == targetValue)
				{
				 	options[i].defaultSelected = true;
          options[i].selected = true;
					return true;
				}
      }
			//alert('继续执行');
    } 
		else 
		{
      alert('missing element(s)!');
    }
  } 
	else 
	{
    alert('missing element(s)!');
  }
}


