function clearInput( inp, val ) {
	var doin = document.getElementById( inp ) ;
	if( val == doin.value )
		doin.value = '' ;
}

function openWindow( f, w, h, n ) {
	leftVal = ( screen.width - w ) / 2 ;
	topVal = ( screen.height - h ) / 2 ;

	newWindow = window.open( f, n, 'resizable=no, location=no, menubar=no, scrollbars=no, status=no, toolbar=no, fullscreen=no, dependent=no, width=' + w + ', height=' + h + ', left=' + leftVal + ', top=' + topVal ) ;
}

function show_version( id, products, nds, lang ) {
	if( id != '0' ) {
		call( "/ajax_show_version.php?id=" + id + "&products=" + products + "&nds=" + nds + "&lang=" + lang, null, show_version_callback ) ;
	} else {
		clearId( 'version' ) ;
		clearId( 'products' ) ;
	}
}

function show_version_callback( val ) {
	if( val == '' ) {
		clearId( 'version' ) ;
		clearId( 'products' ) ;
	} else {
		document.getElementById( 'version' ).innerHTML = val ;
	}
}

function show_product( id, products, nds, lang ) {
	if( id != '0' ) {
		call( "/ajax_show_product.php?id=" + id + "&products=" + products + "&nds=" + nds + "&lang=" + lang, null, show_product_callback ) ;
	} else {
		clearId( 'products' ) ;
	}
}

function show_product_callback( val ) {
	if( val == '' ) {
		clearId( 'products' ) ;
	} else {
		document.getElementById( 'products' ).innerHTML = val ;
	}
}

function clearId ( id ) {
	document.getElementById( id ).innerHTML = ' ' ;
}

function validate_form( name, err_hl ) {
	var error = false ;
	var re = /,/ ;
	var i = 0 ;
	var str = document.getElementById( 'NEED' ).value ;
	var errarr = str.split( re ) ;
	for( i = 0; i < errarr.length; i++ ) {
		if( document.getElementById( errarr[i] ) && document.getElementById( errarr[i] ).value == '' ) {
			if( document.getElementById( errarr[i] ).value == '' )
				error = true ;
		} else if( document.getElementById( errarr[i] ) && document.getElementById( errarr[i] ).selectedIndex >= 0 ) {
			if( document.getElementById( errarr[i] )[document.getElementById( errarr[i] ).selectedIndex].value == '' )
				error = true ;
		}
	}
	if( error == true ) {
		alert( err_hl ) ;
		return false ;
	} else
		return true ;
}
