﻿function grpchg(c) {
    if(c.selectedIndex>0)
        document.location.href = c.options[c.selectedIndex].value;
}
function openTipsaEnVan(baseUrl, strPath, lang) {
	//strPath = strPath.replace(/Bazment/g,"B");
	var strUrl='/Bazment/Tipsa.aspx?path='+escape(strPath)+'&baseUrl='+escape(baseUrl)+'&title='+escape(document.title) + "&lang=" + lang;
	openPopupWindow(strUrl, 'Tipsa', 400, 500, 0, 1);
}

function openSeminarSignUp(baseUrl, strPath, programId) {
	//strPath = strPath.replace(/Bazment/g,"B");
	var strUrl='/Bazment/SeminarSignUp.aspx?path='+escape(strPath)+'&baseUrl='+escape(baseUrl)+'&title='+escape(document.title) + '&programId='+programId;
	openPopupWindow(strUrl, 'Seminar Sign Up', 400, 650, 0, 1);
}

function openPopupWindow(strUrl, strWindowName, paramWidth, paramHeight, paramScrollbars, paramresizable) {
	var objNewWin = null;
	try
	{
	    var strWindowFeatures = 'width='+paramWidth+',height='+paramHeight+',scrollbars=0,resizable=0';
	    objNewWin = window.open(strUrl,strWindowName,strWindowFeatures);
	    if (objNewWin != null) {
		    objNewWin.focus();
	    }
	}
	catch(ex)
	{
	    
	    window.open(strUrl, '', 'width=' + paramWidth + ',height='+paramHeight);
	}
}

function openSignUpPopupWindow(strUrl, strWindowName, paramWidth, paramHeight, paramScrollbars, paramresizable) {
	var objNewWin = null;
	try
	{
	    var strWindowFeatures = 'width='+paramWidth+',height='+paramHeight+',scrollbars=1,scrolling,resizable=0';
	    objNewWin = window.open(strUrl,strWindowName,strWindowFeatures);
	    if (objNewWin != null) {
		    objNewWin.focus();
	    }
	}
	catch(ex)
	{
	    window.open(strUrl, '', 'width=' + paramWidth + ',height='+paramHeight + ',scrollbars,scrolling');
	}
}

function openSignUp(baseUrl, strPath, programId, langId, typeId, disTitle, lang) {
	//strPath = strPath.replace(/Bazment/g,"B");'
	var strUrl ='/Bazment/SignUp.aspx?path='+escape(strPath)+'&baseUrl='+escape(baseUrl)+'&title='+escape(document.title) + '&programId='+programId + '&langId=' + langId + '&typeId=' + typeId + "&disTitle="+disTitle + "&lang=" +lang;
	openSignUpPopupWindow(strUrl, 'Sign Up', 400, 650, 1, 1);
}

function openInfoSessionSignUp(baseUrl, strPath, programId, langId, typeId, disTitle, lang, termId, eventId) {
    var strUrl ='/Bazment/SignUp.aspx?path='+escape(strPath)+'&baseUrl='+escape(baseUrl)+'&title='+escape(document.title) + '&programId='+programId + '&langId=' + langId + '&typeId=' + typeId + "&disTitle="+disTitle + "&lang=" +lang + "&programTermId=" + termId + "&eventId=" +eventId ;
	openSignUpPopupWindow(strUrl, 'Sign Up', 400, 650, 1, 1);
}

function openSeminarSignUp(baseUrl, strPath, programId, langId, typeId, disTitle, lang, termId) {
	var strUrl ='/Bazment/SignUp.aspx?path='+escape(strPath)+'&baseUrl='+escape(baseUrl)+'&title='+escape(document.title) + '&programId='+programId + '&langId=' + langId + '&typeId=' + typeId + "&disTitle="+disTitle + "&lang=" +lang + "&programTermId=" + termId;
	openSignUpPopupWindow(strUrl, 'Sign Up', 400, 650, 1, 1);
}

