// New Cliqon Javascript Routines
					
var printbutton = "<img src='images/icons/printer.png' class='' style='margin-right:24px; height:18px; cursor:pointer; border:0px; text-decoration:none;' onclick='printHelp();' alt='" + jstr[49] + "' title='" + jstr[49] + "' />"

var subprintbutton = "<img src='images/icons/printer.png' class='ui-dialog-titlebar-print' style='margin-right:24px; height:18px; cursor:pointer; border:0px; text-decoration:none;' onclick='printSub()' alt='" + jstr[49] + "' title='" + jstr[49] + "' />"

var miscprintbutton = "<img src='images/icons/printer.png' class='ui-dialog-titlebar-print' style='margin-right:24px; height:16px; cursor:pointer; border:0px; text-decoration:none;' onclick='printMisc()' alt='" + jstr[49] + "' title='" + jstr[49] + "' />"

function printMisc() {
	$("#miscimage").printArea();	
}

$(document).ready(function(){
	
	$("#open_help").live("click",function(){var strtitle=$(this).attr("title");var w=500;var ww=document.body.clientWidth;var wl=ww-w;wl=(wl/2);$("#popup").dialog({bgiframe:true,modal:false,autoOpen:false,width:w,resizeable:true,title:strtitle,position:[wl,60]});$("#popup").load('includes/getstrref.php?langcd=' + jlcd + '&strref=code(0)');$("#popup").dialog('open')});	
	
	$("#test_unit").live("click",function(){var strtitle=$(this).attr("title");var w=400; var ww=document.body.clientWidth; var wl=ww-w;wl=(wl/2);$("#test").dialog({bgiframe:true,modal:false,autoOpen:false,width:w,resizeable:true, height:600,title:strtitle,position:[wl,60]}); $("#test").load('includes/diagnostics.php?langcd=' + jlcd);$("#test").dialog('open')});	
	
	$("#admin_login").live("click",function(){var strtitle=$(this).attr("rel");var w=260;var ww=document.body.clientWidth;var wl=ww-w;wl=(wl/2);$("#popup").dialog({bgiframe:true,modal:true,autoOpen:false,width:w,resizeable:false,title:strtitle,position:[wl,60]});	$("#popup").load('includes/adminlogin.php?langcd=' + jlcd );$("#popup").dialog('open')});	
	
	$("#dislay_log").click(function(){var w=600; var ww=document.body.clientWidth; var wl=ww-w;wl=(wl/2);$("#popup").dialog({bgiframe:true,modal:false,autoOpen:false,width:w,resizeable:true, height:400,title:'Display Log',position:[wl,60]}); $("#popup").load('errors.txt');$("#popup").dialog('open')});
	
	$('.tips').cluetip({
   		splitTitle: '|', 	// use the invoking element's title attribute to populate the clueTip...
                     		// ...and split the contents into separate divs where there is a "|"
    	showTitle: false 	// hide the clueTip's heading
  	});	

	$("#loading").ajaxStart(function() {
		$(this).show();
	});
	
	$("#loading").ajaxStop(function(){
	   	$(this).hide();
	});
	
	// $('#footer').footer();
	
	$("#printpage").click(function() {
		$("#pagecontent").printArea();
	});

});

// Function to Redirect Page
function ReDirect(URLStr) {location = URLStr; };

// Standard Popup Window without Scroll Bars
var AddPopupWindow=null;
function AddPopup(mypage,myname,w,h,pos,infocus){
	if(pos=='random'){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=='center'){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' +
LeftPosition + ',location=yes,directories=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,dependent=yes';
	AddPopupWindow=window.open('',myname,settings);
	if(infocus=='front'){AddPopupWindow.focus();AddPopupWindow.location = mypage;}
};

// Opens a print popup window
var PrintPopupWindow=null;
function PrintPopup(mypage,myname,w,h,pos,infocus){
	if(pos=='random'){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=='center'){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=yes,toolbar=no,status=no,scrollbars=yes,resizable=yes,dependent=yes,titlebar=no';
	PrintPopupWindow=window.open('',myname,settings);
	if(infocus=='front'){PrintPopupWindow.focus();PrintPopupWindow.location = mypage;}
};

// Opens a print popup window with Scroll Bars
var AddPopupWindowSB=null;
function AddPopupSB(mypage,myname,w,h,pos,infocus){
	if(pos=='random'){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=='center'){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' +
LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,dependent=yes';
	AddPopupWindowSB=window.open('',myname,settings);
	if(infocus=='front'){AddPopupWindowSB.focus();AddPopupWindowSB.location = mypage;}
};

/* Old Cookie Handling */

function getCookie(check_name) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; 
	var i = '';	
	for ( i = 0; i < a_all_cookies.length; i++ ) {
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == check_name ) {
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )	{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) {
		return null;
	}
}

function setCookie(name, value, expires, path, domain, secure) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

function delCookie(name, path, domain) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
// Ends
