
$(document).ready(function(){
	  /*
	  
	  $('a').click(function(){
        jQuery(document.body).animate({ 
        width: "1000%"
      }, 1500 );

        setTimeout("nav('"+this.href+"')",1000);
        return false;
    });
	  */
	  
	  
	if($.fn.jcarousel){
		$("#mycarousel li").each(function(i,item){	
			mycarousel_itemList[i] = $(item).html();
		});
		initcarousel();
	}	  
	 	
	
});


var mycarousel_itemList=new Array();

function initcarousel(){
		$('#mycarousel').jcarousel({
			auto: 2,
			scroll:1,
			size:1000000,
			wrap: 'circular',
			initCallback: mycarousel_initCallback,
			itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
			itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
			
		});		
}
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_itemList[idx - 1]);
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};
 
function nav(href){
 location.href=href;
}

  
  


var ie = document.all;
function loadPageSubmit(form,container){
	//$(container).html(loadingContent);

	$.ajax({
		   type: "POST",
		   data:$(form).serialize()+"&save=1",
		   url: $(form).attr('action'),			   
		   cache: false,
		   success: function(msg){ 
			   $(container).html(msg);
			   
		   }
		 });			
	return false;
}

function loadPage(url,container){
		//container=container?container:"#main_content";
		//$(container).html(loadingContent);
		$.ajax({
			   type: "POST",
			   url: url,			   
		   	   cache: false,
			   success: function(msg){
				   $(container).html(msg);
			   }
			 });			
}
function mypopup(url,w,h){
	w = w ? w : 600;
	h = h ? h : 600;	
	t = screen.availHeight/2 - h/2;
	l = screen.availWidth/2 - w/2;	
	window.open(url,'search','width='+w+',height='+h+',top='+t+',left='+l+',toolbars=no');	
}
function toggleAll(cb,name) {
    var val = cb.checked;
	var name = name ? name : 'delete[]';
	var frm = document.list_frm;
	var len = frm.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (frm.elements[i].name==name && !frm.elements[i].disabled) {
			frm.elements[i].checked=val;
		}
	}
}

function showTip(e,name){

	var b = document.getElementById("tipBox_" + name);	
	if(b){
		if(ie){
			b.style.pixelTop = window.event.clientY + 110;
			b.style.pixelLeft = window.event.clientX - 170;		
		}
		else{
			b.style.top = e.pageY;
			b.style.left = e.pageX - 170;	
		}
		b.style.display='block';
	}
}
function hideTip(e,name){
	var b = document.getElementById("tipBox_" + name);
	if(b){
		b.style.display='none';
	}
}

function mypopup(url,w,h){
	if(!w) w = 600;
	if(!h) h = 600;
	mywindow = window.open (url,"mywindow","location=0,status=0,scrollbars=0,width="+w+",height="+h+",left=100,top=100");
} 
function obj(id){
	return document.getElementById(id);
}
function objn(name){
	return document.getElementsByName(name);
}
function OPT(c,t){
	rmAllOpt(c,1);
	if(t!=""){
		myarray = t.split( '|' );
		for ( var i = 0; i < myarray.length; i++ ) {
			if ( myarray[i] != "" ) {
				cur = myarray[i].split( ';' );
				addOpt(c,cur[1], cur[0]);
			}
		}
	}
}
function addOpt(c,text,value){
	c.options[c.options.length] = new Option(text,value);
}
function rmOpt(c,i){
	c.options[i] = null;
}
function rmAllOpt(c,firstOpt){
	k=c.length;
	for(i=0;i<k;i++){
		rmOpt(c,firstOpt);
	}
}
function getValueOfRadio(name){
	var t = document.getElementsByName(name);
	for(var i= 0; i<t.length; i++){
		if(t[i].checked == true){
			return t[i].value;
		}
	}
	return "";
}
function changeRadioValue(name,val){
	var t = document.getElementsByName(name);
	for(var i= 0; i<t.length; i++){
		if(t[i].value == val){
			t[i].checked = true;
		}
	}	
}
function checkAll(name,val){
	if(document.getElementsByTagName('input'))  
	{
		var inpts = document.getElementsByTagName('input');
		for ( i=0;i<inpts.length;i++)
		{
			if(inpts[i].type == "checkbox" || inpts[i].type == "radio" )
 			{
				if(!inpts[i].disabled ){
					inpts[i].checked = val;
				}
			}
		}
	}	
}

function gourl(url){
	window.location = url;
}
function ajax_failure(){
	//alert('Something went wrong...')
}
function ajax_loading(){
	//alert('Loading...');
}
function Only_Numeric(e) {	
	var whichCode = (window.Event) ? e.which : e.keyCode;
	//alert(whichCode);
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 46) return true;  // Point
	if (whichCode > 57 ) return false;
	if (whichCode < 48 && whichCode > 13) return false;
}
function Only_Integer(e) {	
	var whichCode = (window.Event) ? e.which : e.keyCode;
	//alert(whichCode);
	if (whichCode == 13) return true;  // Enter
	if (whichCode > 57 ) return false;
	if (whichCode < 48 && whichCode > 13) return false;
}
