/****************************************** For Dictionary ********************************************************/
var str = "";
function autodict() {
	if (document.selection && document.selection.createRange) {
        if (event.srcElement.tagName == "A" || event.srcElement.tagName == "IMG" ||
            event.srcElement.tagName == "INPUT") {
            return false;
        }
        if(document.selection.type == "Text"){
           	var range = document.selection.createRange();
            str = range.text;
        }
    }
    else if(window.getSelection){
       	str=window.getSelection();
     }else if(BR_NS6 || BR_NS4){
       	str=document.getSelection();
     }
    if (str.length > 50)
          str = "";
}
document.onmouseup = autodict;

function openDictionary() {
        if(str!=""){
         action='Lookup';
      }else{
          action='List';
      }
    var link = this.href +'&queryTerm='+str+'&method='+action+'&dictionaryId='+'D001';

    remote = window.open(link,"galeChildWindow","alwaysRaised=yes,width=720,height=520,screenX=50,screenY=50,top=50,left=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,status=no");
    return false;
}

function citation_download(q_string) {
	var checkval = '';
	var querystring = '';
	$("input[@type='radio'][@name='formats']").each(
		function()
		{ 
			if(this.checked)
			{
				checkval = this.value;
			}
		});
	if(checkval == '') {
		citationFormat = '';
	}
	else {
		citationFormat = '&citationFormat='+checkval;
	}
	
	var link = basepath +'start.do?'+ q_string + citationFormat;
    remote = window.open(link,"galeChildWindow","alwaysRaised=yes,width=785,height=825,screenX=50,screenY=50,top=50,left=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,status=no");
}

function openIndexBrowse(a) {
    remote = window.open(a,"galeChildWindow","alwaysRaised=yes,width=765,height=520,screenX=50,screenY=50,top=50,left=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,status=no");
    //return false;
}

function openPrintPreview(a) {
	var link = basepath + a;
	remote = window.open(link,"galeChildWindow","alwaysRaised=yes,width=785,height=825,screenX=50,screenY=50,top=50,left=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,status=no");
}

function openDownload(a) {
	var tabId = document.getElementById('tabId').value;
	var docId = document.getElementById('docId').value; 
	var download_url = document.getElementById('download_url').value;
	download_url = download_url.replace('/gic/gic/?q=article','start.do?q=download');
	alert(download_url);
	var link = download_url;	
	//var link = basepath +'start.do?prodId=GIC&userGroupName=gic_dev&finalAuth=true&q=download&docId='+docId+'&tabID='+tabId;
	//alert(link);
    remote = window.open(link,"galeChildWindow","alwaysRaised=yes,width=765,height=520,screenX=50,screenY=50,top=50,left=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,status=no");
    //return false;
}

function close_popup() {
	window.close()
}


function validate_dm() {
	var checkval = '';
	$("input[@type='radio'][@name='dm_radio']").each(
		function()
		{ 
			if(this.checked)
			{
				checkval = this.value;
				if(checkval == 4)
				{
					document.getElementById("sel_to_day").disabled = false;
					document.getElementById("sel_to_month").disabled = false;
					document.getElementById("sel_to_year").disabled = false;
				}
				else
				{
					document.getElementById("sel_to_day").disabled = true;
					document.getElementById("sel_to_month").disabled = true;
					document.getElementById("sel_to_year").disabled = true;
				}
			}
		});
}


function toolBoxPopupWindow(href){
   window.open(href,"","toolbar=no, directories=no, status=no, location=no, resizable=yes, menubar=yes, scrollbars=yes,screenX=50,screenY=50,top=50,left=50,width=750,height=550");
   return false;
}


