var sdefaultSearchText='Search';
var sdefaultEnterEmailText='enter your email';
//Show Div Section in html
function ShowObject(objectid,hideDelay)
{
       //if (document.layers) document.layers[divid].display="block";
       //else 
       $('#' + objectid).show();
       if (hideDelay>0)
       {
       var js="HideObject('"+objectid+"');";
       setTimeout(js,hideDelay);
       }
       return false;
       //document.getElementById('frmReports').style.display="block";
}
 

//Hide Div Section in html
function HideObject(objectid)
{
       //if (document.layers) document.layers[divid].display = "none";
       //else 
       $('#' + objectid).hide();
       return false;
       //document.getElementById('frmReports').style.display="none";
}

 
//Load selected value into textbox, and hide div
function SetTextbox( TextboxID, data, MyDiv )
{
    sSearch=sSearch+data+' ';
    document.getElementById(TextboxID).focus();
    document.getElementById(TextboxID).value = sSearch;
    
    if ( MyDiv.length > 0 )
    {
        HideObject( MyDiv );
    }
}

function setFocus(ControlID)
{
    setTimeout('document.getElementById("' + ControlID + '").focus()',750);
    return false;
}



function ddlRemoveItem(list, v) 
{
    for ( var i = 0; i < list.options.length; i++ ) 
    {
        if ( list.options[i].value == v ) 
        {
            list.remove(i);
            return;
        }
    }
}
    
function getRandomNumber()
{
return Math.floor(Math.random()*11000000);
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function pausecomp(millis) 
{
lhndate = new Date();
var lhncurDate = null;

do { var lhncurDate = new Date(); } 
while(lhncurDate-lhndate < millis);
} 

function GetPaper(url,href,email,custom1,custom2,custom3,createdby)
{
var oImage = new Image;
	pausecomp(200);
    oImage.src = '/research/download/?url=' + escape(url) + '&href=' + href + '&email=' + email + '&custom1=' + escape(custom1) + '&custom2=' + escape(custom2) + '&custom3=' + escape(custom3) + '&createdby=' + escape(createdby);
    pausecomp(300);

window.open(href);
oImage=null;
return false;
}

function escapeHTML (str)
{
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}; 

function SendGetFileQuery(beatcache,DivNewContent,DivContent, DivContainer,filetype,fileid,email,url,async)
{
    SendQuery(DivNewContent,DivContainer,'getfile','/actions/getPaperStudy.aspx?dd=' + getRandomNumber() + '&PaperStudy=' +filetype + '&PaperStudyID=' + fileid + '&email=' + email + '&URL=' + url,async,getRandomNumber());
    if ($('#' + DivNewContent).html().indexOf('###error###')>-1)
		{
		$('#' + DivNewContent).html($('#' + DivNewContent).html().replace('###error###',''));
		var command="$('#" + DivNewContent + "').hide();$('#" + DivContent + "').show();";
		setTimeout(command,2000);
		}
		$('#' + DivNewContent).show();$('#' + DivContent).hide();
}
function SendFileQuery(beatcache,DivNewContent,DivContent, DivContainer,em,pu,as,async)
{
    SendQuery(DivNewContent,DivContainer,'getfile','/actions/sendwhitepaper.aspx?dd=' + getRandomNumber() + '&em=' + em + '&pu=' + pu + '&as=' + as,async,getRandomNumber());
    if ($('#' + DivNewContent).html().indexOf('###error###')>-1)
		{
		$('#' + DivNewContent).html($('#' + DivNewContent).html().replace('###error###',''));
		var command="$('#" + DivNewContent + "').hide();$('#" + DivContent + "').show();";
		setTimeout(command,2000);
		}
		$('#' + DivNewContent).show();$('#' + DivContent).hide();
}
function SearchPapersStudies(beatcache,DivNewContent,DivContent,DivContainer,sKeyword,filetype)
{
   SendQuery(DivNewContent,DivContainer,'search_cs_wp','/actions/search_cs_wp.aspx?dd=' + getRandomNumber() + '&ps=' +filetype + '&sol=' + SolutionID + '&k=' + sKeyword + '&ind=' + IndustryID,true,getRandomNumber());
   $('.paging').hide();$('#ShowALL').show();
}
function SearchPapersStudiesA()
{
	SearchPapersStudies(getRandomNumber(),'divCases','divCases', 'divCases',escape(sSearch),PaperStudy)
}
