//<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

//var dev_status = true;

var ui = {
	w: 0,
	h: 0,
	bt: {
		mn: {// main navigation
			id: null
		},
		sn: {// main navigation
			id: null
		}
	},
	action: null
};


function getmain() {
	$("#intro").animate({"top": "-850px"}, 'fast');
	$("#main").animate({"top": "8px"}, 'slow');
}

function get(f){
	var target = arguments[1]?arguments[1]:'ct';
	var param = arguments[2]?arguments[2]:null;
	if(f){
		if(typeof(f)=="object"){
			switch(f[0]){
				case "err":
					alert(" -> com.err -> "+f[1]);
					break;
				case "done":
					$('#'+f[2]).html(f[1]);
					if(f[3]=="adsl"){
						get('tarefe', 'smct');
					}
			}
			savewv(false);
		}else{
			if(f!="main_content"){
				savewv(true);
			}
			x_get(f,target,param,get);
		}
	}
}


function click_action(id){
	var target = arguments[1]?arguments[1]:'ct';
	var param = arguments[2]?arguments[2]:null;
	if(id){
		if(ui.bt.mn.id){
			$('#'+ui.bt.mn.id).css({background: 'url(img/02.gif) no-repeat center', color: '#2587CC'});
		}
		ui.bt.mn.id = id;
		$('#'+ui.bt.mn.id).css({background: 'url(img/01.gif) no-repeat center', color: '#646464'});
		get(ui.bt.mn.id,target,param);
	}
}

function check_order_id(i){
	if(i){
		if(typeof(i)=="object"){
			switch(i[0]){
				case "err":
				voi = true;
				set_order(1);
				break;
				case "done":
				voi = false;
				$('#id').css('background-color', '#ffff66');
				$('#id').focus();
				alert("شماره پرونده وارد شده قبلا در بانک اطلاعات شما درج شده است ");
			}
		}else{
			x_get_order(i, check_order_id);
		}
	}
}

function get_order(i){
	if(i){
		if(typeof(i)=="object"){
			switch(i[0]){
				case "err":
				break;
				case "done":
			}

		}else{
			x_get_order(i, get_order);
		}
	}
}

/*
on document ready
*/
$(document).ready(function(){
	get_save_div();
	ui.w = $(window).width();
	ui.h = $(window).height();
	$('#intro').css('right', ((ui.w-$('#intro').width())/2) + 'px');
	$('#intro').show();
	$('#main').css({'height': (ui.h-10) + 'px', 'right': ((ui.w-$('#main').width())/2) + 'px'});
	$('#wait').css({'height': ui.h + 'px', 'width': ui.w + 'px'});
	$('#ct').css('height', (ui.h-335) + 'px');
	if(adm){
		click_action('orderls');
	}else{
		setTimeout("get('main_content');", 1000);
	}
	$(window).bind("load", function (){
		/*
		get_save_div();
		ui.w = $(window).width();
		ui.h = $(window).height();
		$('#intro').css('right', ((ui.w-$('#intro').width())/2) + 'px');
		$('#intro').show();
		$('#main').css({'height': (ui.h-10) + 'px', 'right': ((ui.w-$('#main').width())/2) + 'px'});
		$('#wait').css({'height': ui.h + 'px', 'width': ui.w + 'px'});
		$('#ct').css('height', (ui.h-335) + 'px');
		if(adm){
			click_action('orderls');
		}else{
			setTimeout("get('main_content');", 1000);
		}*/
	}
	);
	$(window).unload(function(){
	});
	$('.nbt').mouseover(function() {
		if(ui.bt.mn.id!=$(this).attr('id')){
			$(this).css({background: 'url(img/01.gif) no-repeat center', color: '#646464'});
		}
	});
	$('.nbt').mouseout(function() {
		if(ui.bt.mn.id!=$(this).attr('id')){
			$(this).css({background: 'url(img/02.gif) no-repeat center', color: '#2587CC'});
		}
	});
	$('.nbt').click(function() {
		var eid = $(this).attr('id');
		click_action(eid, false, (eid=="chat"?$('#ct').width()+","+$('#ct').height():''));
	});
});
