/**
 *
 */

var N = 0; //开关?

/********** Below from iOffice_menu.script *******/
/**
 * check whether select "INPUT" or "CHECKBOX" control
 * control name must = "selection" or "selected"
 * @return true:
 * @return false:
 */
function isSelected(){
   N = (document.all) ? 0 : 1;
   if(N){
       var obj = document.getElementsByTagName("INPUT");
       for(var i=0;i< obj.length; i++){
               var tmp = obj[i].type.toUpperCase();
               var name = obj[i].name;
               if((tmp == "CHECKBOX")&&(obj[i].checked == true)&&(name == "selection" || name == "selected")){
                   return true;
               }
       }
   }else{
       for(var i=0;i<document.all.length;i++){
           if(document.all[i].tagName.toUpperCase() =="INPUT"){
               var tmp = document.all[i].type.toUpperCase();
               var name = document.all[i].name;
               if((tmp == "CHECKBOX")&&(document.all[i].checked == true)&&(name == "selection" || name == "selected")){
                   return true;
               }
           }
       }
   }
    return false;
}

/**
 * System history back
 * append "skipHistoryMan=true" to notify HistoryManager to skip this request
 */
function submitFormBack(){
	window.location="../common/history.do?state=back&skipHistoryMan=true";
	return;
}

/**
 * open a new window with specified URL
 * we want HistoryManager skip this URL, so append a special Flag to URL
 * @param url
 * @param intHeight
 * @param intWidth
 */
function openWindow(url,intHeight, intWidth){
	if( url.indexOf("?")  > 0 ){ // alread have para in url
		url += "&skipHistoryMan=true";
	}else{
		url += "?skipHistoryMan=true";
	}
	window.open(url, 'newwindow', 'height='+ intHeight + ',width=' + intWidth + ', top=0, left=0, toolbar=yes, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no');
}
/**
 * set iOffice System Page Title
 * @param titleName : new title name
 */
function setTitle(titleName){
	N = (document.all) ? 0 : 1;

	try{
		if(N){
			var obj = top.frames[1].document.getElementById("screenName");
			// alert(obj);
			obj.innerHTML = titleName;
		}else{
			top.frames("topFrame").document.all.screenName.innerHTML = titleName;
		}
	}catch(e){
	}
}
/**
 * window.location change to specified URL
 * @param url : URL to move to
 **/
function gotoURL(url){
	gotoURL(url,'false');
	return;
}
/**
 * window.location change to specified URL
 * @param url : URL to move to
 * @param skipHistory : if = true , will append "skipHistoryMan=true" at the end of para url,
 * 			and notify HistoryManager to skip this request
 **/
function gotoURL(url,skipHistory){
	if( skipHistory == 'true' ){
		if( url.indexOf("?")  > 0 ){ // alread have para in url
			url += "&skipHistoryMan=true";
		}else{
			url += "?skipHistoryMan=true";
		}
	}
	window.location.href = url;
	return;
}
/**
 * return to main index page from sub module
 */
function gotoMainpage(){
	var mainUrl = "./portal.do?state=init";
	gotoURL(mainUrl);
}
/**************************** End of from iOffice_menu.script ***************/

/************ Below from iOffice_Popup.js *******************/
var gcToggle = "#ffff00";
var gcBG = "#CCCCFF";

var ctlObj = new Object();
var winPopupWindow = new Object();

function IgnoreEvents(e){
	return false;
}

function HandleFocus(){
	if (winPopupWindow){
		if (!winPopupWindow.win.closed){
			winPopupWindow.win.focus()
		}else{
			window.top.releaseEvents (Event.CLICK|Event.FOCUS)
		}
	}
	return false
}

