﻿//this function shows the print preview when the print-link is pressed.
//this takes the page name as the argument. example: page_name = 'Commentary.aspx'
function ShowPrintPreview( page_name )
{
    //setting the height of the print preview window (pop up).
    main_content_height = document.getElementById('main-content').offsetHeight ;
    
    //setting the width of the print preview window (pop up).
    main_content_width = document.getElementById('main-content').offsetWidth+31; //here 25 is added considering the width of the vertical scroll bar.
    var baslocation = window.location.host; 
  
    //this function will pop up the print preview window. 
    print_preview = window.open('http://'+baslocation+'/Pages/PrinterFriendly.aspx?pagename='+page_name,'Commentary','width='+main_content_width+',height='+450+',scrollbars=1,toolbar=1');
    
    //moving the window upwards.
    print_preview.moveBy(0,-50);
}

//this function sets site language according to given langtypeid
function SetSiteLanguage(langTypeId)
{
    switch (langTypeId)
    {
        default:
        case 1033:
            pageTracker._setVar('English');
            break;
        case 1034:
            pageTracker._setVar('Spanish');
            break;
        case 1031:
            pageTracker._setVar('German');
            break;
        case 1036:
            pageTracker._setVar('French');
            break;
        case 1040:
            pageTracker._setVar('Italian');
            break;
    }
     
    //if url contains '?'
    /* if(document.location.href.indexOf("?")>-1)
    {
        //remove existing langtype in url (if exists) and redirect
        // var url = document.location.href.replace(/&?LangType=\d+/gi, "") + "&LangType=" + langTypeId;
        // document.location.href = url.replace("?&","?");
    }
    else
    {
        // document.location.href = document.location.href + "?LangType=" + langTypeId;
    } */
}

// this function will submit page on 
// pressing return key in search text
// box or clicking on go button of master page
function SimpleSearchSubmit(evt)
{
    //go button clicked
    if(evt==null)
    {
        document.getElementById("searchType").value = "simple";
        document.forms['simpleSearchForm'].submit();
    }
    else//key pressed in search text box
    {
        var keycode = (window.event)? evt.keyCode : evt.which;	;
        if(keycode==13)
        {
            document.getElementById("searchType").value = "simple";
            document.forms['simpleSearchForm'].submit();
        }
    }
}


// this function will submit page on 
// pressing return key in keyword text
// box or clicking on go button of search page
//function AdvanceSearchSubmit(evt)
//{
//    //go button clicked
//    if(evt==null)
//    {
//        document.getElementById("searchType").value = "advance";
//        document.forms['aspnetForm'].submit();
//    }
//    else//key pressed in search text box
//    {
//        var keycode = (window.event)? evt.keyCode : evt.which;	;
//        if(keycode==13)
//        {
//            document.getElementById("searchType").value = "advance";
//            document.forms['aspnetForm'].submit();
//        }
//    }
//}