function toggleDiv(id, flagit) {
    if (flagit=="1") {
        if (document.layers) document.layers[''+id+''].visibility = "show";
        else if (document.all) document.all[''+id+''].style.visibility = "visible";
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible";
    }
    else
    if (flagit=="0") {
        if (document.layers) document.layers[''+id+''].visibility = "hide";
        else if (document.all) document.all[''+id+''].style.visibility = "hidden";
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden";
    }
}
function clicked( obj, holder ){
        id = document.getElementById( holder );
        if( id.style.display != 'none' ){
            obj.parentNode.className = 'clicked';
        }else{
            obj.parentNode.className = '';
        }
    }
function ajaxSearch(searchString, type, siteID, url, programTab, seminarTab, personTab, webbTab, infoTab)
{
    SearchService.Search(searchString, type, siteID, url, programTab, seminarTab, personTab, webbTab, infoTab, OnAjaxSearchComplete, OnAjaxSearchError, OnAjaxSearchTimeout);
}

function OnAjaxSearchComplete(args)
{
    window.location.href = window.location.href;
}

function OnAjaxSearchError(args)
{
    
}

function OnAjaxSearchTimeout(args)
{
    
}

function showHide(id, display) {
    var d = document.getElementById(id);
    
    if (display != null)
    {
        d.style.display = display;
    }
    else
    {    
        if(d.style.display == 'block')
            d.style.display = 'none';
        else
            d.style.display = 'block';
    }
}

function showHideOverview(header)
{
    showHide('shortcuts', 'none');
    showHide('customize', 'none');
    showHide('overview');
    
    if (header != null)
        document.getElementById('overview_header').innerHTML = header;
        
    if (document.getElementById('overview').style.display == 'block')
        document.getElementById('overview').focus();
//    else if (document.getElementById('overview').style.display == 'none')
//        clearOverview();
}

function checkSearchStringLength()
{
    return (document.getElementById('ucTopMenu_txnSearchString').value.length >= 2);
}

function overviewSort(type)
{
    clearOverview();
    
    document.getElementById('overview_sort').style.display = 'none';
    document.getElementById('overview_load').style.display = 'block';
    document.getElementById('overview').style.height = '10px';

    for (i = 0; i < 3; i++)
    {
        document.getElementById('sort_' + i).setAttribute('class', (i == type) ? 'active' : '');
        document.getElementById('sort_' + i).setAttribute('className', (i == type) ? 'active' : '');
    }
    
    ajaxGetPages(type);
}

function showHideShortcuts()
{
    showHide('overview', 'none');
    showHide('customize', 'none');
    showHide('shortcuts');
    
    if (document.getElementById('shortcuts').style.display == 'block')
        document.getElementById('shortcuts').focus();
}

function showHideCustomize(header)
{
    showHide('overview', 'none');
    showHide('shortcuts', 'none');
    showHide('customize');
    
    if (header != null)
        document.getElementById('customize_header').innerHTML = header;
    
    if (document.getElementById('customize').style.display == 'block')
        document.getElementById('customize').focus();
}

function checkBrochure(id)
{
    if (document.getElementById(id).checked)
        document.getElementById(id + "_a").style.fontWeight = 'bold';
    else
        document.getElementById(id + "_a").style.fontWeight = 'normal';
}

function validateCheckboxes(sender, args)
{
	var pageElements = document.getElementById('infoSessionSubscribe').getElementsByTagName("*");
	var oneChecked = false;
	
	for (var i = 0; i < pageElements.length; i++)
	{
		if (pageElements[i].type == "checkbox")
		{
			if (pageElements[i].checked == true)
				oneChecked = true;
		}
	}
	
	if (oneChecked == false)
		args.IsValid = false;	
}

function clearInput(ctrl, initValue)
{
    if(ctrl.value.toLowerCase() == 'search' || ctrl.value.toLowerCase() == 'sök')
        ctrl.value = '';
    else if(ctrl.value == '')
        ctrl.value = initValue;
}