function getDataFromAnchor(anchor, name) {
	name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	var regexS = "[\\?&#]" + name + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(anchor);
	if (results == null)
    	return '';
	else
		return results[1];
}

function GetWinSize(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
  }
  return {winWidth: myWidth-10, winHeight: myHeight-10};
}

function OpenWindow(link, title, width, height) {
 	var isResized = false;
    var winWidth = width + 17;
    var winHeight = height + 33;
    var winSizes = GetWinSize();
    if (winSizes.winWidth < winWidth) {
    	winWidth=winSizes.winWidth;
    	isResized = true;
    }
    if (winSizes.winHeight < winHeight) {
    	winHeight=winSizes.winHeight;
    	isResized = true;
    }
	var symbol = getDataFromAnchor(location.hash, 'symbol');
	var tab = getDataFromAnchor(location.hash, 'tab');
    
	if (symbol != '') {
		link += '#symbol=' + symbol;

		if (tab != '') {
			link += '&tab=' + tab;
		}
	}

	var win;
	if (isResized){
	    win = new Ext.Window({
	        layout: 'fit',
	        modal: true,
	        title: title,
	        width: winWidth,
	        height: winHeight,
	        modal: true,
	        closeAction: 'hide',
	        resizable: false,
	        plain: true,
	        items: new Ext.Panel({
	            deferredRender: false,
	 	    	autoScroll: true,
	            border: false,
	            html: '<IFRAME scrolling="no" src="' + link + '" width="' + width + '" height="' + height + '" frameborder="0">Your browser doesn\'t support iframe.</IFRAME>'
	        })
	    });		
	}
	else{
	    win = new Ext.Window({
	        layout: 'fit',
	        modal: true,
	        title: title,
	        width: winWidth,
	        height: winHeight,
	        modal: true,
	        closeAction: 'hide',
	        resizable: false,
	        plain: true,
	        items: new Ext.Panel({
	            deferredRender: false,
	            border: false,
	            html: '<IFRAME scrolling="no" src="' + link + '" width="' + width + '" height="' + height + '" frameborder="0">Your browser doesn\'t support iframe.</IFRAME>'
	        })
	    });		
	}
    win.show();
}