function ClearContext(obj)
{
	var tag = obj.tagName;
	if(tag=="INPUT" || tag=="SELECT"){
		var tmp = obj.type.toUpperCase();

		if (tmp == "SELECT-ONE" || tmp == "SELECT-MULTIPLE"){
			obj.selectedIndex = -1;
		}
		else if (tmp == "CHECKBOX" || tmp == "RADIO"){
			obj.checked = false;
		}
		else if(tmp == "TEXT" || tmp=="TEXTAREA"){
			obj.value = "";
		}else if(tmp == "PASSWORD"){
			obj.value = "";
		}else if(tmp == "FILE"){
			obj.value = "";
		}
	}else if(tag == "TEXTAREA"){
		obj.value = "";
	}
}

function ClearAll(){
    if(N){
    	objlist = document.getElementByTagName("INPUT");
    	if(objlist != null ){
    	    for(i=0; i<objlist.length; i++){
		ClearContext(objlist[i]);
    	    }
    	}
    	objlist = document.getElementByTagName("SELECT");
    	if(objlist != null ){
    	    for(i=0; i<objlist.length; i++){
		ClearContext(objlist[i]);
    	    }
    	}
    	objlist = document.getElementByTagName("TEXTAREA");
    	if(objlist != null ){
    	    for(i=0; i<objlist.length; i++){
		ClearContext(objlist[i]);
    	    }
    	}
    }else{
	for(i=0;i<document.all.length;i++){
		ClearContext(document.all[i]);
	}
    }
}

///////////////////////////////////////////////////////////////////////////////
//

