﻿/* Netalogue Functions */
	

function DoMySearch(){
	var mylocation = "";
    if (document.location.href.toLowerCase().indexOf('localhost')>0 || document.location.href.toLowerCase().indexOf('dev.netalogue')>0) {
    //window.location.replace="/ardent/searchresults.aspx?kw=" + escape(document.getElementById("ctl00_tbSearch").value.replace("'","")) + "&tier1=" + escape(document.getElementById("ctl00_ddcategories").options[document.getElementById("ctl00_ddcategories").selectedIndex].value) + "&style=0";
    mylocation = "/scichemdev/searchresults.aspx?kw=" + escape(document.getElementById("ctl00_tbSearchKeyword").value.replace("'","")) + "&category=" + escape(document.getElementById("ctl00_ddSearchCategories").options[document.getElementById("ctl00_ddSearchCategories").selectedIndex].value) + "&categorytext=" + escape(document.getElementById("ctl00_ddSearchCategories").options[document.getElementById("ctl00_ddSearchCategories").selectedIndex].text) + "&style=0&mainsearch=1";
//alert(mylocation);
    }
    else{
    //location.href="/searchresults.aspx?kw=" + escape(document.getElementById("ctl00_tbSearch").value.replace("'","")) + "&tier1=" + escape(document.getElementById("ctl00_ddcategories").options[document.getElementById("ctl00_ddcategories").selectedIndex].value) + "&style=0";
    mylocation = "/searchresults.aspx?kw=" + escape(document.getElementById("ctl00_tbSearchKeyword").value.replace("'","")) + "&category=" + escape(document.getElementById("ctl00_ddSearchCategories").options[document.getElementById("ctl00_ddSearchCategories").selectedIndex].value) + "&categorytext=" + escape(document.getElementById("ctl00_ddSearchCategories").options[document.getElementById("ctl00_ddSearchCategories").selectedIndex].text) + "&style=0&mainsearch=1";
    }
    //window.location.href=mylocation;
    var frm = '<form id="dynForm" action="'+ mylocation + '" method="post"></form>';
    document.body.innerHTML += frm;
	document.getElementById("dynForm").submit();  
}

function clickSearchButton(e){ 	
	
	if (window.event) iKeyCode = window.event.keyCode
	else if (e) iKeyCode = e.which;
		
	if (iKeyCode == 13){ 
	    DoMySearch();
	    return false;
	    //alert("hello");
	    //__doPostBack(buttonid.replace("_", "$").replace("_", "$"),'')
		//return false; 
		//alert ("searchresults.aspx?kw=" + document.getElementById("ctl00_tbSearch").value.replace("'","") + "&tier1=" + document.getElementById("ctl00_ddcategories").options[document.getElementById("ctl00_ddcategories").selectedIndex].value)
		
		//location.href="searchresults.aspx?kw=" + document.getElementById("ctl00_tbSearch").value.replace("'","") + "&tier1=" + document.getElementById("ctl00_ddcategories").options[document.getElementById("ctl00_ddcategories").selectedIndex].value + "&style=0";
	} 
}
	
	
function clickButton(e, buttonid){ 	
	if (window.event) iKeyCode = window.event.keyCode
	else if (e) iKeyCode = e.which;
		
	if (iKeyCode == 13){ 
	    __doPostBack(buttonid.replace("_", "$").replace("_", "$"),'');
		return false; 
	} 
}

function bookmarksite(title, url){
    if (document.all)
    window.external.AddFavorite(url, title);
    else if (window.sidebar)
    window.sidebar.addPanel(title, url, "")
}
	
function selectTheText(myel){
	if(document.getElementById){
        temp = document.getElementById("ctl00$ContentPlaceHolder1$" + myel);
        temp.select();
    }
}

function numbersOnly(myfield, e, dec) {
    var key;
    var keychar;

    if (window.event)
       key = window.event.keyCode;
    else if (e)
       key = e.which;
    else
       return true;
       
    keychar = String.fromCharCode(key);

    if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
       return true;
    else if ((("0123456789").indexOf(keychar) > -1))
       return true;
    else if (dec && (keychar == ".") && (myfield.value.indexOf(keychar) == -1)) {
       return true;
    } else
       return false;
}

    function checkforcookies(){
        document.cookie = "cookies=true";
        var is_cookie = (document.cookie) ? "true" : "false";
        if (is_cookie==false){
            alert("Your current browser security settings\ndo not allow cookies to be stored");
        }
    }

	function ShowTechnical(){
	
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvtechnical").style.display = 'block';
		//document.aspnetForm.cbtech[0].checked=true;
	}
	
	function HideTechnical(){
	
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvtechnical").style.display = 'none';
		//document.aspnetForm.cbtech[1].checked=true;
	}
	
	function ShowRecent(){
	    
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvrecent").style.display = 'block';
	}
	
	function HideRecent(){
	   
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvrecent").style.display = 'none';
	}
	
	function ShowSimilar(){
	    if (document.aspnetForm.cbsim){
	    document.aspnetForm.cbsim[0].checked=true;
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvothers").style.display = 'block';
	    }
	}
	
	function HideSimilar(){
	    if (document.aspnetForm.cbsim){
	    document.aspnetForm.cbsim[1].checked=true;
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvothers").style.display = 'none';
	    }
	}
	function checktech(){
	    if (document.aspnetForm.cbtech){
	        //alert(document.aspnetForm.cbtech[1].checked);
	        if (document.aspnetForm.cbtech[1].checked==true){
    	      HideTechnical();
	        }
	        else{
	            ShowTechnical();
    	        
	        }
	    }
	}
	
	function ShowAlternatives(){
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvalternatives").style.display = 'block';
	}
	
	function HideAlternatives(){
	    var contentprefix = "ctl00$ContentPlaceHolder1$";
	    contentprefix = "";
		document.getElementById(contentprefix + "dvalternatives").style.display = 'none';
	}
