function stAjax(tgt, error, success){
    $.ajax({
            url: tgt,
            type: 'GET',
            dataType: 'text',
            cache: false,
            timeout: 5000,
            error: error,
            success: success
    });
}

function ajaxCall(id, url){
	stAjax(
	url,
	function(){},
	function(xml){
		document.getElementById(id).innerHTML=xml;
	}
	)
}

// Tabbing functions
	function changeTab(src,id,cnt){
		for(var i = 1; i <= cnt; ++i){
			$("#tab"+i).removeClass("on");
			$("#"+src+i).hide();
		}
		$("#"+src+id).show();
		$("#tab"+id).addClass("on");
	}

	function changeScrollTab(scrollsrc,id,scrollcnt){
		for(var i = 1; i <= scrollcnt; ++i){
			$("#icon"+i).removeClass("active");
			$("#"+scrollsrc+i).hide();
		}
		$("#"+scrollsrc+id).show();
		$("#icon"+id).addClass("active");
		if (/msie/i.test (navigator.userAgent)){
			document.getElementById('foot').style.top = '119';
		}else{
			document.getElementById('foot').setAttribute('class','position-new');
		}
	}

	function changeClientTab1(clientsrc1,id,clientcnt1){
		for(var i = 1; i <= clientcnt1; ++i){
			$("#"+clientsrc1+i).hide();
		}
		$("#"+clientsrc1+id).show();
	}

	function changeClientTab2(clientsrc,id,clientcnt){
		for(var i = 1; i <= clientcnt; ++i){
			$("#"+clientsrc+i).hide();
		}
		$("#"+clientsrc+id).show();
	}

	function changeClientTab3(clientsrc3,id,clientcnt3){
		for(var i = 1; i <= clientcnt3; ++i){
			$("#"+clientsrc3+i).hide();
		}
		$("#"+clientsrc3+id).show();
	}

	function changeClientTab4(clientsrc,id,clientcnt){
		for(var i = 1; i <= clientcnt; ++i){
			$("#"+clientsrc+i).hide();
		}
		$("#"+clientsrc+id).show();
	}

	function showLayerOne() {
		$('div#list1').show();
		$('div#list2').hide();
		$('div#list3').hide();
		$('div#foot').hide();
		for(var i=2;i<43;++i){
		    $("#src_"+i).hide();
		}
		$('#src_1').show();
		$('div#leftFake').hide();
		$('#active2').removeClass("active2");
		$('#active1').addClass("active1");
	}
	
	function showLayerTwo() {
		$('div#list1').hide();
		$('div#list3').hide();
		$('div#list2').show();
		$('div#foot').hide();
		$('div#leftFake').hide();
		$('#active1').removeClass("active1");
		$('#active3').removeClass("active3");
		$('#active2').addClass("active2");
	}
	
	function showLayerThree() {
		$('div#list1').hide();
		$('div#list2').hide();
		$('div#list3').hide();
		for(var i=2;i<43;++i){
		    $("#src_"+i).hide();
		}
		$('#src_1').show();
		document.getElementById('foot').style.top=getFooterTopOld();
		$('div#foot').show();
		$('div#leftFake').show();
	}
	
	function showLayerFour() {
		$('div#list1').hide();
		$('div#list2').hide();
		$('div#list3').show();
		$('div#foot').hide();
		$('div#leftFake').hide();
		$('#active1').removeClass("active1");
		$('#active2').removeClass("active2");
		$('#active3').addClass("active3");
	}

	function toggleAllDivs(){
		$('div#list1').hide();
		$('div#list2').hide();
		$('div#list3').hide();
		$('div#foot').hide();
		$('div#leftFake').show();
		$('#active1').removeClass("active1");
		$('#active2').removeClass("active2");
	};

	function toggleDivOpen(){
		$('div#list1').hide();
		$('div#list2').hide();
		$('div#list3').hide();
		$('div#foot').show();
		$('div#leftFake').show();
		$('#active1').removeClass("active1");
		$('#active2').removeClass("active2");
	};

	function toggleDivClose(){
		$('div#list1').hide();
		$('div#list2').hide();
		$('div#list3').hide();
		//$('div#foot').hide();
		switch(document.getElementById('foot').style.top)
		{
			case getFooterTopOld():
				$('div#foot').hide();
				break;
			default:
				document.getElementById('foot').style.top=getFooterTopOld();
		}
		$('div#leftFake').show();
		$('#active1').removeClass("active1");
		$('#active2').removeClass("active2");
	};

	function toggleTest(){
		$('div#spot1').hide();
		$('div#spot2').hide();
		$('div#spot3').show();
		$('#active1').removeClass("active1");
		$('#active2').removeClass("active2");
	};

	function toggleDivTest(){
		$('div#spot1').hide();
		$('div#spot2').show();
		$('div#spot3').hide();
		$('#active1').removeClass("active1");
		$('#active2').removeClass("active2");
	};
	
	$(document).ready(function(){
		$("#btmfake").click(function () {
			$("#foot").hide();
		});

		$("#btmfakeopen").click(function () {
			$("#foot").show();
		});
	});

// simple Accordion
	$(document).ready(function(){
		jQuery('#list1').Accordion({
			active:false
		});
		// bind to change event of select to control first and seconds accordion
		// similar to tab's plugin triggerTab(), without an extra method
		jQuery('#switch select').change(function() {jQuery('#list1').activate( this.selectedIndex-1 );});
		jQuery('#close').click(function() {jQuery('#list1').activate(-1);});
		jQuery('#switch2').change(function() {jQuery('#list1').activate(this.value);});
	});

// JPanel Scroll 
	$(document).ready(function()
	{
		$('.ctn-content').jScrollPane({showArrows:true, maintainPosition:true});
		$('.ctn-content2').jScrollPane({showArrows:true, maintainPosition:true});
	});

	jQuery(document).ready(function() {
	    $('#mycarousel').show();
		jQuery('#mycarousel').jcarousel({
		vertical: false,
		size: '15',
		animation: 'fast'
		});
	});

// Set background image
function setbkimg(id,bgNum)
{
    var el = document.getElementById(id);
   	el.style.backgroundImage='url(images/headers/'+id+'.jpg)';
	el.style.backgroundRepeat='no-repeat';
	el.style.height='24px';
	
	var par = el.parentNode;
	par.style.backgroundImage='url(images/bg' + bgNum + '.gif)';
	par.style.backgroundRepeat='no-repeat';
    par.style.backgroundPosition='172px 28px';
}

function setbck(id,bgNum)
{
    var el = document.getElementById(id);
	el.style.backgroundImage='url(images/bg' + bgNum + '.gif)';
	el.style.backgroundRepeat='no-repeat';
    el.style.backgroundPosition='172px 28px';
}

function getFooterTopNew()
{
    return '119px';
}

function getFooterTopOld()
{
    return '433px';
}