function fPopUpDlg(dialogType,ctl,WINname,WINwidth,WINheight){
	N = (document.all) ? 0 : 1;

	var endtarget;
	if(dialogType == "POPUPLIST_MEETINGPRESIDIALDEPTNAME"){
		endtarget = "../masterref/popup_meetingPresidialDeptName.jsp";
	}else if(dialogType == "POPUPLIST_MEETINGADDRESS"){
		endtarget = "../masterref/popup_meetingAddress.jsp";
	}else if(dialogType == "POPUPLIST_MEETINGTITLE"){
    	endtarget = "../masterref/popup_meetingTitle.jsp";
	}else if(dialogType == "POPUPLIST_REMARK"){
		endtarget = "../masterref/popup_docr.jsp";
	}else if(dialogType == "POPUPLIST_POSITION"){
		endtarget = "../masterref/popup_position.jsp";
	}else if(dialogType == "POPUPLIST_UNIVERSITY"){
		endtarget = "../masterref/popup_university.jsp";
	}else if(dialogType == "POPUPLIST_MAJOR"){
		endtarget = "../masterref/popup_major.jsp";
	}else if(dialogType == "POPUPLIST_ORGAN"){  //机构名称选择
		endtarget = "../masterref/popup_organ.jsp";
	}else if(dialogType == "POPUPLIST_CONFIRMATION"){   //批复用语选择
		endtarget = "../masterref/popup_confirmation.jsp";
	}else if(dialogType == "POPUPLIST_PROBLEMTYPE"){
		endtarget = "../masterref/popup_problemtype.jsp";
	}else if(dialogType == "POPUPLIST_CERTIFICATION"){
		endtarget = "../masterref/popup_certification.jsp";
	}else if(dialogType == "POPUPLIST_NULLDOCCODE"){
		endtarget = "../masterref/popup_dconullcode.jsp";
	}else if(dialogType == "POPUPLIST_SCHEDULETYPE"){
		endtarget = "../masterref/popup_scheduletype.jsp";
	}else if(dialogType == "POPUPLIST_PLACE"){
		endtarget = "../masterref/popup_place.jsp";
	}else if(dialogType == "POPUPLIST_CONTRACTSTOP"){
		endtarget = "../masterref/popup_contractstop.jsp";
	}else if(dialogType == "POPUPLIST_WHITHER"){
		endtarget = "../masterref/popup_whither.jsp";
	}else if(dialogType == "POPUPLIST_MESSAGETITLE"){
		endtarget = "../masterref/popup_messagetitle.jsp";
	}else if(dialogType == "POPUPLIST_BOOKPURPOSE"){
		endtarget = "../masterref/popup_bookpurpose.jsp";
	} else if(dialogType == "POPUPLIST_CONTRACTSTOP"){
		endtarget = "../masterref/popup_contractstop.jsp";
	}else if(dialogType == "POPUPLIST_APPLICATIONTITLE"){
		endtarget = "../masterref/popup_applicationtitle.jsp";
	}else if(dialogType == "POPUPLIST_DDNAPPLICATIONTITLE"){
		endtarget = "../ddn/popup_ddnApplicationtitle.jsp";
	}else if(dialogType == "POPUPLIST_EMPCURPOSITION"){
		endtarget = "../masterref/popup_empcurposition.jsp";
	}else if(dialogType == "POPUPLIST_SHOWMESSAGETITLE"){
		endtarget = "../masterref/popup_showmessagetitle.jsp";
	}else if(dialogType == "POPUPLIST_COMPANYNAME"){
		endtarget = "../masterref/popup_companyname.jsp";
	}else if(dialogType == "POPUPLIST_BOOKPUBLISHER"){
		endtarget = "../masterref/popup_bookpublisher.jsp";
	}else if(dialogType == "POPUPLIST_BOOKLANGUAGE"){
		endtarget = "../masterref/popup_booklanguage.jsp";
	}else if(dialogType == "POPUPLIST_BOOKCLASSIFY"){
		endtarget = "../masterref/popup_bookclassify.jsp";
	}else if(dialogType == "POPUPLIST_PROVINCE"){
		endtarget = "../masterref/popup_province.jsp";
	}else if(dialogType == "POPUPLIST_RELATIONSHIP"){
		endtarget = "../masterref/popup_relationship.jsp";
	}else if(dialogType == "POPUPLIST_INDUSTRYTYPE"){
		endtarget = "../masterref/popup_industrytype.jsp";
	}else if(dialogType == "POPUPLIST_ENTERPRISETYPE"){
		endtarget = "../masterref/popup_enterprisetype.jsp";
	}else if(dialogType == "POPUPLIST_OPPRSTAGE"){
		endtarget = "../masterref/popup_opprstage.jsp";
	}else if(dialogType == "POPUPLIST_OPPRROLE"){
		endtarget = "../masterref/popup_opprrole.jsp";
	}else if(dialogType == "POPUPLIST_OPPRDOCTYPE"){
		endtarget = "../masterref/popup_opprdoctype.jsp";
	}else if(dialogType == "POPUPLIST_MEASUREUNIT"){
		endtarget = "../masterref/popup_measureunit.jsp";
	}else if(dialogType == "POPUPLIST_GERINFOTYPE"){
		endtarget = "../masterref/popup_gerinfotype.jsp";
	}else if(dialogType == "POPUPLIST_COLORPALATE"){
		endtarget = "../vote/palate.htm";
	}else if(dialogType == "POPUPLIST_SKILLNAME"){
		endtarget = "../masterref/popup_skilllist.jsp";
	}else if(dialogType == "POPUPLIST_SKILLLEVEL"){
		endtarget = "../masterref/popup_skilllevel.jsp";
	}else {
		endtarget = "../masterref/popup_posincharge.htm";
	}
	if(N){
	    	showx = window.screen.width /2;
	    	showy = window.screen.height /2;
	}else{
	    showx = event.screenX - event.offsetX - 4 - WINwidth ; // + deltaX;
	    showy = event.screenY - event.offsetY + 18; // + deltaY;
	}

	if (dialogType == "POPUPLIST_CONTRACTSTOP" ){
	    if(N){
	    	showx = window.screen.width /2;
	    	showy = window.screen.height /2;
	    }else{
	        showx = event.screenX - event.offsetX - WINwidth + 150;
  	        showy = event.screenY - event.offsetY + 20;
	    }
	}

	newWINwidth = WINwidth + 4 + 18;
	var retval;
	if(N){
	    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    	    window.top.onclick=IgnoreEvents;
            window.top.onfocus=HandleFocus;
            winPopupWindow.returnedValue = new Array();
   	    if (dialogType == "POPUPLIST_CONTRACTSTOP" ){
	        if(N){
            	    winPopupWindow.returnFunc = HRMContractN6SubmitDelete;
	        }
	    }
            winPopupWindow.args = ctl;
            winPopupWindow.win = window.open(endtarget,"PopupDialog","dependent=yes,width="+newWINwidth + ",height=" + WINheight )
            winPopupWindow.win.focus()
            winPopupWindow.win.screen.top = showy;
            winPopupWindow.win.screen.left = showx;
            return winPopupWindow;
	}else{
		var features =
		'dialogWidth:'  + newWINwidth  + 'px;' +
		'dialogHeight:' + WINheight + 'px;' +
		'dialogLeft:'   + showx     + 'px;' +
		'dialogTop:'    + showy     + 'px;' +
		'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:no;Resizeable=no';
	    retval = window.showModalDialog(endtarget, " ", features );
        }

	if( retval != null ){
		retval = trim(retval);
		ctl.value = retval;
	}else{
		//alert("canceled");
	}
}


