﻿// JScript 文件
//输入你希望根据页面高度自动调整高度的iframe的名称的列表
//用逗号把每个iframe的ID分隔. 例如: ["myframe1", "myframe2"]，可以只有一个窗体，则不用逗号。
//定义iframe的ID
//	var iframeids=["searchFrame"];
//如果用户的浏览器不支持iframe是否将iframe隐藏 yes 表示隐藏，no表示不隐藏
function dyniframesize() 
{
	if (document.getElementById)
	{
		//自动调整iframe高度
		var dyniframe = document.getElementById( "JournalList");
		
		var height = 580;
		if( dyniframe && !window.opera)
		{
			dyniframe.style.display="block";
			if( dyniframe.contentDocument && dyniframe.contentDocument.body.offsetHeight) //如果用户的浏览器是NetScape
				dyniframe.height = dyniframe.contentDocument.body.offsetHeight; 
			else if (dyniframe.Document && dyniframe.Document.body ) //如果用户的浏览器是IE
			{
				dyniframe.height = dyniframe.Document.body.scrollHeight;
			}
			if( dyniframe.height > height )
			{
				height = dyniframe.height;
				
			}
		}
		

		var obj = document.getElementById( "leftx" );
		var obj2 = document.getElementById( "tablex" );
		if ( obj == null || obj2 == null )
		{
		    return;
		}
		if( height > 580 )
		{
			obj.style.height = parseInt( height ) + 30;
			obj2.style.height = parseInt( height ) + 30;
			dyniframe.height = parseInt( height ) + 30;
			    //alert( dyniframe.height );
		}
		else
		{
			obj.style.height = 580;
			obj2.style.height = 580;
			dyniframe.height = 580;
		}	
	}
}
		
function UrlEncode( str )
{
	var ret = "";
	var strSpecial = "!\"#$%&'()*+,/:;<=>?[]^`{|}~%";
	for( i = 0; i < str.length; i ++ )
	{
		var chr = str.charAt( i );
		var c = str2asc(chr);
		if( parseInt( "0x" + c ) > 0x7f )
		{
			ret += "%" + c.slice( 0, 2 ) + "%" + c.slice( -2 );
		}
		else
		{
			if( chr == ' ' )
			{
				ret += "+";
			}
			else if( strSpecial.indexOf( chr ) != -1 )
			{
				ret += "%" + c.toString( 16 );
			}
			else
			{
				ret += chr;
			}
		}
	}
	return ret;
}

function UrlDecode(str)
{ 
	var ret=""; 
	for( var i=0; i<str.length; i++ )
	{
		var chr = str.charAt(i); 
		if(chr == "+")
		{ 
			ret+=" ";
		}
		else if( chr=="%" )
		{
			var asc = str.substring(i+1,i+3);
			if( parseInt( "0x" + asc) > 0x7f )
			{
				ret += asc2str( parseInt( "0x" + asc + str.substring( i+4, i+6 ) ) );
				i += 5;
			}
			else
			{
				ret += asc2str( parseInt( "0x" + asc ) );
				i += 2;
			}
		}
		else
		{
			ret += chr;
		}
	} 
	return ret;
}

function sel( str, type )
{
    type = encodeURI( type );
    if( str.length == 0 )
    {
        return;
    }
    if( str == "resource" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyDb.aspx?type=" + type;
    }
    else if( str == "query" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyQuery.aspx?type=" + type;
    }
    else if( str == "journal" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyJournal.aspx?type=" + type;
    }
    else if( str == "rss" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyRss.aspx?type=" + type;
    }
    else if( str == "history" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyHistory.aspx";
    }
    else if( str == "xueke" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyXueke.aspx?type=" + type;
    }
    else if ( str == "store" )
    {
        window.frames.item( 'JournalList' ).location.href = "MyStore.aspx?type=" + type;
        
    }
    dyniframesize();
}

function SelectDB( str )
{
	if( str.length == 0 )
	{
		return;
	}
	var xstr = "JournalList.aspx?type="
	window.frames.item( 'JournalList' ).location.href = xstr + escape(str);
}

function SelectDB2( str )
{
    if( str.length == 0 )
    {
        return;
    }   
    var frm = window.frames.item( 'JournalList' );
	var xstr = frm.location.href;
	var iIndex = xstr.indexOf( "?" );
	if( iIndex != -1 )
		xstr = xstr.substr( 0, iIndex );
    xstr += "?pro=true&word=";
	window.frames.item( 'JournalList' ).location.href = xstr + escape(str);
}

String.prototype.trim = function()
{
	return this.replace( /(^\s*)|(\s*$)/g, "" );
}
