/* 
 * Flash handling
 */

function flashControl(SRC,WIDTH,HEIGHT,FLASHVARS,WMODE,BGCOLOR,ALIGN,MARGIN) {

	while ( FLASHVARS.search(' ') != -1 ) {
		FLASHVARS = FLASHVARS.replace(' ', '%20');
	}

	if (ALIGN)
	{
		ALIGN = ' align=' + ALIGN;
	}

	if (MARGIN)
	{
		MARGIN = ' style="margin:' + MARGIN + '"';
	}

	document.write('<object type="application/x-shockwave-flash" data=' + SRC+ ' width=' + WIDTH + ' height=' + HEIGHT + ALIGN + MARGIN + '>');
	document.write('<!--[if IE]><param name="movie" value=' + SRC+ '>< ![endif]-->');

	if ( FLASHVARS ) { document.write('<param name="flashvars" value=' + FLASHVARS + '>'); }
	if ( WMODE ) { document.write('<param name="wmode" value=' + WMODE + '>'); }
	if ( BGCOLOR ) { document.write('<param name="bgcolor" value=' + BGCOLOR + '>'); }

        document.write('<param name="quality" value="high">');
	document.write('<\/object>');
}

/* 
 * Popup function
 */
  
function popup(url,name,width,height,wplus,hplus,focus,left,top,menubar,status,toolbar,scrollbar,resizable,scrx,scry,directories,loc) {
	if ( !url ) return false;
	if ( !name ) name = 'popupWin';
	if ( !width ) width = '';
	if ( !height ) height = '';
	if ( !directories ) directories = 'no';
	if ( !loc ) loc = 'no';
	if ( !menubar ) menubar = 'no';
	if ( !status ) status = 'no';
	if ( !toolbar ) toolbar = 'no';
	if ( !scrollbar ) scrollbar = 'no';
	if ( !resizable ) resizable = 'no';
	if ( !scrx ) scrx = '100';
	if ( !scry ) scry = '100';
	if ( !left ) left = '100';
	if ( !top ) top = '100';
	if ( wplus ) width  += wplus;
	if ( hplus ) height += hplus;

    var popupWin = window.open(url,name,'width='+width+'px,height='+height+'px,left='+left+',top='+top+',menubar='+menubar+',status='+status+',toolbar='+toolbar+',scrollbars='+scrollbar+',resizable='+resizable+',screenX='+scrx+',screenY='+scry+'directories='+directories+',location='+loc);

	if ( focus ) popupWin.focus();
}

/*
 * Form initializtaion
 */

function init(form) {

	var inputs = document.getElementById(form).elements;

	for (i=0;i < inputs.length ; i++) {
		set_input(inputs[i]);
	}

}
function set_input(input) {

	var oldClass = input.className;

	input.onfocus = function() {
		this.className = oldClass+'_in';
	}
	input.onblur = function() {
		this.className = oldClass;
	}
}

function confirmMsg (msg)
{
var con = confirm(msg);
if (con)
        return true ;
else
        return false ;
}

/*
 * Toggle elements
 */

var OLD_LAYER = '';

function toggle(NEW_LAYER, URL) {

    LAYER_OBJ = document.getElementById(NEW_LAYER);
    IS_OPENED = LAYER_OBJ.style.display == 'block' ? true : false;

    if (OLD_LAYER != '' && OLD_LAYER != NEW_LAYER) {

		OLD_LAYER_OBJ = document.getElementById(OLD_LAYER);
        OLD_LAYER_OBJ.style.display = 'none';
    }

    if (OLD_LAYER != NEW_LAYER || !IS_OPENED) {

        LAYER_OBJ.style.display     = 'block';
    }

    OLD_LAYER = NEW_LAYER;

	if (URL) window.location = URL;
}