function fPopUpColorDlg(ctrlobj)
{
    if(N){
	    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    	    window.top.onclick=IgnoreEvents;
            window.top.onfocus=HandleFocus;
            winPopupWindow.args = ctrlobj;
            winPopupWindow.returnedValue = new Array();
            winPopupWindow.win = window.open("../vote/palette.htm","CalendarDialog","dependent=yes,width=242px,height=333px" )
            winPopupWindow.win.focus()
            return winPopupWindow;
    }else{
	showx = event.screenX - event.offsetX - 4 - 210 ; // + deltaX;
	showy = event.screenY - event.offsetY + 18; // + deltaY;
	newWINwidth = 380 + 4 + 18;

	retval = window.showModalDialog("../vote/palette.htm", "", "dialogWidth:242px; dialogHeight:333px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
	if( retval != null ){
		ctrlobj.value = retval;
	}else{
	}
    }
}

function fPopUpChart(dialogType,WINwidth,WINheight, para1,para2)
{
    if(N){
	    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    	    window.top.onclick=IgnoreEvents;
            window.top.onfocus=HandleFocus;
	    if(dialogType == "POPUP_VOTECHART"){
			endtarget = "../vote/vote-chart.do?skipHistoryMan=true&action=Init&serialId=" + para1;
	    }
        winPopupWindow.win = window.open(endtarget,"CalendarDialog","dependent=yes,width="+WINwidth + ",height="+WINheight )
        winPopupWindow.win.focus()
        return winPopupWindow;
    }else{
		showx = event.screenX / 3 ; // + deltaX;
		showy = event.screenY / 3 ; // + deltaY;

		var features =
			'dialogWidth:'  + WINwidth  + 'px;' +
			'dialogHeight:' + WINheight + 'px;' +
			'dialogLeft:'   + showx     + 'px;' +
			'dialogTop:'    + showy     + 'px;' +
			'directories:no; localtion:no; menubar:no; status=no; toolbar=no;scrollbars:no;Resizeable=no';

		if(dialogType == "POPUP_VOTECHART"){
			endtarget = "../vote/vote-chart.do?skipHistoryMan=true&action=Init&serialId=" + para1;
		}
		var retval = window.showModalDialog(endtarget, " ", features );
    }
}

////////////////////////////////////////////////////////////////////////
//

function fPopUpCalendarDlg(ctrlobj)
{
	N = (document.all) ? 0 : 1;
	if(N){
	    showx = 220 ; // + deltaX;
	    showy = 220; // + deltaY;
	}else{
	    showx = event.screenX - event.offsetX - 4 - 210 ; // + deltaX;
	    showy = event.screenY - event.offsetY + 18; // + deltaY;
        }
	newWINwidth = 210 + 4 + 18;
	if(N){
	    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    	    window.top.onclick=IgnoreEvents;
            window.top.onfocus=HandleFocus;
            winPopupWindow.args = ctrlobj;
            winPopupWindow.returnedValue = new Array();
            winPopupWindow.args = ctrlobj;
	    newWINwidth = 202;
            winPopupWindow.win = window.open("../common/calendardlg.jsp","CalendarDialog","dependent=yes,width="+newWINwidth + ",height=182px" )
            winPopupWindow.win.focus()
            return winPopupWindow;
	}else{
	    retval = window.showModalDialog("../common/calendardlg.jsp", "", "dialogWidth:197px; dialogHeight:210px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
        }
	if( retval != null ){
		ctrlobj.value = retval;
	}else{
		//alert("canceled");
	}
}

////////////////////////////////////////////////////////////////////////
// 月份选择对话框  Dianhui.He -- 2003/09/08

function fPopUpYearMonthDlg(ctrlobj)
{
	if(N)
	{
    showx = 200 ; // + deltaX;
    showy = 300; // + deltaY;
	}else
	{
    showx = event.screenX - event.offsetX - 150; // + deltaX;
    showy = event.screenY - event.offsetY + 18; // + deltaY;
  }
	//newWINwidth = 210 + 4 + 18;
	newWINwidth = 202;
	if(N)
	{
    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    window.top.onclick = IgnoreEvents;
    window.top.onfocus = HandleFocus;
    winPopupWindow.args = ctrlobj;
    winPopupWindow.returnedValue = new Array();
    winPopupWindow.args = ctrlobj;
    newWINwidth = 202;
    winPopupWindow.win = window.open("../common/yearmonthdlg.jsp","CalendarDialog","dependent=yes,width="+newWINwidth + ",height=182px" )
    winPopupWindow.win.focus()
    return winPopupWindow;
	}else
	{
	  retval = window.showModalDialog("../common/yearmonthdlg.jsp", "", "dialogWidth:146px; dialogHeight:156px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;resizable=no; "  );
  }
	if( retval != null )
	{
		ctrlobj.value = retval;
	}else
	{
	}
}

////////////////////////////////////////////////////////////////////////

//铃音详情
function view(viewUrl)
{
	window.open (viewUrl, "铃音信息", "width=520, height=300, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}

//铃音试听
function taste(tasteUrl)
{
	window.open (tasteUrl, "铃音试听", "width=400, height=120, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}

//套餐详情
function viewRingGroup(viewUrl)
{
	window.open (viewUrl, "套餐信息", "width=600, height=420, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
}


//下载
    function download(downloadUrl)
{
	window.open (downloadUrl, "下载", "width=500, height=180, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=yes");
}

//检验数值合法性
function IsNum(Sign,Str,IsFloat,ValueFlag) 
    {       
	  var Value ; 
	  Value = parseInt(Str); 
	  if (isNaN(Str))
	  {
	    alert(Sign + "应为数值型") ;
	  } 
	  else
	  if ((IsFloat = false) && (Value.toString().length != string.length))
      { 
	    alert(Sign + "应为整数") ;
	  }
	  else
	  if ((ValueFlag == 0) && (Value < 0))
	  {
		alert(Sign + "应大于等于0") ;
	  }
	  else		
	  if ((ValueFlag == 1) && (Value <= 0))
	  {
		alert(Sign + "应大于0") ;
	  }	  
    } 

////////////////////////////////////////////////////////////////////////

//为联通互联网调用portal网站新增
function down(ringId)
{
	  	MM_openBrWindow('/user/ringQuery.do?method=detailInter&type=2&ringId='+ ringId,'订购铃音','width=500,height=457');
}

function listen(ringId)
{
	  	MM_openBrWindow('/user/ringQuery.do?method=detailInter&type=3&ringId='+ ringId,'铃音试听','width=500,height=457');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}